Mentions légales du service

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

Bind to matfaust the new proxs added by 5901bfca.

parent 332dacc9
No related branches found
No related tags found
No related merge requests found
......@@ -27,11 +27,29 @@ classdef (Abstract) ConstraintGeneric
constraint.param = param;
end
function pM = project(this, M)
function pM = project(this, M, varargin)
% optional key-value arguments
argc = length(varargin);
normalized = true;
if(argc > 0)
for i=1:argc
switch(varargin{i})
case 'normalized'
if(argc == i || ~ islogical(normalized))
error('normalized keyword arg. is not followed by a boolean')
end
normalized = varargin{i+1};
otherwise
if(isstr(varargin{i}))
error([ varargin{i} ' unrecognized argument'])
end
end
end
end
if(isreal(M))
pM = mexFaustReal('prox', M, this.name.name, this.param);
pM = mexFaustReal('prox', M, this.name.name, this.param, normalized);
else
pM = mexFaustCplx('prox', M, this.name.name, this.param);
pM = mexFaustCplx('prox', M, this.name.name, this.param, normalized);
end
end
end
......
......@@ -11,6 +11,7 @@ classdef ConstraintInt < matfaust.factparams.ConstraintGeneric
if(~ isreal(param) || ~ isscalar(param))
error('ConstraintInt must receive an integer as param argument.')
end
constraint = constraint@matfaust.factparams.ConstraintGeneric(name, num_rows, num_cols, floor(param));
if(~ isa(constraint.name, 'matfaust.factparams.ConstraintName') || ~ constraint.name.is_int_constraint())
error(['ConstraintInt first argument must be a ConstraintName with a int type name ', ...
......
......@@ -234,8 +234,7 @@ void save(Faust::TransformHelper<SCALAR,Cpu>* core_ptr, int nargs, const mxArray
mxArray2Ptr(mxMat_in, mat_data);
Faust::MatDense<SCALAR, Cpu> mat(mat_data, nrows_mat, ncols_mat);
Faust::MatDense<SCALAR, Cpu>* mat_param = nullptr;
bool normalized = true;
if(is_param_scalar)
{
......@@ -248,40 +247,72 @@ void save(Faust::TransformHelper<SCALAR,Cpu>* core_ptr, int nargs, const mxArray
mat_param = new Faust::MatDense<SCALAR, Cpu>(mat_data, nrows_mat, ncols_mat);
}
switch(constraint_type)
if(nrhs > 4)
{
case CONSTRAINT_NAME_SP: /*!< fixed number of non zero elements, INT (frobenius norm 1) */
Faust::prox_sp(mat, (faust_unsigned_int) scal_param);
break;
case CONSTRAINT_NAME_SPCOL: /*!< fixed number of non zero elements per column INT (frobenius norm 1) */
Faust::prox_spcol(mat, (faust_unsigned_int) scal_param);
break;
case CONSTRAINT_NAME_SPLIN: /*!< fixed number of non zero elements per line INT (frobenius norm 1) */
Faust::prox_splin(mat, (faust_unsigned_int) scal_param);
break;
case CONSTRAINT_NAME_SPLINCOL:
Faust::prox_splincol(mat, (faust_unsigned_int) scal_param);
break;
case CONSTRAINT_NAME_SP_POS:/**< fixed number of non zeros coefficients: INT (frobenius norm 1) */
Faust::prox_sp_pos(mat, (faust_unsigned_int) scal_param);
break;
case CONSTRAINT_NAME_NORMLIN:/**< 2nd norm of the lines of matrix A ; REAL */
Faust::prox_normlin(mat, scal_param);
break;
case CONSTRAINT_NAME_NORMCOL:/*!< 2nd norm of the colons of A REAL */
Faust::prox_normcol(mat, scal_param);
break;
case CONSTRAINT_NAME_CONST: /**< Matrix equal to A ; MAT */
mat = *mat_param;
break ;
case CONSTRAINT_NAME_BLKDIAG:
//not impl. yet in cpp core
break;
case CONSTRAINT_NAME_SUPP: /**< Matrix which support is equal to A ; MAT ; (frobenius norm 1)*/
Faust::prox_supp(mat, *mat_param);
break;
normalized = (bool) mxGetScalar(prhs[4]);
}
cout << "normalized=" << normalized << endl;
if(normalized)
switch(constraint_type)
{
case CONSTRAINT_NAME_SP: /*!< fixed number of non zero elements, INT (frobenius norm 1) */
Faust::prox_sp(mat, (faust_unsigned_int) scal_param);
break;
case CONSTRAINT_NAME_SPCOL: /*!< fixed number of non zero elements per column INT (frobenius norm 1) */
Faust::prox_spcol(mat, (faust_unsigned_int) scal_param);
break;
case CONSTRAINT_NAME_SPLIN: /*!< fixed number of non zero elements per line INT (frobenius norm 1) */
Faust::prox_splin(mat, (faust_unsigned_int) scal_param);
break;
case CONSTRAINT_NAME_SPLINCOL:
Faust::prox_splincol(mat, (faust_unsigned_int) scal_param);
break;
case CONSTRAINT_NAME_SP_POS:/**< fixed number of non zeros coefficients: INT (frobenius norm 1) */
Faust::prox_sp_pos(mat, (faust_unsigned_int) scal_param);
break;
case CONSTRAINT_NAME_NORMLIN:/**< 2nd norm of the lines of matrix A ; REAL */
Faust::prox_normlin(mat, scal_param);
break;
case CONSTRAINT_NAME_NORMCOL:/*!< 2nd norm of the colons of A REAL */
Faust::prox_normcol(mat, scal_param);
break;
case CONSTRAINT_NAME_CONST: /**< Matrix equal to A ; MAT */
mat = *mat_param;
break ;
case CONSTRAINT_NAME_BLKDIAG:
//not impl. yet in cpp core
break;
case CONSTRAINT_NAME_SUPP: /**< Matrix which support is equal to A ; MAT ; (frobenius norm 1)*/
Faust::prox_supp(mat, *mat_param);
break;
}
else
switch(constraint_type)
{
case CONSTRAINT_NAME_SP: /*!< fixed number of non zero elements, INT (frobenius norm 1) */
Faust::prox_sp_normfree(mat, (faust_unsigned_int) scal_param);
break;
case CONSTRAINT_NAME_SPCOL: /*!< fixed number of non zero elements per column INT (frobenius norm 1) */
Faust::prox_spcol_normfree(mat, (faust_unsigned_int) scal_param);
break;
case CONSTRAINT_NAME_SPLIN: /*!< fixed number of non zero elements per line INT (frobenius norm 1) */
Faust::prox_splin_normfree(mat, (faust_unsigned_int) scal_param);
break;
case CONSTRAINT_NAME_SPLINCOL:
Faust::prox_splincol_normfree(mat, (faust_unsigned_int) scal_param);
break;
case CONSTRAINT_NAME_SP_POS:/**< fixed number of non zeros coefficients: INT (frobenius norm 1) */
Faust::prox_sp_pos_normfree(mat, (faust_unsigned_int) scal_param);
break;
case CONSTRAINT_NAME_SUPP: /**< Matrix which support is equal to A ; MAT ; (frobenius norm 1)*/
Faust::prox_supp_normfree(mat, *mat_param);
break;
}
plhs[0] = FaustMat2mxArray(mat);
if(mat_param != nullptr)
delete mat_param;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment