Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 3ab0cd33 authored by hhakim's avatar hhakim
Browse files

Add matfaust.Faust.transpose/ctranspose/conj GPU2 wrappers.

parent 63ad747f
Branches
Tags
No related merge requests found
/****************************************************************************/
/* 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> */
#ifndef __MEX_FAUST_CONJ__
#define __MEX_FAUST_CONJ__
template <typename SCALAR, FDevice DEV>
void faust_conj(const mxArray **prhs, const int nrhs, mxArray **plhs, const int nlhs);
#include "faust_conj.hpp"
#endif
#include "class_handle.hpp"
#include "faust_TransformHelper.h"
template <typename SCALAR, FDevice DEV>
void faust_conj(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<SCALAR,DEV>* th = core_ptr->conjugate();
plhs[0] = convertPtr2Mat<Faust::TransformHelper<SCALAR,DEV> >(th);
#ifdef FAUST_VERBOSE
printf("new ptr for Faust conjugate's TransformHelper obj=%p\n", th);
printf("conjugate()\n");
printf("isConjugate()=%d\n",th->isConjugate());
#endif
}
/****************************************************************************/
/* 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> */
#ifndef __MEX_FAUST_CTRANSPOSE__
#define __MEX_FAUST_CTRANSPOSE__
template <typename SCALAR, FDevice DEV>
void faust_ctranspose(const mxArray **prhs, const int nrhs, mxArray **plhs, const int nlhs);
#include "faust_ctranspose.hpp"
#endif
#include "class_handle.hpp"
#include "faust_TransformHelper.h"
template <typename SCALAR, FDevice DEV>
void faust_ctranspose(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<SCALAR,DEV>* th = core_ptr->adjoint();
plhs[0] = convertPtr2Mat<Faust::TransformHelper<SCALAR,DEV> >(th);
#ifdef FAUST_VERBOSE
printf("new ptr for Faust conjugate's TransformHelper obj=%p\n", th);
printf("conjugate()\n");
printf("isConjugate()=%d\n",th->isConjugate());
printf("isTransposed()=%d\n", th->isTransposed());
#endif
}
/****************************************************************************/
/* 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> */
#ifndef __MEX_FAUST_SAVE__
#define __MEX_FAUST_SAVE__
template <typename SCALAR, FDevice DEV>
void faust_save(const mxArray **prhs, const int nrhs, mxArray **plhs, const int nlhs);
#include "faust_save.hpp"
#endif
#include "class_handle.hpp"
#include "faust_TransformHelper.h"
template <typename SCALAR, FDevice DEV>
void faust_save(const mxArray **prhs, const int nrhs, mxArray **plhs, const int nlhs)
{
Faust::TransformHelper<SCALAR,DEV>* core_ptr = convertMat2Ptr<Faust::TransformHelper<SCALAR,DEV> >(prhs[1]);
const size_t MAX_PATH_SIZE=512;
char filepath[MAX_PATH_SIZE];
// prhs[2] must be the filepath
if(nrhs != 3){
mexErrMsgTxt("The number of arguments for the save function is not valid. Must be one.");
return;
}
if(mxGetString(prhs[2], filepath, sizeof(filepath)) || strlen(filepath) == 0){
mexErrMsgTxt("The filepath is not valid.");
return;
}
// printf("save: filepath = %s, nprhs = %d\n", filepath, nprhs);
try
{
core_ptr->save_mat_file(filepath/*, mxGetScalar(prhs[1])*/);
}
catch(exception& e)
{
mexErrMsgTxt("Failed to save the file.");
}
}
/****************************************************************************/
/* 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> */
#ifndef __MEX_FAUST_TRANSPOSE__
#define __MEX_FAUST_TRANSPOSE__
template <typename SCALAR, FDevice DEV>
void faust_transpose(const mxArray **prhs, const int nrhs, mxArray **plhs, const int nlhs);
#include "faust_transpose.hpp"
#endif
#include "class_handle.hpp"
#include "faust_TransformHelper.h"
template <typename SCALAR, FDevice DEV>
void faust_transpose(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<SCALAR,DEV>* th = core_ptr->transpose();
plhs[0] = convertPtr2Mat<Faust::TransformHelper<SCALAR,DEV> >(th);
#ifdef FAUST_VERBOSE
printf("new ptr for Faust transpose's TransformHelper obj=%p\n", th);
printf("transpose()\n");
printf("isTransposed()=%d\n",th->isTransposed());
#endif
}
......@@ -76,6 +76,10 @@
#include "faust_factors.h"
#include "faust_rand.h"
#include "faust_save.h"
#include "faust_conj.h"
#include "faust_transpose.h"
#include "faust_ctranspose.h"
typedef @FAUST_SCALAR@ SCALAR;
typedef @FAUST_FPP@ FPP;
......@@ -500,18 +504,9 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
}
if(!strcmp("save", cmd))
return faust_save<FPP,Cpu>(prhs, nrhs, plhs, nlhs);
return faust_save<SCALAR,Cpu>(prhs, nrhs, plhs, nlhs);
if(!strcmp("transpose", cmd)) { //TODO: verify no arguments passed or
Faust::TransformHelper<SCALAR,Cpu>* th = core_ptr->transpose();
plhs[0] = convertPtr2Mat<Faust::TransformHelper<SCALAR,Cpu> >(th);
#ifdef FAUST_VERBOSE
printf("new ptr for Faust transpose's TransformHelper obj=%p\n", th);
printf("transpose()\n");
printf("isTransposed()=%d\n",th->isTransposed());
#endif
return;
}
if(!strcmp("optimize_storage", cmd)) { //TODO: verify no arguments passed or
if(nrhs != 3)
......@@ -565,28 +560,19 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
return;
}
if(!strcmp("conj", cmd)) { //TODO: verify no arguments passed or
Faust::TransformHelper<SCALAR,Cpu>* th = core_ptr->conjugate();
plhs[0] = convertPtr2Mat<Faust::TransformHelper<SCALAR,Cpu> >(th);
#ifdef FAUST_VERBOSE
printf("new ptr for Faust conjugate's TransformHelper obj=%p\n", th);
printf("conjugate()\n");
printf("isConjugate()=%d\n",th->isConjugate());
#endif
if(!strcmp("conj", cmd)) {
faust_conj<SCALAR,Cpu>(prhs, nrhs, plhs, nlhs);
return;
}
if(!strcmp("ctranspose", cmd)) {
Faust::TransformHelper<SCALAR,Cpu>* th = core_ptr->adjoint();
plhs[0] = convertPtr2Mat<Faust::TransformHelper<SCALAR,Cpu> >(th);
#ifdef FAUST_VERBOSE
printf("new ptr for Faust conjugate's TransformHelper obj=%p\n", th);
printf("conjugate()\n");
printf("isConjugate()=%d\n",th->isConjugate());
printf("isTransposed()=%d\n", th->isTransposed());
#endif
if(!strcmp("transpose", cmd)) {
faust_transpose<SCALAR,Cpu>(prhs, nrhs, plhs, nlhs);
return;
}
if(!strcmp("ctranspose", cmd)) {
faust_ctranspose<SCALAR,Cpu>(prhs, nrhs, plhs, nlhs);
return;
}
if(!strcmp("subsref", cmd)){
......
......@@ -76,6 +76,10 @@
#include "faust_TransformHelper_gpu.h"
#include "faust_rand.h"
#include "faust_save.h"
#include "faust_conj.h"
#include "faust_transpose.h"
#include "faust_ctranspose.h"
typedef @FAUST_SCALAR@ SCALAR;
typedef @FAUST_FPP@ FPP;
......@@ -136,6 +140,12 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
faust_factors<SCALAR, GPU2>(prhs, nrhs, plhs, nlhs);
else if (!strcmp("save", cmd))
faust_save<SCALAR, GPU2>(prhs, nrhs, plhs, nlhs);
else if(!strcmp("conj", cmd))
faust_conj<SCALAR,GPU2>(prhs, nrhs, plhs, nlhs);
else if(!strcmp("transpose", cmd))
faust_transpose<SCALAR,GPU2>(prhs, nrhs, plhs, nlhs);
else if(!strcmp("ctranspose", cmd))
faust_ctranspose<SCALAR,GPU2>(prhs, nrhs, plhs, nlhs);
}
catch (const std::exception& e)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment