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
af9b2a87
Commit
af9b2a87
authored
3 years ago
by
hhakim
Browse files
Options
Downloads
Patches
Plain Diff
Add template function helperCreateNumMxArray to refactor FaustVec2mxArray and FaustMat2mxArray.
parent
3b4dbdd8
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/tools/faust2Mx.h
+7
-0
7 additions, 0 deletions
wrapper/matlab/tools/faust2Mx.h
wrapper/matlab/tools/faust2Mx.hpp
+19
-20
19 additions, 20 deletions
wrapper/matlab/tools/faust2Mx.hpp
with
26 additions
and
20 deletions
wrapper/matlab/tools/faust2Mx.h
+
7
−
0
View file @
af9b2a87
...
...
@@ -148,6 +148,13 @@ template<typename FPP>
void
newMxGetData
(
FPP
*&
ptr_out
,
const
mxArray
*
mxMat
);
#endif
/**
* Creates a numeric mxArray that matches the FPP type (complex<float>/<double> or float/double).
*/
template
<
typename
FPP
>
mxArray
*
helperCreateNumMxArray
(
const
mwSize
dims
[
2
]);
#include
"faust2Mx.hpp"
#endif
This diff is collapsed.
Click to expand it.
wrapper/matlab/tools/faust2Mx.hpp
+
19
−
20
View file @
af9b2a87
...
...
@@ -135,6 +135,23 @@ void newMxGetData<std::complex<float>>(complex<float>*& ptr_out, const mxArray*
}
#endif
template
<
typename
FPP
>
mxArray
*
helperCreateNumMxArray
(
const
mwSize
dims
[
2
])
{
mxArray
*
mxMat
;
if
(
std
::
is_same
<
FPP
,
complex
<
float
>>::
value
)
mxMat
=
mxCreateNumericArray
(
2
,
dims
,
mxSINGLE_CLASS
,
mxCOMPLEX
);
else
if
(
std
::
is_same
<
FPP
,
complex
<
double
>>::
value
)
mxMat
=
mxCreateNumericArray
(
2
,
dims
,
mxDOUBLE_CLASS
,
mxCOMPLEX
);
else
if
(
std
::
is_same
<
FPP
,
float
>::
value
)
mxMat
=
mxCreateNumericArray
(
2
,
dims
,
mxSINGLE_CLASS
,
mxREAL
);
else
if
(
std
::
is_same
<
FPP
,
double
>::
value
)
mxMat
=
mxCreateNumericArray
(
2
,
dims
,
mxDOUBLE_CLASS
,
mxREAL
);
else
mexErrMsgTxt
(
"helperCreateNumMxArray: unsupported scalar type of matrix"
);
return
mxMat
;
}
template
<
typename
FPP
>
mxArray
*
FaustMat2mxArray
(
const
Faust
::
MatDense
<
std
::
complex
<
FPP
>
,
Cpu
>&
M
)
{
...
...
@@ -145,16 +162,7 @@ mxArray* FaustMat2mxArray(const Faust::MatDense<std::complex<FPP>,Cpu>& M)
const
mwSize
dims
[
2
]
=
{(
mwSize
)
row
,(
mwSize
)
col
};
if
(
typeid
(
FPP
)
==
typeid
(
float
))
{
mxMat
=
mxCreateNumericArray
(
2
,
dims
,
mxSINGLE_CLASS
,
mxCOMPLEX
);
}
else
if
(
sizeof
(
FPP
)
==
sizeof
(
double
))
{
mxMat
=
mxCreateNumericArray
(
2
,
dims
,
mxDOUBLE_CLASS
,
mxCOMPLEX
);
}
else
{
mexErrMsgTxt
(
"FaustMat2mxArray (complex) : unsupported type of float"
);
}
mxMat
=
helperCreateNumMxArray
<
complex
<
FPP
>>
(
dims
);
#ifdef MX_HAS_INTERLEAVED_COMPLEX
// TODO: refactor this code (it is used many times in this file)
...
...
@@ -184,16 +192,7 @@ mxArray* FaustVec2mxArray(const Faust::Vect<std::complex<FPP>,Cpu>& v)
const
mwSize
dims
[
2
]
=
{(
mwSize
)
row
,(
mwSize
)
col
};
if
(
typeid
(
FPP
)
==
typeid
(
float
))
{
mxMat
=
mxCreateNumericArray
(
2
,
dims
,
mxSINGLE_CLASS
,
mxCOMPLEX
);
}
else
if
(
sizeof
(
FPP
)
==
sizeof
(
double
))
{
mxMat
=
mxCreateNumericArray
(
2
,
dims
,
mxDOUBLE_CLASS
,
mxCOMPLEX
);
}
else
{
mexErrMsgTxt
(
"FaustMat2mxArray (complex) : unsupported type of float"
);
}
mxMat
=
helperCreateNumMxArray
<
FPP
>
(
dims
);
#ifdef MX_HAS_INTERLEAVED_COMPLEX
copyComplexDataToMxArray
(
v
.
getData
(),
sizeof
(
complex
<
FPP
>
)
*
row
*
col
,
mxMat
);
#else
...
...
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