Mentions légales du service

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

Add matfaust.lazylinop.zeros + doc.

parent bd71f781
No related branches found
No related tags found
No related merge requests found
......@@ -31,7 +31,7 @@ if(BUILD_DOCUMENTATION)
string(CONCAT DOXYGEN_FILE_PATTERNS "*.cpp *.hpp *.h *.cu *.hu")
endif()
if(BUILD_WRAPPER_MATLAB)
string(CONCAT DOXYGEN_FILE_PATTERNS ${DOXYGEN_FILE_PATTERNS} " Faust.m FaustMulMode.m StoppingCriterion.m ConstraintGeneric.m ConstraintMat.m ConstraintReal.m ConstraintInt.m ConstraintName.m ParamsFact.m ParamsHierarchical.m ParamsPalm4MSA.m FaustFactory.m hadamard.m quickstart.m fft.m bsl.m runtimecmp.m runall.m version.m faust_fact.m ParamsHierarchicalSquareMat.m ParamsHierarchicalRectMat.m license.m omp.m wht.m dft.m eye.m rand.m rand_bsr.m eigtj.m hierarchical.m fact.m palm4msa.m fgft_givens.m fgft_palm.m svdtj.m splin.m spcol.m proj_gen.m sp.m const.m supp.m hankel.m toeplitz.m circ.m normcol.m normlin.m splincol.m blockdiag.m skperm.m enable_gpu_mod.m is_gpu_mod_enabled.m isFaust.m poly.m basis.m next.m expm_multiply.m FaustPoly.m MHTPParams.m palm4msa_mhtp.m hierarchical_mhtp.m butterfly.m ParamsHierarchicalDFT.m create_bsr.m ParamsPalm4msaWHT.m proj_id.m ParamsHierarchicalNoResCons.m ParamsHierarchicalWHTNoResCons.m ParamsHierarchicalRectMatNoResCons.m circ.m anticirc.m toeplitz.m dct.m dst.m rand_butterfly.m opt_butterfly_faust.m bitrev_perm.m LazyLinearOp.m asLazyLinearOp.m isLazyLinearOp.m LazyLinearOpKron.m kron.m aslazylinearoperator.m LazyLinearOperator.m diag.m blkdiag.m sum.m ") # warning: the space on the end matters
string(CONCAT DOXYGEN_FILE_PATTERNS ${DOXYGEN_FILE_PATTERNS} " Faust.m FaustMulMode.m StoppingCriterion.m ConstraintGeneric.m ConstraintMat.m ConstraintReal.m ConstraintInt.m ConstraintName.m ParamsFact.m ParamsHierarchical.m ParamsPalm4MSA.m FaustFactory.m hadamard.m quickstart.m fft.m bsl.m runtimecmp.m runall.m version.m faust_fact.m ParamsHierarchicalSquareMat.m ParamsHierarchicalRectMat.m license.m omp.m wht.m dft.m eye.m rand.m rand_bsr.m eigtj.m hierarchical.m fact.m palm4msa.m fgft_givens.m fgft_palm.m svdtj.m splin.m spcol.m proj_gen.m sp.m const.m supp.m hankel.m toeplitz.m circ.m normcol.m normlin.m splincol.m blockdiag.m skperm.m enable_gpu_mod.m is_gpu_mod_enabled.m isFaust.m poly.m basis.m next.m expm_multiply.m FaustPoly.m MHTPParams.m palm4msa_mhtp.m hierarchical_mhtp.m butterfly.m ParamsHierarchicalDFT.m create_bsr.m ParamsPalm4msaWHT.m proj_id.m ParamsHierarchicalNoResCons.m ParamsHierarchicalWHTNoResCons.m ParamsHierarchicalRectMatNoResCons.m circ.m anticirc.m toeplitz.m dct.m dst.m rand_butterfly.m opt_butterfly_faust.m bitrev_perm.m LazyLinearOp.m asLazyLinearOp.m isLazyLinearOp.m LazyLinearOpKron.m kron.m aslazylinearoperator.m LazyLinearOperator.m diag.m blkdiag.m sum.m zeros.m ") # warning: the space on the end matters
endif()
if(BUILD_WRAPPER_PYTHON)
string(CONCAT DOXYGEN_FILE_PATTERNS ${DOXYGEN_FILE_PATTERNS} "__init__.py factparams.py demo.py tools.py fact.py proj.py poly.py lazylinop.py")
......
%=============================================================
%> @brief Returns a zero LazyLinearOp.
%>
%> @param shape: (1x2 real matrix) the shape of the zero LazyLinearOp.
%>
%> @b Example:
%> @code
%> >> import matfaust.lazylinop.zeros
%> >> Lz = zeros([10, 12]);
%> >> x = rand(12, 1);
%> >> Lz * x
%>
%> ans =
%>
%> 0
%> 0
%> 0
%> 0
%> 0
%> 0
%> 0
%> 0
%> 0
%> 0
%> @endcode
%>
%=============================================================
function lz = zeros(shape)
import matfaust.lazylinop.LazyLinearOp
import matfaust.lazylinop.LazyLinearOperator
if ~ ismatrix(shape) || ~ isnumeric(shape) || any(size(shape) ~= [1, 2]) || ~ isreal(shape)
error('shape is not valid 1x2 double matrix')
end
function mm = matmat_(op, shape)
ops = size(op);
if ops(1) ~= shape(2)
error('Dimensions must agree')
end
if LazyLinearOp.isLazyLinearOp(op)
mm = matfaust.lazylinop.zeros([shape(1), size(op, 2)]);
elseif numel(size(op)) == 2
mm = zeros([shape(1), size(op, 2)]);
if isreal(op)
if strcmp(class(op), 'single')
mm = single(mm);
end
else
% op is complex
mm = complex(mm);
end
else % op ndim > 2
zargs = num2cell(ops(3:end));
mm = zeros(shape(1), ops(2), zargs{:});
end
end
lz = LazyLinearOperator(shape, 'matmat', @(x) matmat_(x, shape), 'rmatmat', ...
@(x) matmat_(x, [shape(2), shape(1)]));
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment