Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
faust
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
faust group
faust
Commits
224c9247
Commit
224c9247
authored
5 years ago
by
hhakim
Browse files
Options
Downloads
Patches
Plain Diff
Bind wrapper to Faust::prox_blockdiag into matfaust.proj.blockdiag class/functor.
parent
9518cbaa
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
wrapper/matlab/+matfaust/+proj/@blockdiag/blockdiag.m
+47
-0
47 additions, 0 deletions
wrapper/matlab/+matfaust/+proj/@blockdiag/blockdiag.m
wrapper/matlab/src/mexFaust.cpp.in
+45
-0
45 additions, 0 deletions
wrapper/matlab/src/mexFaust.cpp.in
with
92 additions
and
0 deletions
wrapper/matlab/+matfaust/+proj/@blockdiag/blockdiag.m
0 → 100644
+
47
−
0
View file @
224c9247
%==================================================
%> Functor for the BLOCKDIAG projector.
%==================================================
classdef
blockdiag
%< matfaust.proj.proj_gen
properties
m_vec
n_vec
normalized
pos
end
methods
function
proj
=
blockdiag
(
shape
,
mn_cell
,
varargin
)
M
=
zeros
(
shape
(
1
),
shape
(
2
));
m_vec
=
zeros
(
1
,
length
(
mn_cell
));
n_vec
=
zeros
(
1
,
length
(
mn_cell
));
for
i
=
1
:
length
(
mn_cell
)
m_vec
(
i
)
=
mn_cell
{
i
}{
1
};
n_vec
(
i
)
=
mn_cell
{
i
}{
2
};
end
proj
.
m_vec
=
m_vec
;
proj
.
n_vec
=
n_vec
;
proj
.
normalized
=
false
;
proj
.
pos
=
false
;
end
function
pM
=
subsref
(
self
,
S
)
if
(
~
strcmp
(
S
.
type
,
'()'
)
&&
~
strcmp
(
S
.
type
,
'.'
))
error
(
'Invalid use of projector functor object: only () or . are handled'
)
end
if
(
iscell
(
S
.
subs
)
&&
length
(
S
.
subs
)
>=
1
&&
ismatrix
(
S
.
subs
{
1
}))
%error('The projector must be called on a matrix')
M
=
S
.
subs
{
1
};
% pM = self.constraint.project(M);
if
(
isreal
(
M
))
pM
=
mexFaustReal
(
'prox_blockdiag'
,
M
,
self
.
m_vec
,
self
.
n_vec
,
self
.
normalized
,
self
.
pos
);
else
pM
=
mexFaustCplx
(
'prox_blockdiag'
,
M
,
self
.
m_vec
,
self
.
n_vec
,
self
.
normalized
,
self
.
pos
);
end
elseif
(
ischar
(
S
.
subs
)
&&
strcmp
(
'constraint'
,
S
.
subs
))
pM
=
self
.
constraint
;
else
error
(
'bad use of projector: must be projector(matrix) or projector.constraint.'
)
end
end
end
end
This diff is collapsed.
Click to expand it.
wrapper/matlab/src/mexFaust.cpp.in
+
45
−
0
View file @
224c9247
...
...
@@ -319,6 +319,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
case CONSTRAINT_NAME_HANKEL:
Faust::prox_hankel(mat);
break;
break;
default:
mexErrMsgTxt("Unknown constraint name/type.");
}
...
...
@@ -328,6 +329,50 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
return;
}
if(!strcmp("prox_blockdiag", cmd))
{
if(nlhs!=1)
mexErrMsgTxt("prox_blockdiag(): 1 output variable is expected.");
if(nrhs < 4)
mexErrMsgTxt("prox_blockdiag(): wrong number of arguments (must be 4)");
SCALAR* mat_data = NULL;
const mxArray* mxMat_in = prhs[1];
const mxArray* mx_m_ptr = prhs[2], *mx_n_ptr = prhs[3];
double * m_ptr = NULL, *n_ptr = NULL;
size_t nblocks;
const size_t nrows_mat = mxGetM(mxMat_in);
const size_t ncols_mat = mxGetN(mxMat_in);
mxArray2Ptr(mxMat_in, mat_data);
Faust::MatDense<SCALAR, Cpu> mat(mat_data, nrows_mat, ncols_mat);
mxArray2Ptr<double>(mx_n_ptr, n_ptr);
mxArray2Ptr<double>(mx_m_ptr, m_ptr);
std::vector<faust_unsigned_int> m_vec;
std::vector<faust_unsigned_int> n_vec;
bool normalized = (bool) mxGetScalar(prhs[2]);
bool pos = (bool) mxGetScalar(prhs[3]);
nblocks = mxGetM(mx_m_ptr);
if(nblocks == 1 && mxGetN(mx_n_ptr) > 1)
nblocks = mxGetN(mx_n_ptr);
if(mxGetM(mx_m_ptr) != nblocks && mxGetN(mx_n_ptr) != nblocks)
mexErrMsgTxt("the number of row and col offsets must agree.");
for(int i = 0; i < nblocks; i++)
{
m_vec.push_back((faust_unsigned_int)(m_ptr[i]));
n_vec.push_back((faust_unsigned_int)(n_ptr[i]));
}
// Faust::MatDense<FPP,Cpu> & M, std::vector<faust_unsigned_int> & m_vec, std::vector<faust_unsigned_int>& n_vec, const bool normalized /* default to false */, const bool pos
//
Faust::prox_blockdiag(mat, m_vec, n_vec, normalized, pos);
plhs[0] = FaustMat2mxArray(mat);
return;
}
// New
if (!strcmp("new", cmd))
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment