Mentions légales du service

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

wrapper matlab : overload matlab builtin function end for Faust class

parent dc80bd92
Branches
Tags
No related merge requests found
......@@ -238,6 +238,20 @@ 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
%% operator end with slicing
F_end = F(1:end,1:end);
if (size(F_end,1) ~= dim1) | (size(F_end,2) ~= dim2)
error('invalid dimension');
end
if (F_end ~= F_dense(1:end,1:end))
error('F(1:end,1:end) ~= F_dense(1:end,1:end)');
end
disp('Ok');
......@@ -289,6 +303,8 @@ end
if ((dim1_trans_trans_eq ~= dim1) | (dim2_trans_trans_eq ~= dim2))
error(['operator = test 3 : invalid dimension']);
end
disp('Ok');
%% test faust multiplication with vector
......@@ -400,13 +416,13 @@ if (y_expected ~= y_mtimes_trans_T)
error(['multiplication faust-vector : invalid result ' ]);
end
disp('Ok');
disp('Ok');
%% test 2-norm (spectral norm)
disp('TEST 2-norm : ');
real_norm=norm(F_dense);
norm_faust=norm(F);
......
......@@ -130,6 +130,25 @@ classdef Faust
end
% end :
% serve as the last index in an indexing expression. In
% that context, end = SIZE(X,k) when used as part of the k-th index.
% Examples of this use are, X(3:end) and X(1,1:2:end-1)
function end_dim = end(this,k,n)
% end - overload of the builtin function end
if (n ~= 2)
error('invalid slicing : faust is a 2D array i.e matrix');
end
end_dim=size(this,k);
end
%% get_fact : return the id factor of the faust as a dense matrix
function factor = get_fact(this,id)
......@@ -183,7 +202,7 @@ classdef Faust
%% subsref : allows operation such as A(i,j) A(:,j) A(3:4,2:5) but not A(end,end)
function submatrix=subsref(this,S)
% overloading of the slicing method only for reading the value of the coeff
% WARNING : operation such as this(end,end) give wrong results (operator end not supported)
if (~isfield(S,'type')) | (~isfield(S,'subs'))
error(' subsref invalid structure S missing field type or subs');
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment