Mentions légales du service

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

Add matfaust.aslazylinearoperator shape optional argument and document it.

parent c49cbf2c
Branches
Tags
No related merge requests found
...@@ -545,7 +545,28 @@ classdef LazyLinearOp < handle % needed to use references on objects ...@@ -545,7 +545,28 @@ classdef LazyLinearOp < handle % needed to use references on objects
b = isa(obj, 'matfaust.lazylinop.LazyLinearOp'); b = isa(obj, 'matfaust.lazylinop.LazyLinearOp');
end end
function lop = create_from_op(obj) %=============================================================
%> Alias of matfaust.lazylinop.aslazylinearoperator.
%=============================================================
function lop = create_from_op(obj, varargin)
nargs = length(varargin);
if nargs >= 1
if ~ strcmp(varargin{1}, 'shape')
error([ varargin{1}, ' is not a valid keyword argument, valid one: ''shape'''])
end
if nargs >= 2
argval = varargin{2};
else
error('''shape'' must be followed by a value')
end
if ismatrix(varargin{2}) && isnumeric(varargin{2}) && all(size(varargin{2}) == [1, 2])
osize = varargin{2};
else
error('the value of ''shape'' must be a valid row-vector of 2 integers')
end
else
osize = size(obj);
end
import matfaust.lazylinop.LazyLinearOp import matfaust.lazylinop.LazyLinearOp
lambdas = cell(1, 4); lambdas = cell(1, 4);
lambdasT = cell(1, 4); lambdasT = cell(1, 4);
...@@ -565,13 +586,13 @@ classdef LazyLinearOp < handle % needed to use references on objects ...@@ -565,13 +586,13 @@ classdef LazyLinearOp < handle % needed to use references on objects
dtype = 'single'; dtype = 'single';
end end
lop = LazyLinearOp(lambdas, size(obj), 'dtype', dtype, ... lop = LazyLinearOp(lambdas, osize, 'dtype', dtype, ...
'root_obj', obj); 'root_obj', obj);
lopT = LazyLinearOp(lambdasT, [size(obj, 2), size(obj, 1)], 'dtype', dtype, ... lopT = LazyLinearOp(lambdasT, [osize(2), osize(1)], 'dtype', dtype, ...
'root_obj', obj); 'root_obj', obj);
lopH = LazyLinearOp(lambdasH, [size(obj, 2), size(obj, 1)], 'dtype', dtype, ... lopH = LazyLinearOp(lambdasH, [osize(2), osize(1)], 'dtype', dtype, ...
'root_obj', obj); 'root_obj', obj);
lopC = LazyLinearOp(lambdasC, size(obj), 'dtype', dtype, ... lopC = LazyLinearOp(lambdasC, osize, 'dtype', dtype, ...
'root_obj', obj); 'root_obj', obj);
lop.lambdas{LazyLinearOp.T} = @() lopT; lop.lambdas{LazyLinearOp.T} = @() lopT;
......
...@@ -3,9 +3,14 @@ ...@@ -3,9 +3,14 @@
%> %>
%> @note obj must support operations and attributes defined in the LazyLinearOp class. %> @note obj must support operations and attributes defined in the LazyLinearOp class.
%> Any operation not supported would raise an exception at the evaluation time. %> Any operation not supported would raise an exception at the evaluation time.
%>
%> @param obj: the root object on which the LazyLinearOp is based (it could %> @param obj: the root object on which the LazyLinearOp is based (it could
%> be a dense matrix, a sparse matrix, a Faust object or almost any %> be a dense matrix, a sparse matrix, a Faust object or almost any
%> object that supports the same kind of functions). %> object that supports the same kind of functions).
%> @param 'shape', [int, int] (optional): defines the shape of the resulting LazyLinearOp. In most cases
%> this argument shouldn't be used because we can rely on size(obj) but
%> if for any reason size(obj) is not well defined the user can explicitly
%> define the shape of the LazyLinearOp.
%> %>
%> @retval L: a LazyLinearOp instance based on obj. %> @retval L: a LazyLinearOp instance based on obj.
%> %>
...@@ -31,7 +36,7 @@ ...@@ -31,7 +36,7 @@
%> %>
%> @b See @b also: matfaust.rand. %> @b See @b also: matfaust.rand.
%============================================================= %=============================================================
function L = aslazylinearoperator(obj) function L = aslazylinearoperator(obj, varargin)
import matfaust.lazylinop.LazyLinearOp import matfaust.lazylinop.LazyLinearOp
L = LazyLinearOp.create_from_op(obj); L = LazyLinearOp.create_from_op(obj, varargin{:});
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment