Mentions légales du service

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

Handle save of complex or complex-transpose faust in Faust::MatDense::toMatIOVar().

Fix also the test of tranpose save which was testing the transpose-conjugate in place of transpose.
parent 058917e5
Branches
Tags
No related merge requests found
...@@ -597,8 +597,13 @@ if (dim1_trans_faust_loaded ~= dim2) | (dim2_trans_faust_loaded ~= dim1) ...@@ -597,8 +597,13 @@ if (dim1_trans_faust_loaded ~= dim2) | (dim2_trans_faust_loaded ~= dim1)
end end
F_dense_trans_loaded=full(F_trans_loaded); F_dense_trans_loaded=full(F_trans_loaded);
if (~isequal(F_dense_trans_loaded,F_dense')) if (~isequal(F_dense_trans_loaded,F_dense.'))
error(['save transposed : invalid faust']); disp('F_dense_trans_loaded')
F_dense_trans_loaded
disp('F_dense_trans=')
F_dense.'
disp(F_dense_trans_loaded==F_dense.')
error(['save transposed : invalid faust']);
end end
......
...@@ -689,26 +689,52 @@ t_print_file.stop(); ...@@ -689,26 +689,52 @@ t_print_file.stop();
#endif #endif
} }
template<typename FPP> template<typename FPP>
matvar_t* Faust::MatDense<FPP, Cpu>::toMatIOVar(bool transpose) const matvar_t* Faust::MatDense<FPP, Cpu>::toMatIOVar(bool transpose) const
{ {
matvar_t *var = NULL; //TODO: should be nullptr in C++11 matvar_t *var = NULL; //TODO: should be nullptr in C++11
size_t dims[2]; size_t dims[2];
int opt = typeid(mat(0,0))==typeid(complex<double>(1.0,1.0))?MAT_F_COMPLEX:0;
mat_complex_split_t z = {NULL,NULL};
//
if(transpose) if(transpose)
{ {
dims[0] = this->getNbCol(); dims[0] = this->getNbCol();
dims[1] = this->getNbRow(); dims[1] = this->getNbRow();
Eigen::Matrix<FPP, Eigen::Dynamic, Eigen::Dynamic> mat_copy(mat.transpose().eval()); if(!opt){
// mat_copy.transposeInPlace(); //undo the transposition Eigen::Matrix<FPP, Eigen::Dynamic, Eigen::Dynamic> mat_copy(mat.transpose().eval());
var = Mat_VarCreate(NULL, MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, (FPP*) mat_copy.data() /*mat.transpose().eval().data() // doesn't work so we copy above */, 0); // mat_copy.transposeInPlace(); //undoing the transposition
var = Mat_VarCreate(NULL, MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, (FPP*) mat_copy.data() /*mat.transpose().eval().data() // doesn't work so we copy above */, opt);
}
else {
Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> dst_re(mat.rows(), mat.cols());
Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> dst_im(mat.rows(), mat.cols());
dst_re = mat.real()/*.transpose()*/.template cast<double>();
dst_im = mat.imag()/*.transpose()*/.template cast<double>();
dst_re.transposeInPlace();
dst_im.transposeInPlace();
z.Re = dst_re.data();
z.Im = dst_im.data();
var = Mat_VarCreate(NULL, MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, &z /*mat.transpose().eval().data() // doesn't work so we copy above */, opt);
}
} }
else else
{ {
dims[0] = this->getNbRow(); dims[0] = this->getNbRow();
dims[1] = this->getNbCol(); dims[1] = this->getNbCol();
var = Mat_VarCreate(NULL, MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, (FPP*) mat.data(), 0); if(!opt) //we don't copy the data again, we use it directly (col-major order organized)
var = Mat_VarCreate(NULL, MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, (FPP*) mat.data(), opt);
else {
Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> dst_re(mat.rows(), mat.cols());
Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> dst_im(mat.rows(), mat.cols());
dst_re = mat.real().template cast<double>();
dst_im = mat.imag().template cast<double>();
z.Re = dst_re.data();
z.Im = dst_im.data();
var = Mat_VarCreate(NULL, MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, &z /*mat.transpose().eval().data() // doesn't work so we copy above */, opt);
}
} }
//we don't copy the data again, we use it directly (col-major order organized)
return var; return var;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment