Mentions légales du service

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

Add support for 'pos' and 'normalized' to skperm projector and update the API documentation.

parent 65486539
No related branches found
No related tags found
No related merge requests found
Pipeline #833979 skipped
......@@ -7,7 +7,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 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 ")
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 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 ") # 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")
......
......@@ -520,7 +520,7 @@ EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS = *faust_MatDense_gpu.h *faust_MatSparse_gpu.h expfiltered*
EXCLUDE_SYMBOLS = mtimes_trans subsasgn get_factor_nonopt reshape ABC ParamsPalm4MSAFGFT UpdateCholesky UpdateCholeskyFull UpdateCholeskySparse greed_omp_chol hierarchical_constends palm4msa_constends ConstraintGeneric ConstraintMat ConstraintReal ConstraintName ConstraintInt is_mat_consistent init_facts stop_crit ParamsPalm4MSAFGFT data_num_cols data_num_rows is_fact_side_left stop_crits constant_step_size constraints DISABLED_OPT EXTERNAL_OPT grad_calc_opt_mode init_lambda INTERNAL_OPT is_update_way_R2L is_verbose num_facts step_size IDX_IS_FACT_SIDE_LEFT OPT_ARG_NAMES2 OPT_ARG_NAMES DEFAULT_OPT IDX_USE_CSR IDX_NORM2_MAX_ITER IDX_NORM2_THRESHOLD IDX_GRAD_CALC_OPT_MODE IDX_VERBOSITY IDX_CONSTANT_STEP_SIZE IDX_STEP_SIZE IDX_INIT_LAMBDA IDX_IS_UPDATE_WAY_R2L
EXCLUDE_SYMBOLS = mtimes_trans subsasgn get_factor_nonopt reshape ABC ParamsPalm4MSAFGFT UpdateCholesky UpdateCholeskyFull UpdateCholeskySparse greed_omp_chol hierarchical_constends palm4msa_constends ConstraintGeneric ConstraintMat ConstraintReal ConstraintName ConstraintInt is_mat_consistent init_facts stop_crit ParamsPalm4MSAFGFT data_num_cols data_num_rows is_fact_side_left stop_crits constant_step_size constraints DISABLED_OPT EXTERNAL_OPT grad_calc_opt_mode init_lambda INTERNAL_OPT is_update_way_R2L is_verbose num_facts step_size IDX_IS_FACT_SIDE_LEFT OPT_ARG_NAMES2 OPT_ARG_NAMES DEFAULT_OPT IDX_USE_CSR IDX_NORM2_MAX_ITER IDX_NORM2_THRESHOLD IDX_GRAD_CALC_OPT_MODE IDX_VERBOSITY IDX_CONSTANT_STEP_SIZE IDX_STEP_SIZE IDX_INIT_LAMBDA IDX_IS_UPDATE_WAY_R2L set_FM_mul_mode set_Fv_mul_mode
# The EXAMPLE_PATH tag can be used to specify one or more files or
# directories that contain example code fragments that are included (see
......
......@@ -504,6 +504,8 @@ template<typename FPP> void Faust::prox_circ(Faust::MatDense<FPP, Cpu> & M, cons
template<typename FPP>
void Faust::prox_skperm(Faust::MatDense<FPP, Cpu> & M_, const unsigned int k, const bool normalized /* default to true*/, const bool pos/* default to false */)
{
if(pos) Faust::pre_prox_pos(M_);
// template<typename FPP> using DenseMat = Eigen::Matrix<FPP, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
// using DenseMatInt = Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
// use preproc constants instead of nice C++ template aliases because they are only used here and can't be local to a function
......@@ -671,5 +673,6 @@ void Faust::prox_skperm(Faust::MatDense<FPP, Cpu> & M_, const unsigned int k, co
}
}
M = (matching.array() > 0).select(M, 0);
if(normalized) M_.normalize();
}
#endif
......@@ -19,7 +19,7 @@ classdef skperm < matfaust.proj.proj_gen
%> @param 'normalized', false: (the default) no normalization.
%> @param 'pos', true: skips the negative values (replaced by zero) of the input matrix.
%> @param 'pos', false: (the default) negative values are not skipped.
%> @retval the skperm projector.
%> @retval proj the skperm projector.
%===============================================
function proj = skperm(shape, k, varargin)
import matfaust.factparams.ConstraintInt
......
......@@ -108,7 +108,9 @@ class hankel(proj_gen):
class sp(proj_gen):
"""
Functor for the SP projector. A, the image matrix, is such that \f$ \| A \|_0 = k, \| A\|_F = 1 \f$ (if normalized == True).
Functor for the SP projector.
A, the image matrix, is such that \f$ \| A \|_0 = k, \| A\|_F = 1 \f$ (if normalized == True).
Example:
......@@ -142,7 +144,9 @@ class sp(proj_gen):
class splin(proj_gen):
"""
Functor for the SPLIN projector. A, the image matrix, is defined by \f$
Functor for the SPLIN projector.
A, the image matrix, is defined by \f$
\forall i \in \{0,...,shape[0]-1\} \| \f$ the i-th row \f$ A_{i,*}\f$ is
such that \f$ \| A_{i,*}\|_0 = k, \| A\|_F = 1\f$ (if normalized == True).
......@@ -500,9 +504,29 @@ class skperm(proj_gen):
Functor for the SKPERM projector.
Example:
>>> from pyfaust.proj import skperm
>>> from numpy.random import rand
>>> import numpy as np
>>> from numpy import array
>>>
>>> k = 2
>>> if len(sys.argv) > 1:
>>> k = int(sys.argv[1])
>>>
>>> M = array([[-0.04440802, -0.17569296, -0.02557815, -0.15559154],
>>> [-0.0083095, -3.38725936, -0.78484126, -0.4883618 ],
>>> [-1.48942563, -1.71787215, -0.84000212, -3.71752454],
>>> [-0.88957883, -0.19107863, -5.92900636, -6.51064175]])
>>> p = skperm(M.shape, k)
>>> print(p(M))
[[-0.04440802 0. -0.02557815 0. ]
[-0.0083095 -3.38725936 0. 0. ]
[ 0. -1.71787215 0. -3.71752454]
[ 0. 0. -5.92900636 -6.51064175]]
"""
def __init__(self, shape, k, normalized=False, pos=False):
"""
Projector constructor.
Args:
k: the integer sparsity (number of nonzeros) targeted per-row and
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment