Mentions légales du service

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

Add matfaust.lazylinop.zpad + doc.

parent feb4eb21
Branches
Tags
No related merge requests found
...@@ -31,7 +31,7 @@ if(BUILD_DOCUMENTATION) ...@@ -31,7 +31,7 @@ if(BUILD_DOCUMENTATION)
string(CONCAT DOXYGEN_FILE_PATTERNS "*.cpp *.hpp *.h *.cu *.hu") string(CONCAT DOXYGEN_FILE_PATTERNS "*.cpp *.hpp *.h *.cu *.hu")
endif() endif()
if(BUILD_WRAPPER_MATLAB) 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 zeros.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 zpad.m ") # warning: the space on the end matters
endif() endif()
if(BUILD_WRAPPER_PYTHON) 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") 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 LazyLinearOp of op padded with zeros on one or two dimensions.
%>
%> @param op: the array/operator to pad with zeros.
%> @param z_sizes: a cell array of vectors of two integers. The first vector defined the number of zeros to prepend and append to op on row dimension. The second vector is the same for the column dimension.
%>
%> @b Example:
%> @code
%> >> import matfaust.lazylinop.zpad
%> >> A = reshape(1:18*2, 18, 2)
%>
%> A =
%>
%> 1 19
%> 2 20
%> 3 21
%> 4 22
%> 5 23
%> 6 24
%> 7 25
%> 8 26
%> 9 27
%> 10 28
%> 11 29
%> 12 30
%> 13 31
%> 14 32
%> 15 33
%> 16 34
%> 17 35
%> 18 36
%>
%> >> lz = zpad(A, { [2, 3]; [4, 1]});
%> >> lz
%>
%> lz =
%>
%> 23x7 LazyLinearOp array with no properties.
%>
%> >> full(lz)
%>
%> ans =
%>
%> 0 0 0 0 0 0 0
%> 0 0 0 0 0 0 0
%> 0 0 0 0 1 19 0
%> 0 0 0 0 2 20 0
%> 0 0 0 0 3 21 0
%> 0 0 0 0 4 22 0
%> 0 0 0 0 5 23 0
%> 0 0 0 0 6 24 0
%> 0 0 0 0 7 25 0
%> 0 0 0 0 8 26 0
%> 0 0 0 0 9 27 0
%> 0 0 0 0 10 28 0
%> 0 0 0 0 11 29 0
%> 0 0 0 0 12 30 0
%> 0 0 0 0 13 31 0
%> 0 0 0 0 14 32 0
%> 0 0 0 0 15 33 0
%> 0 0 0 0 16 34 0
%> 0 0 0 0 17 35 0
%> 0 0 0 0 18 36 0
%> 0 0 0 0 0 0 0
%> 0 0 0 0 0 0 0
%> 0 0 0 0 0 0 0
%>
%> @endcode
%>
%=============================================================
function out = zpad(op, z_sizes)
import matfaust.lazylinop.zeros
import matfaust.lazylinop.aslazylinearoperator
import matfaust.lazylinop.LazyLinearOp
% TODO: sanitize op
if ~ iscell(z_sizes)
error('z_sizes must be a cell array')
end
z_sizes = cell2mat(z_sizes);
if numel(size(z_sizes)) > 2
error('Cannot pad zeros on more than two dimensions')
end
if ~ LazyLinearOp.isLazyLinearOp(op)
op = aslazylinearoperator(op);
end
out = op;
for i=1:size(z_sizes, 1)
bz = z_sizes(i, 1);
az = z_sizes(i, 2);
if bz > 0
if i == 1
out = vertcat(matfaust.lazylinop.zeros([bz, size(out, 2)]), out);
else
out = horzcat(matfaust.lazylinop.zeros([size(out, 1), bz]), out);
end
if az > 0
if i == 1
out = vertcat(out, matfaust.lazylinop.zeros([az, size(out, 2)]));
else
out = horzcat(out, matfaust.lazylinop.zeros([size(out, 1), az]));
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment