void cast_and_apply(Function& f, Matrix1& first, Matrix2& second) { typedef typename Matrix2::value_type value_type; typedef typename Matrix2::dense_type dense_type; typedef typename Matrix2::sparse_type sparse_type; typedef typename Matrix2::scalar_type scalar_type; if (second.is_true_scalar()) { // kanske bara ta in värdet ist const scalar_type& sc = dynamic_cast<const scalar_type&> (second); Operator<Function, Matrix1, const scalar_type> op; op(f, first, sc); } else if (second.is_dense()) { const dense_type& d = dynamic_cast<const dense_type&> (second); Operator<Function, Matrix1, const dense_type> op; op(f, first, d); } else if (second.is_sparse()) { const sparse_type& s = dynamic_cast<const sparse_type&> (second); Operator<Function, Matrix1, const sparse_type> op; op(f, first, s); } else { Operator<Function, Matrix1, const Matrix2> op; op(f, first, second); } }
void cast_and_apply(Matrix1& first, Matrix2& second) { typedef typename Matrix2::dense_type dense_type; typedef typename Matrix2::sparse_type sparse_type; typedef typename Matrix2::scalar_type scalar_type; if (second.is_true_scalar()) { // kanske bara ta in värdet ist const scalar_type& sc = dynamic_cast<const scalar_type&> (second); Operator<Matrix1, const scalar_type> op; op(first, sc); } else if (second.is_dense()) { const dense_type& d = dynamic_cast<const dense_type&> (second); Operator<Matrix1, const dense_type> op; op(first, d); } else if (second.is_sparse()) { const sparse_type& s = dynamic_cast<const sparse_type&> (second); Operator<Matrix1, const sparse_type> op; op(first, s); } else { std::cout << "Did not match a type" << std::endl; Operator<Matrix1, const Matrix2> op; op(first, second); } }