I want to add two sparse armadillo matrices of arbitrary (different) type with operator+, e.g.
SpMat<double> M1(2,2);
SpMat<cx_double> M2(2,2);
// ..fill both matrices
cout<<M1 + M2<<endl;
Upon compiling, the compiler complains that operator+ is not defined for those types.
When doing the same with DENSE matrices, armadillo automatically promotes the double matrix to a complex one, performs the addition and prints a complex result matrix.
There is a corresponding template for this operator in operator_plus.hpp in the include dir for adding two sparse objects, possibly of different type (at least the template definition suggests that), but it seems to only work when both operands are of the same type. The actual compiler message for the above code is the following
operator_plus.hpp:164:1: note: template<class T1, class T2> typename arma::enable_if2<((arma::is_arma_sparse_type<T1>::value && arma::is_arma_sparse_type<T2>::value) && arma::is_same_type<typename T1::elem_type, typename T2::elem_type>::value), arma::SpGlue<T1, T2, arma::spglue_plus> >::result arma::operator+(const T1&, const T2&)
operator_plus.hpp:164:1: note: template argument deduction/substitution failed:
operator_plus.hpp:164:1: error: no type named ‘result’ in ‘struct arma::enable_if2<false, arma::SpGlue<arma::SpMat<double>, arma::SpMat<std::complex<double> >, arma::spglue_plus> >’
Any ideas? Is it possible that this feature is just not implemented yet? Thanks!