Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 69315a05 authored by hhakim's avatar hhakim
Browse files

Refactor matio module.

- Removing empty cpp files.
- Removing 'using namespace' instructions in headers.
- Putting functions in Faust namespace.
parent cb5f4912
Branches
Tags
No related merge requests found
Showing with 1128 additions and 1364 deletions
......@@ -46,97 +46,98 @@
using namespace std;
matvar_t* faust_matio_read_variable(const char* fileName, const char* variableName)
{
mat_t* matfp = Mat_Open(fileName,MAT_ACC_RDONLY);
if(matfp == NULL)
{
cerr << "error in faust_matio_read_variable : unable to open "<< fileName << endl;
exit(EXIT_FAILURE);
}
matvar_t* matvar = Mat_VarRead(matfp, variableName);
if(matvar == NULL)
{
cerr << "error in faust_matio_read_variable : unable to read "<< variableName <<" from "<< fileName << endl;
exit(EXIT_FAILURE);
}
Mat_Close(matfp);
return matvar;
}
double init_double_from_matio(const char* fileName, const char* variableName)
{
matvar_t* matvar = faust_matio_read_variable(fileName, variableName);
if( matvar->class_type != MAT_C_DOUBLE
|| matvar->rank != 2
|| matvar->dims[0] != 1
|| matvar->dims[1] != 1)
{
cerr << "error in init_T_from_matio : "<< variableName << " seems not to be a scalar." << endl;
exit(EXIT_FAILURE);
}
double val = ((double*)(matvar->data))[0];
Mat_VarFree(matvar);
return val;
}
namespace Faust {
matvar_t* faust_matio_read_variable(const char* fileName, const char* variableName)
{
mat_t* matfp = Mat_Open(fileName,MAT_ACC_RDONLY);
if(matfp == NULL)
{
cerr << "error in faust_matio_read_variable : unable to open "<< fileName << endl;
exit(EXIT_FAILURE);
}
matvar_t* matvar = Mat_VarRead(matfp, variableName);
if(matvar == NULL)
{
cerr << "error in faust_matio_read_variable : unable to read "<< variableName <<" from "<< fileName << endl;
exit(EXIT_FAILURE);
}
Mat_Close(matfp);
return matvar;
}
double init_double_from_matio(const char* fileName, const char* variableName)
{
matvar_t* matvar = faust_matio_read_variable(fileName, variableName);
if( matvar->class_type != MAT_C_DOUBLE
|| matvar->rank != 2
|| matvar->dims[0] != 1
|| matvar->dims[1] != 1)
{
cerr << "error in init_T_from_matio : "<< variableName << " seems not to be a scalar." << endl;
exit(EXIT_FAILURE);
}
double val = ((double*)(matvar->data))[0];
Mat_VarFree(matvar);
return val;
}
int init_int_from_matio(const char* fileName, const char* variableName)
{
double val_d = init_double_from_matio(fileName, variableName);
int val_i = (int) val_d;
if ((double)val_i != val_d)
{
cerr<<"error in init_int_from_matio : "<< variableName << " seems not to be an integer." <<endl;
exit(EXIT_FAILURE);
}
return val_i;
}
bool init_bool_from_matio(const char* fileName, const char* variableName)
{
matvar_t* matvar = faust_matio_read_variable(fileName, variableName);
if( (matvar->class_type != MAT_C_DOUBLE && matvar->class_type != MAT_C_UINT8)
|| matvar->rank != 2
|| matvar->dims[0] != 1
|| matvar->dims[1] != 1)
{
cerr << "error in init_bool_from_matio : "<< variableName << " seems not to be a scalar." << endl;
exit(EXIT_FAILURE);
}
double val;
if (matvar->data_type == MAT_T_UINT8)
val = ((uint8_t*)(matvar->data))[0];
else if (matvar->data_type == MAT_T_DOUBLE)
val = ((double*)(matvar->data))[0];
else
{
cerr << "error in init_bool_from_matio : "<< variableName << " wrong data type." << endl;
exit(EXIT_FAILURE);
}
Mat_VarFree(matvar);
if (val==0.0)
return false;
else if (val == 1)
return true;
else
{
cerr<<"error in init_bool_from_matio : "<< variableName << " seems not to be a boolean." <<endl;
exit(EXIT_FAILURE);
}
}
int init_int_from_matio(const char* fileName, const char* variableName)
{
double val_d = init_double_from_matio(fileName, variableName);
int val_i = (int) val_d;
if ((double)val_i != val_d)
{
cerr<<"error in init_int_from_matio : "<< variableName << " seems not to be an integer." <<endl;
exit(EXIT_FAILURE);
}
return val_i;
}
bool init_bool_from_matio(const char* fileName, const char* variableName)
{
matvar_t* matvar = faust_matio_read_variable(fileName, variableName);
if( (matvar->class_type != MAT_C_DOUBLE && matvar->class_type != MAT_C_UINT8)
|| matvar->rank != 2
|| matvar->dims[0] != 1
|| matvar->dims[1] != 1)
{
cerr << "error in init_bool_from_matio : "<< variableName << " seems not to be a scalar." << endl;
exit(EXIT_FAILURE);
}
double val;
if (matvar->data_type == MAT_T_UINT8)
val = ((uint8_t*)(matvar->data))[0];
else if (matvar->data_type == MAT_T_DOUBLE)
val = ((double*)(matvar->data))[0];
else
{
cerr << "error in init_bool_from_matio : "<< variableName << " wrong data type." << endl;
exit(EXIT_FAILURE);
}
Mat_VarFree(matvar);
if (val==0.0)
return false;
else if (val == 1)
return true;
else
{
cerr<<"error in init_bool_from_matio : "<< variableName << " seems not to be a boolean." <<endl;
exit(EXIT_FAILURE);
}
}
......@@ -44,11 +44,13 @@
#include "matio.h"
matvar_t* faust_matio_read_variable(const char* fileName, const char* variableName);
double init_double_from_matio(const char* fileName, const char* variableName);
int init_int_from_matio(const char* fileName, const char* variableName);
bool init_bool_from_matio(const char* fileName, const char* variableName);
namespace Faust
{
matvar_t* faust_matio_read_variable(const char* fileName, const char* variableName);
double init_double_from_matio(const char* fileName, const char* variableName);
int init_int_from_matio(const char* fileName, const char* variableName);
bool init_bool_from_matio(const char* fileName, const char* variableName);
}
#endif
/****************************************************************************/
/* Description: */
/* For more information on the FAuST Project, please visit the website */
/* of the project : <http://faust.inria.fr> */
/* */
/* License: */
/* Copyright (2016): 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 */
/* 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> */
/****************************************************************************/
// #include "faust_init_from_matio_core.h"
// #include "faust_init_from_matio_mat.h"
// #include "faust_MatDense.h"
// #include "faust_MatSparse.h"
// #include "faust_Transform.h"
// #include "faust_constant.h"
// #include <iostream>
// #include <vector>
// #include "faust_Params.h"
// #include "faust_ParamsPalm.h"
// #include "faust_StoppingCriterion.h"
// #include "faust_ConstraintInt.h"
// #include "faust_ConstraintGeneric.h"
// #include "faust_ConstraintFPP.h"
// #include "faust_ConstraintMat.h"
// using namespace std;
// void init_faust_core_from_matiofile(Faust::Transform& core, const char* fileName, const char* variableName)
// {
// matvar_t* cell_var = faust_matio_read_variable(fileName, variableName);
// init_faust_core_from_matvar(core, cell_var);
// Mat_VarFree(cell_var);
// }
// void init_faust_core_from_matvar(Faust::Transform& core, matvar_t* cell_var )
// {
// if(cell_var->class_type != MAT_C_CELL
// || cell_var->rank != 2
// || cell_var->data_size != sizeof(double))
// {
// cout << "Error in init_faust_core_from_matiofile : filename seems not to be a cell" << endl;
// exit(EXIT_FAILURE);
// }
// matvar_t* current_spmat_var;
// Faust::MatSparse data_spmat;
// core.clear();
// if(cell_var->dims[0] != 1 )
// {
// cout << "Error in init_faust_core_from_matiofile : filename seems not to be a row vector" << endl;
// exit(EXIT_FAILURE);
// }
// for (int j=0 ; j<cell_var->dims[1] ; j++)
// {
// current_spmat_var = Mat_VarGetCell(cell_var, j);
// init_spmat_from_matvar(data_spmat, current_spmat_var);
// core.push_back(data_spmat);
// }
// }
// void init_faust_data_from_matiofile(vector<Faust::MatDense>& full_mat, vector<Faust::Transform>& core, const char* fileName, const char* variableName)
// {
// matvar_t* cell_array_var = faust_matio_read_variable(fileName, variableName);
// if(cell_array_var->class_type != MAT_C_CELL
// || cell_array_var->rank != 2
// || cell_array_var->data_size != sizeof(double))
// {
// cout << "Error in init_faust_data_from_matiofile : " << fileName << "seems not to be a cell" << endl;
// exit(EXIT_FAILURE);
// }
// matvar_t* current_cell_var;
// matvar_t* current_mat_var;
// Faust::MatSparse data_spmat;
// core.clear();
// full_mat.clear();
// if(cell_array_var->dims[0] != 2)
// {
// cerr << "Error in init_faust_data_from_matiofile : wrong dimensions of cell aray" << endl;
// exit(EXIT_FAILURE);
// }
// //creation des matrices pleines full_mat a partir de la premiere ligne du tableau de cellules (1ere ligne de cell_array_var)
// for (int j=0 ; j<cell_array_var->dims[1] ; j++)
// {
// current_mat_var = Mat_VarGetCell(cell_array_var, j*cell_array_var->dims[0]);
// Faust::MatDense mat_tmp;
// init_mat_from_matvar(mat_tmp, current_mat_var);
// full_mat.push_back(mat_tmp);
// }
// //creation des objets Faust::Transform core a partir de la deuxieme ligne du tableau de cellules (2eme ligne de cell_array_var)
// for (int j=0 ; j<cell_array_var->dims[1] ; j++)
// {
// current_cell_var = Mat_VarGetCell(cell_array_var, j*cell_array_var->dims[0]+1);
// faust_core core_tmp;
// init_Faust::Transform_from_matvar(core_tmp, current_cell_var );
// core.push_back(core_tmp);
// }
// }
......@@ -46,33 +46,33 @@
#include "matio.h"
#include <vector>
// class Faust::Transform;
// class Faust::MatDense;
template<typename FPP,FDevice DEVICE> class Transform;
template<typename FPP,FDevice DEVICE> class MatDense;
namespace Faust {
template<typename FPP,FDevice DEVICE> class Transform;
template<typename FPP,FDevice DEVICE> class MatDense;
template<typename FPP,FDevice DEVICE>
void init_faust_core_from_matiofile(Faust::Transform<FPP,DEVICE>& core, const char* fileName, const char* variableName);
template<typename FPP,FDevice DEVICE>
void init_faust_core_from_matvar(Faust::Transform<FPP,DEVICE>& core, matvar_t* cell_var );
template<typename FPP,FDevice DEVICE>
void init_faust_data_from_matiofile(std::vector<Faust::MatDense<FPP,DEVICE> >& full_mat, std::vector<Faust::Transform<FPP,DEVICE> >& core, const char* fileName, const char* variableName);
template<typename FPP,FDevice DEVICE>
void init_faust_core_from_matiofile(Faust::Transform<FPP,DEVICE>& core, const char* fileName, const char* variableName);
template<typename FPP,FDevice DEVICE>
void init_faust_core_from_matvar(Faust::Transform<FPP,DEVICE>& core, matvar_t* cell_var );
template<typename FPP,FDevice DEVICE>
void init_faust_data_from_matiofile(std::vector<Faust::MatDense<FPP,DEVICE> >& full_mat, std::vector<Faust::Transform<FPP,DEVICE> >& core, const char* fileName, const char* variableName);
#ifdef COMPILE_GPU
template<typename FPP>
void write_faust_core_into_matfile(const Faust::Transform<FPP,Gpu> core, const char* fileName, const char* variableName);
template<typename FPP>
void write_faust_core_into_matfile(const Faust::Transform<FPP,Gpu> core, const char* fileName, const char* variableName);
#endif
//template<typename FPP,FDevice DEVICE>
//void write_faust_spmat_list_into_matfile(const faust_spmat<FPP,DEVICE>& M, const char* fileName, const char* variableName);
//template<typename FPP,FDevice DEVICE>
//void write_faust_spmat_list_into_matfile(const faust_spmat<FPP,DEVICE>& M, const char* fileName, const char* variableName);
template<typename FPP>
void write_faust_core_into_matfile(const Faust::Transform<FPP,Cpu> core, const char* fileName, const char* variableName);
template<typename FPP>
void write_faust_core_into_matfile(const Faust::Transform<FPP,Cpu> core, const char* fileName, const char* variableName);
template<typename FPP>
void write_faust_core_into_matvar(const Faust::Transform<FPP,Cpu> core, matvar_t** matvar, const char* variableName);
template<typename FPP>
void write_faust_core_into_matvar(const Faust::Transform<FPP,Cpu> core, matvar_t** matvar, const char* variableName);
}
......
......@@ -58,175 +58,170 @@
#include "faust_ConstraintFPP.h"
#include "faust_ConstraintMat.h"
namespase Faust {
#ifdef COMPILE_GPU
#include "faust_gpuCore2cpuCore.h"
template<typename FPP>
void write_faust_core_into_matfile(const Transform<FPP,Gpu> core, const char* fileName, const char* variableName)
{
Transform<FPP,Cpu> fcore;
faust_gpu2cpu(fcore,core);
write_faust_core_into_matfile(fcore,fileName,variableName);
}
#endif
template<typename FPP,FDevice DEVICE>
void init_faust_core_from_matiofile(Transform<FPP,DEVICE>& core, const char* fileName, const char* variableName)
{
matvar_t* cell_var = faust_matio_read_variable(fileName, variableName);
init_faust_core_from_matvar(core, cell_var);
#ifdef COMPILE_GPU
template<typename FPP>
void write_faust_core_into_matfile(const Faust::Transform<FPP,Gpu> core, const char* fileName, const char* variableName)
{
Faust::Transform<FPP,Cpu> fcore;
faust_gpu2cpu(fcore,core);
write_faust_core_into_matfile(fcore,fileName,variableName);
Mat_VarFree(cell_var);
}
}
#endif
template<typename FPP,FDevice DEVICE>
void init_faust_core_from_matvar(Transform<FPP,DEVICE>& core, matvar_t* cell_var )
{
if(cell_var->class_type != MAT_C_CELL
|| cell_var->rank != 2
|| cell_var->data_size != sizeof(double))
{
cout << "Error in init_faust_core_from_matiofile : filename seems not to be a cell" << endl;
exit(EXIT_FAILURE);
using namespace std;
}
template<typename FPP,FDevice DEVICE>
void init_faust_core_from_matiofile(Faust::Transform<FPP,DEVICE>& core, const char* fileName, const char* variableName)
{
matvar_t* cell_var = faust_matio_read_variable(fileName, variableName);
matvar_t* current_spmat_var;
init_faust_core_from_matvar(core, cell_var);
Mat_VarFree(cell_var);
}
MatSparse<FPP,DEVICE> data_spmat;
core.clear();
if(cell_var->dims[0] != 1 )
{
cout << "Error in init_faust_core_from_matiofile : filename seems not to be a row vector" << endl;
exit(EXIT_FAILURE);
}
for (int j=0 ; j<cell_var->dims[1] ; j++)
{
current_spmat_var = Mat_VarGetCell(cell_var, j);
init_spmat_from_matvar(data_spmat, current_spmat_var);
MatGeneric<FPP,DEVICE> * ptr_data_spmat = &data_spmat;
core.push_back(ptr_data_spmat);
}
template<typename FPP,FDevice DEVICE>
void init_faust_core_from_matvar(Faust::Transform<FPP,DEVICE>& core, matvar_t* cell_var )
{
if(cell_var->class_type != MAT_C_CELL
|| cell_var->rank != 2
|| cell_var->data_size != sizeof(double))
{
cout << "Error in init_faust_core_from_matiofile : filename seems not to be a cell" << endl;
exit(EXIT_FAILURE);
}
matvar_t* current_spmat_var;
Faust::MatSparse<FPP,DEVICE> data_spmat;
core.clear();
if(cell_var->dims[0] != 1 )
{
cout << "Error in init_faust_core_from_matiofile : filename seems not to be a row vector" << endl;
exit(EXIT_FAILURE);
}
for (int j=0 ; j<cell_var->dims[1] ; j++)
{
current_spmat_var = Mat_VarGetCell(cell_var, j);
init_spmat_from_matvar(data_spmat, current_spmat_var);
Faust::MatGeneric<FPP,DEVICE> * ptr_data_spmat = &data_spmat;
core.push_back(ptr_data_spmat);
}
}
}
template<typename FPP,FDevice DEVICE>
void init_faust_data_from_matiofile(vector<MatDense<FPP,DEVICE> >& full_mat, vector<Transform<FPP,DEVICE> >& core, const char* fileName, const char* variableName)
{
template<typename FPP,FDevice DEVICE>
void init_faust_data_from_matiofile(vector<Faust::MatDense<FPP,DEVICE> >& full_mat, vector<Faust::Transform<FPP,DEVICE> >& core, const char* fileName, const char* variableName)
{
matvar_t* cell_array_var = faust_matio_read_variable(fileName, variableName);
matvar_t* cell_array_var = faust_matio_read_variable(fileName, variableName);
if(cell_array_var->class_type != MAT_C_CELL
|| cell_array_var->rank != 2
|| cell_array_var->data_size != sizeof(double))
{
cout << "Error in init_faust_data_from_matiofile : " << fileName << "seems not to be a cell" << endl;
exit(EXIT_FAILURE);
if(cell_array_var->class_type != MAT_C_CELL
|| cell_array_var->rank != 2
|| cell_array_var->data_size != sizeof(double))
{
cout << "Error in init_faust_data_from_matiofile : " << fileName << "seems not to be a cell" << endl;
exit(EXIT_FAILURE);
}
}
matvar_t* current_cell_var;
matvar_t* current_cell_var;
matvar_t* current_mat_var;
matvar_t* current_mat_var;
MatSparse<FPP,DEVICE> data_spmat;
Faust::MatSparse<FPP,DEVICE> data_spmat;
core.clear();
full_mat.clear();
core.clear();
full_mat.clear();
if(cell_array_var->dims[0] != 2)
{
cerr << "Error in init_faust_data_from_matiofile : wrong dimensions of cell aray" << endl;
exit(EXIT_FAILURE);
}
if(cell_array_var->dims[0] != 2)
{
cerr << "Error in init_faust_data_from_matiofile : wrong dimensions of cell aray" << endl;
exit(EXIT_FAILURE);
}
// creation des matrices pleines full_mat a partir de la premiere ligne du tableau de cellules (1ere ligne de cell_array_var)
for (int j=0 ; j<cell_array_var->dims[1] ; j++)
{
current_mat_var = Mat_VarGetCell(cell_array_var, j*cell_array_var->dims[0]);
MatDense<FPP,DEVICE> mat_tmp;
init_mat_from_matvar(mat_tmp, current_mat_var);
full_mat.push_back(mat_tmp);
}
// creation des matrices pleines full_mat a partir de la premiere ligne du tableau de cellules (1ere ligne de cell_array_var)
for (int j=0 ; j<cell_array_var->dims[1] ; j++)
{
current_mat_var = Mat_VarGetCell(cell_array_var, j*cell_array_var->dims[0]);
Faust::MatDense<FPP,DEVICE> mat_tmp;
init_mat_from_matvar(mat_tmp, current_mat_var);
full_mat.push_back(mat_tmp);
}
// creation des objets Transform core a partir de la deuxieme ligne du tableau de cellules (2eme ligne de cell_array_var)
for (int j=0 ; j<cell_array_var->dims[1] ; j++)
{
current_cell_var = Mat_VarGetCell(cell_array_var, j*cell_array_var->dims[0]+1);
Transform<FPP,DEVICE> core_tmp;
init_faust_core_from_matvar(core_tmp, current_cell_var );
core.push_back(core_tmp);
}
// creation des objets Faust::Transform core a partir de la deuxieme ligne du tableau de cellules (2eme ligne de cell_array_var)
for (int j=0 ; j<cell_array_var->dims[1] ; j++)
{
current_cell_var = Mat_VarGetCell(cell_array_var, j*cell_array_var->dims[0]+1);
Faust::Transform<FPP,DEVICE> core_tmp;
init_faust_core_from_matvar(core_tmp, current_cell_var );
core.push_back(core_tmp);
}
}
}
template<typename FPP>
void write_faust_core_into_matfile(const Transform<FPP,Cpu> core, const char* fileName, const char* variableName)
{
mat_t* matfp = Mat_Open(fileName,MAT_ACC_RDWR);
matvar_t *matvar;
template<typename FPP>
void write_faust_core_into_matfile(const Faust::Transform<FPP,Cpu> core, const char* fileName, const char* variableName)
{
mat_t* matfp = Mat_Open(fileName,MAT_ACC_RDWR);
matvar_t *matvar;
if(matfp == NULL)
{
matfp = Mat_CreateVer(fileName,NULL,MAT_FT_DEFAULT);
if ( NULL == matfp ) {
cerr << "error in write_faust_mat<FPP,DEVICE>_into_matfile : unable to create "<< fileName << endl;
exit(EXIT_FAILURE);
}
}
if(matfp == NULL)
{
matfp = Mat_CreateVer(fileName,NULL,MAT_FT_DEFAULT);
if ( NULL == matfp ) {
cerr << "error in write_faust_mat<FPP,DEVICE>_into_matfile : unable to create "<< fileName << endl;
exit(EXIT_FAILURE);
}
}
while ( (matvar = Mat_VarReadNextInfo(matfp)) != NULL ) {
if (strcmp(matvar->name,variableName) == 0)
{
Mat_VarDelete(matfp,matvar->name);
}
matvar = NULL;
}
while ( (matvar = Mat_VarReadNextInfo(matfp)) != NULL ) {
if (strcmp(matvar->name,variableName) == 0)
{
Mat_VarDelete(matfp,matvar->name);
}
matvar = NULL;
}
write_faust_core_into_matvar(core,&matvar,variableName);
Mat_VarWrite(matfp,matvar,MAT_COMPRESSION_NONE);
write_faust_core_into_matvar(core,&matvar,variableName);
Mat_VarWrite(matfp,matvar,MAT_COMPRESSION_NONE);
Mat_VarFree(matvar);
Mat_VarFree(matvar);
Mat_Close(matfp);
Mat_Close(matfp);
}
}
template<typename FPP>
void write_faust_core_into_matvar(const Transform<FPP,Cpu> core, matvar_t** matvar, const char* variableName)
{
template<typename FPP>
void write_faust_core_into_matvar(const Faust::Transform<FPP,Cpu> core, matvar_t** matvar, const char* variableName)
{
// TODO : not compatible with faust mat generic
cerr << "error in write_faust_core_into_matvar(...) : TODO NOT COMPATIBLE with Faust_Transform since they used MatGeneric as factor "<< endl;
exit(EXIT_FAILURE);
std::vector<Faust::MatSparse<FPP,Cpu> > sparse_facts;
//core.get_facts(sparse_facts);
write_faust_spmat_list_into_matvar(sparse_facts,matvar,variableName);
// TODO : not compatible with faust mat generic
cerr << "error in write_faust_core_into_matvar(...) : TODO NOT COMPATIBLE with Faust_Transform since they used MatGeneric as factor "<< endl;
exit(EXIT_FAILURE);
std::vector<MatSparse<FPP,Cpu> > sparse_facts;
//core.get_facts(sparse_facts);
write_faust_spmat_list_into_matvar(sparse_facts,matvar,variableName);
}
}
#endif
/****************************************************************************/
/* Description: */
/* For more information on the FAuST Project, please visit the website */
/* of the project : <http://faust.inria.fr> */
/* */
/* License: */
/* Copyright (2016): 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 */
/* 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> */
/****************************************************************************/
......@@ -50,44 +50,46 @@
#include "faust_MatDense.h"
#include "faust_MatSparse.h"
template<typename FPP,FDevice DEVICE> class MatSparse;
template<typename FPP,FDevice DEVICE> class MatDense;
namespace Faust {
template<typename FPP,FDevice DEVICE> class MatSparse;
template<typename FPP,FDevice DEVICE> class MatDense;
template<typename FPP,FDevice DEVICE>
void init_faust_mat_from_matio(Faust::MatDense<FPP,DEVICE>& M, const char* fileName, const char* variableName);
template<typename FPP,FDevice DEVICE>
void init_faust_mat_from_matio(MatDense<FPP,DEVICE>& M, const char* fileName, const char* variableName);
template<typename FPP,FDevice DEVICE>
void init_faust_spmat_from_matio(Faust::MatSparse<FPP,DEVICE>& S, const char* fileName, const char* variableName);
template<typename FPP,FDevice DEVICE>
void write_faust_mat_list_into_matfile(const std::vector< Faust::MatDense<FPP,DEVICE> >& M, const char* fileName, const char* variableName);
template<typename FPP,FDevice DEVICE>
void init_faust_mat_vector_from_matiofile( std::vector<Faust::MatDense<FPP,DEVICE> > & vec_M, const char* fileName, const char* variableName);
template<typename FPP,FDevice DEVICE>
void init_mat_from_matvar(Faust::MatDense<FPP,DEVICE> & M,matvar_t** var);
template<typename FPP,FDevice DEVICE>
void init_spmat_from_matvar(Faust::MatSparse<FPP,DEVICE> & M,matvar_t* var);
template<typename FPP,FDevice DEVICE>
void init_faust_spmat_from_matio(MatSparse<FPP,DEVICE>& S, const char* fileName, const char* variableName);
template<typename FPP,FDevice DEVICE>
void write_faust_mat_list_into_matfile(const std::vector< MatDense<FPP,DEVICE> >& M, const char* fileName, const char* variableName);
template<typename FPP,FDevice DEVICE>
void init_faust_mat_vector_from_matiofile( std::vector<MatDense<FPP,DEVICE> > & vec_M, const char* fileName, const char* variableName);
template<typename FPP,FDevice DEVICE>
void init_mat_from_matvar(MatDense<FPP,DEVICE> & M,matvar_t** var);
template<typename FPP,FDevice DEVICE>
void init_spmat_from_matvar(MatSparse<FPP,DEVICE> & M,matvar_t* var);
template<typename FPP,FDevice DEVICE>
void write_faust_mat_list_into_matvar(const std::vector<Faust::MatDense<FPP,DEVICE> >& M,matvar_t** matvar, const char* variableName);
template<typename FPP,FDevice DEVICE>
void write_faust_mat_list_into_matvar(const std::vector<MatDense<FPP,DEVICE> >& M,matvar_t** matvar, const char* variableName);
//passer l adresse du pointeur en parametre, pas un pointeur de pointeur pour matvar_t** matvar
template<typename FPP,FDevice DEVICE>
void write_faust_mat_into_matvar(const Faust::MatDense<FPP,DEVICE>& M,matvar_t** matvar, const char* variableName);
template<typename FPP,FDevice DEVICE>
void write_faust_mat_into_matfile(const Faust::MatDense<FPP,DEVICE>& M, const char* fileName, const char* variableName);
//passer l adresse du pointeur en parametre, pas un pointeur de pointeur pour matvar_t** matvar
template<typename FPP,FDevice DEVICE>
void write_faust_mat_into_matvar(const MatDense<FPP,DEVICE>& M,matvar_t** matvar, const char* variableName);
template<typename FPP,FDevice DEVICE>
void write_faust_mat_into_matfile(const MatDense<FPP,DEVICE>& M, const char* fileName, const char* variableName);
/// A MODIFIER : pour l instant les matrices creuse sont stockés en matrices dense dans matlab
template<typename FPP,FDevice DEVICE>
void write_faust_spmat_list_into_matfile(const Faust::MatSparse<FPP,DEVICE>& M, const char* fileName, const char* variableName);
template<typename FPP,FDevice DEVICE>
void write_faust_spmat_list_into_matvar(const std::vector<Faust::MatSparse<FPP,DEVICE> >& M,matvar_t** matvar, const char* variableName);
/// A MODIFIER : pour l instant les matrices creuse sont stockés en matrices dense dans matlab
template<typename FPP,FDevice DEVICE>
void write_faust_spmat_list_into_matfile(const MatSparse<FPP,DEVICE>& M, const char* fileName, const char* variableName);
template<typename FPP,FDevice DEVICE>
void write_faust_spmat_list_into_matvar(const std::vector<MatSparse<FPP,DEVICE> >& M,matvar_t** matvar, const char* variableName);
}
......
This diff is collapsed.
/****************************************************************************/
/* Description: */
/* For more information on the FAuST Project, please visit the website */
/* of the project : <http://faust.inria.fr> */
/* */
/* License: */
/* Copyright (2016): 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 */
/* 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> */
/****************************************************************************/
#include "faust_init_from_matio_params.h"
//template void add_constraint<double>(std::vector<const Faust::ConstraintGeneric*> & consS,matvar_t* cons_var);
//template void add_constraint<float>(std::vector<const Faust::ConstraintGeneric*> & consS,matvar_t* cons_var);
......@@ -50,26 +50,29 @@
template<typename FPP,FDevice DEVICE> class ParamsPalm;
template<typename FPP,FDevice DEVICE> class Params;
template<typename FPP,FDevice DEVICE> class ConstraintGeneric;
namespace Faust {
template<typename FPP,FDevice DEVICE>
void init_params_palm_from_matiofile(Faust::ParamsPalm<FPP,DEVICE>& params, const char* fileName, const char* variableName);
// template<typename FPP,FDevice DEVICE> class ParamsPalm;
// template<typename FPP,FDevice DEVICE> class Params;
// template<typename FPP,FDevice DEVICE> class ConstraintGeneric;
/** \brief load data matrix from ".mat file"
* \param params
* \param fileName
* \param variableName
*/
template<typename FPP,FDevice DEVICE, typename FPP2 = double>
void init_params_from_matiofile(Faust::Params<FPP,DEVICE,FPP2>& params, const char* fileName, const char* variableName);
template<typename FPP,FDevice DEVICE>
void init_params_palm_from_matiofile(ParamsPalm<FPP,DEVICE>& params, const char* fileName, const char* variableName);
template<typename FPP,FDevice DEVICE, typename FPP2 = double>
void add_constraint(std::vector<const Faust::ConstraintGeneric*> & consS,matvar_t* cons_var);
/** \brief load data matrix from ".mat file"
* \param params
* \param fileName
* \param variableName
*/
template<typename FPP,FDevice DEVICE, typename FPP2 = double>
void init_params_from_matiofile(Params<FPP,DEVICE,FPP2>& params, const char* fileName, const char* variableName);
template<typename FPP,FDevice DEVICE>
void Display_params(Faust::Params<FPP,DEVICE> & params);
template<typename FPP,FDevice DEVICE, typename FPP2 = double>
void add_constraint(std::vector<const ConstraintGeneric*> & consS,matvar_t* cons_var);
template<typename FPP,FDevice DEVICE>
void Display_params(Params<FPP,DEVICE> & params);
}
#include "faust_init_from_matio_params.hpp"
#endif
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment