Mentions légales du service

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

Fix a bug in matfaust.Faust.get_factor() happening when the Faust is conjugate(-transpose).

It closes issue #16.
parent 2a4207e2
Branches
Tags
No related merge requests found
...@@ -726,6 +726,7 @@ end ...@@ -726,6 +726,7 @@ end
for i=1:nb_fact for i=1:nb_fact
A=get_factor(F_conj,i); A=get_factor(F_conj,i);
if(~isequal(A,conj(factors{i}))) if(~isequal(A,conj(factors{i})))
conj(factors{i})
get_factor(F_conj,i) get_factor(F_conj,i)
error('get_fact : invalid factor'); error('get_fact : invalid factor');
end end
...@@ -766,6 +767,7 @@ end ...@@ -766,6 +767,7 @@ end
for i=1:nb_fact for i=1:nb_fact
A=get_factor(F_ctranspose,i) A=get_factor(F_ctranspose,i)
if(~isequal(A,ctranspose(factors{nb_fact-i+1}))) if(~isequal(A,ctranspose(factors{nb_fact-i+1})))
ctranspose(factors{nb_fact-i+1})
get_factor(F_ctranspose,i) get_factor(F_ctranspose,i)
error('get_fact : invalid factor'); error('get_fact : invalid factor');
end end
......
...@@ -6,7 +6,7 @@ namespace Faust { ...@@ -6,7 +6,7 @@ namespace Faust {
void conjugate(complex<FPP>* elts, faust_unsigned_int n) void conjugate(complex<FPP>* elts, faust_unsigned_int n)
{ {
for(faust_unsigned_int i=0; i< n; i++) for(faust_unsigned_int i=0; i< n; i++)
elts[i] = complex<FPP>(elts[i].real(), elts[i].imag()); elts[i] = complex<FPP>(elts[i].real(), - elts[i].imag());
} }
template<typename FPP> template<typename FPP>
......
...@@ -383,7 +383,7 @@ mxArray* transformFact2FullMxArray(faust_unsigned_int id, Faust::TransformHelper ...@@ -383,7 +383,7 @@ mxArray* transformFact2FullMxArray(faust_unsigned_int id, Faust::TransformHelper
// cause it needs to be reordered // cause it needs to be reordered
complex<FPP>* src_data_ptr = (complex<FPP>*) malloc(sizeof(complex<FPP>)*dim_sizes[0]*dim_sizes[1]); // TODO: alloc-free in c++ style (new/delete) complex<FPP>* src_data_ptr = (complex<FPP>*) malloc(sizeof(complex<FPP>)*dim_sizes[0]*dim_sizes[1]); // TODO: alloc-free in c++ style (new/delete)
core_ptr->get_fact(id, src_data_ptr, &num_rows, &num_cols); core_ptr->get_fact(id, src_data_ptr, &num_rows, &num_cols);
splitComplexPtr(src_data_ptr, num_cols*num_rows, data_ptr, img_data_ptr, core_ptr->isConjugate()); splitComplexPtr(src_data_ptr, num_cols*num_rows, data_ptr, img_data_ptr/*, core_ptr->isConjugate()*/); //let conjugate to false because it's handled internally by get_fact()
free(src_data_ptr); free(src_data_ptr);
// it's different to real transformFact2FullMxArray() case here // it's different to real transformFact2FullMxArray() case here
// because with complex we need to split im/real (until we stop to use separated complex API) // because with complex we need to split im/real (until we stop to use separated complex API)
...@@ -395,7 +395,8 @@ mxArray* transformFact2FullMxArray(faust_unsigned_int id, Faust::TransformHelper ...@@ -395,7 +395,8 @@ mxArray* transformFact2FullMxArray(faust_unsigned_int id, Faust::TransformHelper
const complex<FPP>* src_data_ptr; const complex<FPP>* src_data_ptr;
//not calling the same prototype of get_fact() called in transpose case (and real version of this function) //not calling the same prototype of get_fact() called in transpose case (and real version of this function)
core_ptr->get_fact(id, &src_data_ptr, &num_rows, &num_cols); core_ptr->get_fact(id, &src_data_ptr, &num_rows, &num_cols);
splitComplexPtr(src_data_ptr, num_rows*num_cols, data_ptr, img_data_ptr, core_ptr->isConjugate()); splitComplexPtr(src_data_ptr, num_rows*num_cols, data_ptr, img_data_ptr, core_ptr->isConjugate());//let conjugate to false because it's handled internally by get_fact()
} }
//TODO: matlab 2018 setComplexDoubles()/setComplexSingles() to avoid separating //TODO: matlab 2018 setComplexDoubles()/setComplexSingles() to avoid separating
// in real and imaginary part to copy, directly copy into mxArray with get_fact() in the pointer returned by mxComplexSingles()/mxComplexDoubles() // in real and imaginary part to copy, directly copy into mxArray with get_fact() in the pointer returned by mxComplexSingles()/mxComplexDoubles()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment