Mentions légales du service

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

Add matlab unit tests for LazyLinearOp defined from functions (here fft).

parent 4b1f9580
No related branches found
No related tags found
No related merge requests found
classdef LazyLinearOpFFTTest < LazyLinearOpTest
properties (Constant = true)
%
end
methods(TestClassSetup)
function initializeRandSeed(this)
rng('shuffle')
end
end
methods (TestMethodSetup)
function addFaustToPath(this)
addpath(this.faust_paths{:})
set_path
end
function instantiateTestFaust(this)
import matfaust.rand
import matfaust.lazylinop.*
this.lop = LazyLinearOp.create_from_funcs(@(x) fft(x), @(x) 8 * ifft(x), [8, 8]);
this.from_func = true;
this.lopA = full(this.lop);
F2 = rand(8, 8);
this.lop2 = aslazylinearoperator(F2);
this.lop2A = full(F2);
F3 = rand(8, 8);
this.lop3 = aslazylinearoperator(F3);
this.lop3A = full(F3);
end
end
methods(TestMethodTeardown)
end
methods(Static)
end
end
...@@ -7,7 +7,8 @@ classdef LazyLinearOpTest < matlab.unittest.TestCase ...@@ -7,7 +7,8 @@ classdef LazyLinearOpTest < matlab.unittest.TestCase
lop2A; lop2A;
lop3; lop3;
lop3A; lop3A;
faust_paths; faust_paths;
from_func;
end end
properties (Constant = true) properties (Constant = true)
...@@ -32,6 +33,7 @@ classdef LazyLinearOpTest < matlab.unittest.TestCase ...@@ -32,6 +33,7 @@ classdef LazyLinearOpTest < matlab.unittest.TestCase
import matfaust.lazylinop.aslazylinearoperator import matfaust.lazylinop.aslazylinearoperator
F1 = rand(10, 15); F1 = rand(10, 15);
this.lop = aslazylinearoperator(F1); this.lop = aslazylinearoperator(F1);
this.from_func = false;
this.lopA = full(F1); this.lopA = full(F1);
F2 = rand(10, 15); F2 = rand(10, 15);
this.lop2 = aslazylinearoperator(F2); this.lop2 = aslazylinearoperator(F2);
...@@ -105,10 +107,12 @@ classdef LazyLinearOpTest < matlab.unittest.TestCase ...@@ -105,10 +107,12 @@ classdef LazyLinearOpTest < matlab.unittest.TestCase
this.verifyTrue(ismatrix(lmul2)) this.verifyTrue(ismatrix(lmul2))
this.verifyEqual(full(lmul2), this.lopA * M, 'AbsTol', 1e-6) this.verifyEqual(full(lmul2), this.lopA * M, 'AbsTol', 1e-6)
lmul2 = this.lop * sparse(M) if ~ this.from_func
this.verifyFalse(isLazyLinearOp(lmul2)) lmul2 = this.lop * sparse(M)
this.verifyTrue(ismatrix(lmul2)) this.verifyFalse(isLazyLinearOp(lmul2))
this.verifyEqual(full(lmul2), this.lopA * M, 'AbsTol', 1e-6) this.verifyTrue(ismatrix(lmul2))
this.verifyEqual(full(lmul2), this.lopA * M, 'AbsTol', 1e-6)
end
lmul3 = this.lop * M(:, 1) lmul3 = this.lop * M(:, 1)
this.verifyFalse(isLazyLinearOp(lmul3)) this.verifyFalse(isLazyLinearOp(lmul3))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment