Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
faust
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
GitLab upgrade completed. Current version is 17.11.4.
Show more breadcrumbs
faust group
faust
Commits
3a41ff0d
Commit
3a41ff0d
authored
7 years ago
by
hhakim
Browse files
Options
Downloads
Patches
Plain Diff
Add unit tests for Matlab wrapper Faust class.
parent
48678a84
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
misc/test/src/Matlab/FaustTest.m
+117
-4
117 additions, 4 deletions
misc/test/src/Matlab/FaustTest.m
with
117 additions
and
4 deletions
misc/test/src/Matlab/FaustTest.m
+
117
−
4
View file @
3a41ff0d
...
...
@@ -4,11 +4,13 @@ classdef FaustTest < matlab.unittest.TestCase
properties
test_faust
faust_paths
end
factors
num_factors
end
properties
(
Constant
=
true
)
MAX_NUM_FACTORS
=
64
MAX_DIM_SIZE
=
1024
MAX_NUM_FACTORS
=
32
MAX_DIM_SIZE
=
512
end
methods
(
TestClassSetup
)
...
...
@@ -34,6 +36,8 @@ classdef FaustTest < matlab.unittest.TestCase
factors
{
i
}
=
sprand
(
d1
,
d2
,
density
);
end
this
.
test_faust
=
Faust
(
factors
,
1.0
,
0
)
this
.
factors
=
factors
this
.
num_factors
=
num_factors
end
end
...
...
@@ -78,6 +82,106 @@ classdef FaustTest < matlab.unittest.TestCase
delete
(
filepath_ref
)
delete
(
filepath_test
)
end
function
testSize
(
this
)
disp
(
'testSize()'
)
[
num_rows
,
num_cols
]
=
size
(
this
.
test_faust
)
num_facs
=
this
.
num_factors
size_first_fac
=
size
(
this
.
factors
{
1
})
size_last_fac
=
size
(
this
.
factors
{
num_facs
})
this
.
verifyEqual
(
num_rows
,
size_first_fac
(
1
))
this
.
verifyEqual
(
num_cols
,
size_last_fac
(
2
))
end
function
testGetFactorAndConstructor
(
this
)
disp
(
'testGetFactorAndConstructor()'
)
for
i
=
1
:
this
.
num_factors
this
.
verifyEqual
(
get_fact
(
this
.
test_faust
,
i
),
full
(
this
.
factors
{
i
}))
end
end
function
testGetNumFactors
(
this
)
disp
(
'testGetNumFactors()'
)
this
.
verifyEqual
(
get_nb_factor
(
this
.
test_faust
),
this
.
num_factors
)
end
function
testNorm2
(
this
)
disp
(
'testNorm2()'
)
ref_F
=
this
.
mulFactors
()
this
.
verifyEqual
(
norm
(
ref_F
,
2
),
norm
(
this
.
test_faust
,
2
),
'RelTol'
,
0.05
)
end
function
testnnz
(
this
)
disp
(
'testnnz()'
)
this
.
verifyEqual
(
nnz
(
this
.
test_faust
),
nnzero_count
(
this
.
factors
))
end
function
testDensity
(
this
)
disp
(
'testDensity()'
)
ref_nlines
=
size
(
this
.
factors
{
1
},
1
)
ref_ncols
=
size
(
this
.
factors
{
this
.
num_factors
},
2
)
this
.
verifyEqual
(
nnzero_count
(
this
.
factors
)/
ref_nlines
/
ref_ncols
,
density
(
this
.
test_faust
),
'AbsTol'
,
0.01
)
end
function
testrcg
(
this
)
disp
(
'testrcg()'
)
ref_nlines
=
size
(
this
.
factors
{
1
},
1
)
ref_ncols
=
size
(
this
.
factors
{
this
.
num_factors
},
2
)
this
.
verifyEqual
(
ref_nlines
*
ref_ncols
/
nnzero_count
(
this
.
factors
),
RCG
(
this
.
test_faust
),
'RelTol'
,
0.01
)
end
function
testend
(
this
)
disp
(
'testend()'
)
prod_F
=
this
.
mulFactors
()
for
i
=
1
:
size
(
this
.
factors
{
1
},
1
)
this
.
verifyEqual
(
prod_F
(
i
,
end
),
this
.
test_faust
(
i
,
end
),
'RelTol'
,
0.01
)
end
for
j
=
1
:
size
(
this
.
factors
{
this
.
num_factors
},
2
)
this
.
verifyEqual
(
prod_F
(
end
,
j
),
this
.
test_faust
(
end
,
j
),
'RelTol'
,
0.01
)
end
end
function
testsubsref
(
this
)
disp
(
'testsubsref()'
)
% test whole faust
ref_F
=
this
.
mulFactors
();
test_F
=
this
.
test_faust
(
1
:
end
,
1
:
end
);
this
.
verifyEqual
(
ref_F
(
1
:
end
,
1
:
end
),
test_F
,
'RelTol'
,
0.01
)
% test a random row
row_i
=
randi
(
1
,
size
(
this
.
test_faust
,
1
));
test_F
=
this
.
test_faust
(
row_i
,:);
this
.
verifyEqual
(
test_F
,
ref_F
(
row_i
,:),
'RelTol'
,
0.01
)
% test a random col
col_i
=
randi
(
1
,
size
(
this
.
test_faust
,
2
));
test_F
=
this
.
test_faust
(:,
col_i
);
this
.
verifyEqual
(
test_F
,
ref_F
(:,
col_i
),
'RelTol'
,
0.01
)
end
function
testFull
(
this
)
disp
(
'Test Faust.full()'
)
ref_faust
=
this
.
mulFactors
();
test_faust
=
full
(
this
.
test_faust
);
this
.
verifyEqual
(
test_faust
,
ref_faust
,
'RelTol'
,
10
^-
3
)
end
function
testTranspose
(
this
)
disp
(
'Test Faust.transpose()'
)
% test full matrix to avoid longer time for comparisons (element by
% element)
transp_faust
=
full
(
transpose
(
this
.
test_faust
));
test_faust
=
full
(
this
.
test_faust
);
this
.
verifyEqual
(
test_faust
,
transpose
(
transp_faust
),
'RelTol'
,
10
^-
3
)
end
function
testCtranspose
(
this
)
disp
(
'Test Faust.ctranspose()'
)
%TODO (when the function will be implemeted)
end
function
testConj
(
this
)
disp
(
'Test Faust.conj()'
)
%TODO (when the funciton will be implemented)
end
end
methods
...
...
@@ -85,7 +189,16 @@ classdef FaustTest < matlab.unittest.TestCase
faust_test
.
faust_paths
=
varargin
run
(
faust_test
)
end
end
function
prod_F
=
mulFactors
(
this
)
first_fac_size
=
size
(
this
.
factors
{
1
})
prod_F
=
eye
(
first_fac_size
(
1
));
for
i
=
1
:
this
.
num_factors
prod_F
=
prod_F
*
this
.
factors
{
i
};
end
end
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment