Mentions légales du service

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

Add matfaust.lazylinop.blkdiag with its doc.

parent c34884f1
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 ") # 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 ") # 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 the block diagonal LazyLinearOp formed of operators in varargin.
%>
%> @param varargin: cell array of operators defining the diagonal blocks.
%>
%> @retval LB the diagonal block LazyLinearOp.
%>
%> @b Example
%> @code
%> >> import matfaust.lazylinop.blkdiag
%> >> A = rand(10, 12);
%> >> B = rand(14, 18);
%> >> C = rand(14, 22);
%> >> LB = blkdiag(A, B, C)
%>
%> LB =
%>
%> 38x52 LazyLinearOp array with no properties.
%>
%> >> M = rand(size(LB, 2), 13);
%> >> LB * M;
%> @endcode
%>
%> <p>@b See @b also blkdiag matlab built-in.
%=============================================================
function LB = blkdiag(varargin)
import matfaust.lazylinop.LazyLinearOperator
% TODO: check varargin is composed of numerical arrays or compatible operators
lAx = @(A, x) A * x;
lAHx = @(A, x) A' * x;
n = length(varargin);
offsets = zeros(n, 1);
nrows = 0;
for i=2:n+1
offsets(i) = offsets(i-1) + size(varargin{i-1}, 2);
nrows = nrows + size(varargin{i-1}, 1);
end
function P = matmat(x, lmul)
P = [];
for i=1:n
A = varargin{i};
P = [P ; lmul(A, x(offsets(i)+1: offsets(i+1), :))];
end
end
LB = LazyLinearOperator([nrows, offsets(n+1)], 'matmat', @(x) matmat(x, lAx), 'rmatmat', @(x) matmat(x, lAHx));
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment