Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 51520cac authored by Nicolas Bellot's avatar Nicolas Bellot Committed by hhakim
Browse files

classe matlab ajout operator A(i,j)

parent d2f4ee75
No related branches found
No related tags found
No related merge requests found
......@@ -4,10 +4,10 @@
nb_fact = 3;
dim1 = 5;
dim2 = 3;
dim2 = 4;
dim3 = 10;
int_max= 100;
threshold = 10^(-15); % equality test
disp('****** TEST MATLAB_FAUST ******* ');
%% creation du faust
disp(' TEST CONSTRUCTOR : ');
......@@ -65,7 +65,7 @@ disp('Ok');
disp('TEST LOAD AND SAVE : ');
filename = [ '@FAUST_BIN_TEST_OUTPUT_DIR@' filesep 'faust.mat'];
disp(['save faust into the file : ' filename]);
save_faust(F,filename);
save(F,filename);
F_loaded = matlab_faust(filename);
[dim1_loaded,dim2_loaded]=size(F_loaded);
......@@ -90,7 +90,7 @@ disp('Ok');
%% get_product test
disp('TEST GET_PRODUCT : ');
F_dense= get_product(F);
F_dense= get_product(F)
[dim1_dense,dim2_dense]=size(F_dense);
if((dim1_dense ~= dim1) | (dim2_dense ~= dim2))
......@@ -99,9 +99,48 @@ end
disp('Ok');
%% slicing test
disp('TEST SLICING : ');
for i=1:dim1
for j=1:dim2
F_i_j=F(i,j);
if (size(F_i_j) ~= [1 1])
error('invalid size of F(i,j)');
end
if (F_i_j ~= F_dense(i,j))
error('F(i,j) ~= F_dense(i,j)');
end
end
end
F_slice_slice=F(:,:);
if (size(F_slice_slice,1) ~= dim1) | (size(F_slice_slice,2) ~= dim2)
error('invalid dimension');
end
if (F_slice_slice ~= F_dense)
error('F(:,:) ~= F_dense');
end
F_slice_slice_2=F(1:dim1,1:dim2);
if (size(F_slice_slice_2,1) ~= dim1) | (size(F_slice_slice_2,2) ~= dim2)
error('invalid dimension');
end
if (F_slice_slice_2 ~= F_dense)
error('F(1:dim1,1:dim2) ~= F_dense');
end
F_inv=F(dim1:-1:1,dim2:-1:1);
if (size(F_inv,1) ~= dim1) | (size(F_inv,2) ~= dim2)
error('invalid dimension');
end
if (F_inv ~= F_dense(dim1:-1:1,dim2:-1:1))
error('F(1:dim1,1:dim2) ~= F_dense(dim1:-1:1,dim2:-1:1)');
end
disp('Ok');
%%% transpose test
disp('TEST TRANSPOSE : ');
......
......@@ -169,7 +169,7 @@ classdef matlab_faust
end
%% save a faust into a matfile
function save_faust(this,filename)
function save(this,filename)
% save a faust into a matfile
if (~ischar(filename))
error('second argument must contains a string (a filename)');
......@@ -187,6 +187,42 @@ classdef matlab_faust
end
%% overloading of the slicing method only for reading the value of the coeff
function submatrix=subsref(this,S)
if (~isfield(S,'type')) | (~isfield(S,'subs'))
error(' subsref invalid structure S missing field type or subs');
end
if (~ischar(S.type)) | (~iscell(S.subs))
error(' subsref invalid structure S, S.type must be a char, S.subs must be a cell-array');
end
if ~strcmp(S.type,'()')
error(' subsref is only overloaded for () operator');
end
if (length(S.subs) ~=2)
invalid(' subsref invalid slicing must have 2 index since this is a 2D-array');
end
slicing_row=S.subs{1};
slicing_col=S.subs{2};
nbcol=size(this,2);
identity=eye(nbcol);
if ~ischar(slicing_col)
identity=identity(:,slicing_col);
end
submatrix=this*identity;
if ~ischar(slicing_row)
submatrix=submatrix(slicing_row,:);
end
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment