Almost any matrix can be converted to an arbirtrary other matrix class, but there are of course a few caveats. In particular,
- converting an arbitrary matrix to an Indexmatrix is done by rounding the elements.
- converting a square matrix B to a symmetric matrix class is done via extracting the symmetric part, i.e., by setting A=(B+transpose(B))/2.;
- converting a rectangular matrix to a symmetric matrix is not allowed and will result in an error if DEBUG has been defined during compile time (otherwise the result is undefined).
- In converting an arbitrary matrix to a sparse representation the sparse matrix will consider all elements as zero whose absolute value are below a certain tolerance. This tolerance, however, can be adapted for each sparse matrix separately.
- the same caveats apply to the overloaded assignment operators "="!
- Attention
- There is a certain danger involved in offering all these conversion possibilities. Indeed, sometimes the compiler will automatically choose to convert a matrix class into another one if one has requested a certain matrix operation that is only available for one specific matrix class. On several occasions this has led to rather unexpected results. Therefore explicit conversion is recommended whenever matrix classes of different types are mixed within one statement or whenever one is not sure of the availability of a certain operation for the desired combination of matrices.