Problems with taking magnitude
Opened this issue · 3 comments
jeanluct commented
Some problems with taking magnitudes: if I have a mathvector of complex numbers, then the magnitude should return a real, not complex, number. Also, it shouldn't be defined as x*x, as this is wrong for complex numbers. Need to call a magnitude function for the type. Maybe also need a magnitude type. Define with traits?
jeanluct commented
Part of the problem is with
template<class T, class S = T>
class mathvector : public vector<T> // note that this is jlt::vector
S = T is not the right default for complex.
jeanluct commented
See mathvector_test.cpp
. The situation is better: mathvector<complex>
now makes a vector with complex scalar type, so mag2 returns a complex (with zero real part). mathvector<complex,double>
is the more sensible case.