Mentions légales du service

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

Fix reference return issue in MatSparse::operator().

The function prototype is imposed by the MatGeneric parent which was in its turn imposed by MatDense first function to move up in hierarchy, so we have to return a ref without having access to the buffer directly (fortunately Eigen provides the function coeffRef for that).
parent 9aa63c31
Branches
Tags
No related merge requests found
#include "faust_MatSparse.h"
#include <iostream>
/** \brief unitary test for MatDense conjugate
*/
typedef @TEST_FPP@ FPP;
using namespace Faust;
using namespace std;
int main(int argc, char* argv[])
{
faust_unsigned_int dim1 = 3;
faust_unsigned_int dim2 = 3;
MatDense<FPP,Cpu>* M1;
Faust::MatSparse<FPP,Cpu> M_sp1;
M1 = Faust::MatDense<FPP,Cpu>::randMat(dim1,dim2);
M_sp1 = *M1;
cout << "M_sp1:" << endl;
M_sp1.Display();
cout<<"M1:"<<endl;
M1->Display();
for(int i = 0; i < M1->getNbRow(); i++)
for(int j = 0; j < M1->getNbCol(); j++)
{
assert(M_sp1(i,j) == (*M1)(i,j));
}
return 0;
}
......@@ -295,6 +295,7 @@ namespace Faust
matvar_t* toMatIOVarDense(bool transpose, bool conjugate) const;
FPP normL1(const bool transpose=false) const;
FPP normL1(faust_unsigned_int&, const bool transpose=false) const;
const FPP& operator()(faust_unsigned_int i, faust_unsigned_int j)const{return const_cast<Eigen::SparseMatrix<FPP,Eigen::RowMajor>*>(&mat)->coeffRef(i,j);}
Faust::Vect<FPP,Cpu> get_col(faust_unsigned_int id) const;
Faust::MatSparse<FPP,Cpu>* get_cols(faust_unsigned_int col_id_start, faust_unsigned_int num_cols) const;
Faust::MatSparse<FPP,Cpu>* get_cols(faust_unsigned_int* col_ids, faust_unsigned_int num_cols) const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment