Mentions légales du service

Skip to content
Snippets Groups Projects
Commit a971c28b authored by hhakim's avatar hhakim
Browse files

Add unit tests for Faust mul. by a real scalar (pyfaust and matfaust).

It closes #19 (issue).
parent 4f28eb9d
Branches
Tags
No related merge requests found
......@@ -281,7 +281,18 @@ classdef FaustTest < matlab.unittest.TestCase
ref_mat = ref_full_faust*cmat;
test_mat = F*cmat;
this.verifyEqual(test_mat,ref_mat, 'RelTol', 10^-3)
% mul by real scalar
r = rand();
test_rF = full(F*r);
test_commu_rF = full(r*F)
ref_rF = ref_full_faust*r;
this.verifyEqual(test_rF,ref_rF, 'RelTol', 10^-3);
this.verifyEqual(test_commu_rF,ref_rF, 'RelTol', 10^-3);
this.verifyNotEqual(test_rF, ref_full_faust*(r+1))
this.verifyNotEqual(test_commu_rF, ref_full_faust*(r+1))
this.assertLessThan(norm(full(F'*r)-full(F)'*r)/norm(full(F)'*r), eps(1.))
this.assertLessThan(norm(full(F.'*r)-full(F).'*r)/norm(full(F).'*r), eps(1.))
% TODO: mul by complex scalar (when impl.)
end
function testDelete(this)
......
......@@ -266,7 +266,17 @@ class TestFaustPy(unittest.TestCase):
prod = self.mulFactors().dot(cmat)
test_prod = self.F*cmat
self.assertProdEq(prod, test_prod)
# test mul by a real scalar
import random
r = random.random()*100
test_prod = self.F*r
ref_prod = self.mulFactors()*r
self.assertLess(norm(test_prod.toarray()-ref_prod)/norm(ref_prod),
1**-5)
self.assertLess(norm((self.F.T*r).toarray()-self.F.toarray().T*r)/norm(self.F.toarray().T*r),1**-5)
self.assertLess(norm((self.F.H*r).toarray()-self.F.toarray().T.conj()*r)/norm(self.F.toarray().T.conj()*r),1**-5)
#TODO: test mul by a complex scalar when impl.
def testTranspose(self):
print("testTranspose()")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment