Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 1d2cd5b2 authored by hhakim's avatar hhakim
Browse files

Document and implement matfaust.Faust.double wrapper with its mex C++ code.

Issue #257
parent bf54d2e8
No related branches found
No related tags found
No related merge requests found
...@@ -1024,6 +1024,49 @@ classdef Faust ...@@ -1024,6 +1024,49 @@ classdef Faust
% 2nd argument (true) is for is_real attribute % 2nd argument (true) is for is_real attribute
end end
%======================================================================
%> @brief Returns a new Faust whose class is double. It allows to convert all the factors to double precision.
%>
%>
%> @b Usage
%>
%>     @b sF = double(F)
%>
%> @retval sF the double class/precision Faust.
%>
%> @b Example:
%> @code
%> >> sF = matfaust.rand(5, 5, 'field', 'real', 'class', 'single')
%> @endcode
%> sF =
%>
%> Faust size 5x5, density 5, nnz_sum 125, 5 factor(s):
%> - FACTOR 0 (float) SPARSE, size 5x5, density 1, nnz 25
%> - FACTOR 1 (float) SPARSE, size 5x5, density 1, nnz 25
%> - FACTOR 2 (float) SPARSE, size 5x5, density 1, nnz 25
%> - FACTOR 3 (float) SPARSE, size 5x5, density 1, nnz 25
%> - FACTOR 4 (float) SPARSE, size 5x5, density 1, nnz 25
%>
%> @code
%> >> dF = single(sF)
%> @endcode
%>
%> dF =
%>
%> Faust size 5x5, density 5, nnz_sum 125, 5 factor(s):
%> - FACTOR 0 (double) SPARSE, size 5x5, density 1, nnz 25
%> - FACTOR 1 (double) SPARSE, size 5x5, density 1, nnz 25
%> - FACTOR 2 (double) SPARSE, size 5x5, density 1, nnz 25
%> - FACTOR 3 (double) SPARSE, size 5x5, density 1, nnz 25
%> - FACTOR 4 (double) SPARSE, size 5x5, density 1, nnz 25
%>
%> <p/>@b See @b also Faust.class, Faust.single
%======================================================================
function sF = double(F)
sF = matfaust.Faust(call_mex(F, 'double'), true, F.dev, 'double');
% 2nd argument (true) is for is_real attribute
end
%====================================================================== %======================================================================
%> @brief The transpose of F. %> @brief The transpose of F.
%> %>
......
/****************************************************************************/
/* Description: */
/* file where the C++ class Faust::TransformHelper is interfaced */
/* with Matlab */
/* */
/* For more information on the FAuST Project, please visit the website */
/* of the project : <http://faust.inria.fr> */
/* */
/* License: */
/* Copyright (2021): Hakim HADJ-DJILANI */
/* Nicolas Bellot, Adrien Leman, Thomas Gautrais, */
/* Luc Le Magoarou, Remi Gribonval */
/* INRIA Rennes, FRANCE */
/* http://www.inria.fr/ */
/* */
/* The FAuST Toolbox is distributed under the terms of the GNU Affero */
/* General Public License. */
/* This program is free software: you can redistribute it and/or modify */
/* it under the terms of the GNU Affero General Public License as */
/* published by the Free Software Foundation. */
/* */
/* This program is distributed in the hope that it will be useful, but */
/* WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */
/* See the GNU Affero General Public License for more details. */
/* */
/* You should have received a copy of the GNU Affero General Public */
/* License along with this program. */
/* If not, see <http://www.gnu.org/licenses/>. */
/* */
/* Contacts: */
/* Nicolas Bellot : nicolas.bellot@inria.fr */
/* Adrien Leman : adrien.leman@inria.fr */
/* Thomas Gautrais : thomas.gautrais@inria.fr */
/* Luc Le Magoarou : luc.le-magoarou@inria.fr */
/* Hakim hadj-djilani : hakim.hadj-djilani@inria.fr */
/* Remi Gribonval : remi.gribonval@inria.fr */
/* */
/* References: */
/* [1] Le Magoarou L. and Gribonval R., "Flexible multi-layer sparse */
/* approximations of matrices and applications", Journal of Selected */
/* Topics in Signal Processing, 2016. */
/* <https://hal.archives-ouvertes.fr/hal-01167948v1> */
template <typename SCALAR, FDevice DEV>
void faust_double(const mxArray **prhs, const int nrhs, mxArray **plhs, const int nlhs);
#include "faust_double.hpp"
#include "class_handle.hpp"
#include "faust_TransformHelper.h"
template <typename SCALAR, FDevice DEV>
void faust_double(const mxArray **prhs, const int nrhs, mxArray **plhs, const int nlhs)
{
Faust::TransformHelper<SCALAR,DEV>* core_ptr = convertMat2Ptr<Faust::TransformHelper<SCALAR,DEV> >(prhs[1]);
Faust::TransformHelper<double,DEV>* th = core_ptr->template real<double>();
plhs[0] = convertPtr2Mat<Faust::TransformHelper<double,DEV> >(th);
}
...@@ -99,6 +99,7 @@ ...@@ -99,6 +99,7 @@
#include "faust_mex_prox.h" #include "faust_mex_prox.h"
#include "faust_isreal.h" #include "faust_isreal.h"
#include "faust_single.h" #include "faust_single.h"
#include "faust_double.h"
#include "faust_fourier.h" #include "faust_fourier.h"
#include "faust_hadamard.h" #include "faust_hadamard.h"
#include "faust_eye.h" #include "faust_eye.h"
...@@ -164,6 +165,8 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) ...@@ -164,6 +165,8 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
faust_isreal<SCALAR,Cpu>(prhs, nrhs, plhs, nlhs); faust_isreal<SCALAR,Cpu>(prhs, nrhs, plhs, nlhs);
else if(!strcmp("single", cmd)) else if(!strcmp("single", cmd))
faust_single<SCALAR,DEV>(prhs, nrhs, plhs, nlhs); faust_single<SCALAR,DEV>(prhs, nrhs, plhs, nlhs);
else if(!strcmp("double", cmd))
faust_double<SCALAR,DEV>(prhs, nrhs, plhs, nlhs);
else if(!strcmp("nnz", cmd)) else if(!strcmp("nnz", cmd))
faust_nnz<SCALAR, DEV>(prhs, nrhs, plhs, nlhs); faust_nnz<SCALAR, DEV>(prhs, nrhs, plhs, nlhs);
else if(!strcmp("full", cmd)) else if(!strcmp("full", cmd))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment