+ 2

[ANSWERED] Error in Type Comparisons and Assignments

I have a Matrix (vector of vectors) of a general type and I wished to decompose it as per Cholesky's Decomposition Method. I found that the dcomposition returns two Matrices, of which the first is calculated by some formulas and the second is the 'conjugate transpose' of the first. So my function declaration was as follows : pair<Matrix,Matrix> Decompose(); Now after calculation of the first element of the pair, I ran the following if-else block : Matrix L1(r,c) ,L2(r,c); /* Other Code */ if(typeid(this->mat.begin()->front())==typeid(Complex)) L2 = L1.CTranspose(); // If the type is Complex, we can assign conjugate transpose. else L2 = L1.Transpose(); // Else, the conjugate simply does not exist. Just assign normal transpose. Now, I get the following error, if I tried the function for a non complex Matrix: Error : no match for 'operator =' ( operand types are 'Matrix<long double>' and 'Matrix<Complex>' ) How can I repair this? Do I have no other choice but to specialize/overload the Decomposition Function for the Complex Type?

26th Mar 2018, 1:40 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
3 odpowiedzi
+ 3
@~swim~ Thank You very much for your reply. I just wanted some expert advice on the matter so that I may learn of newer techniques that can be applied in the language, but in this case it seems there is only one option...
26th Mar 2018, 4:58 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar