1 #ifndef _theplu_yat_utility_expression_matrix_product 2 #define _theplu_yat_utility_expression_matrix_product 25 #include "MatrixTraits.h" 26 #include "ScaledMatrix.h" 27 #include "TransposedMatrix.h" 29 #include "yat/utility/BasicMatrix.h" 30 #include "yat/utility/MatrixExpression.h" 31 #include "yat/utility/yat_assert.h" 33 #include <gsl/gsl_blas_types.h> 34 #include <gsl/gsl_blas.h> 35 #include <gsl/gsl_cblas.h> 36 #include <gsl/gsl_matrix.h> 44 namespace expression {
47 template<
class MATRIX1,
class MATRIX2>
48 class MatrixProduct :
public MatrixExpression<MatrixProduct<MATRIX1,MATRIX2> >
51 MatrixProduct(
const MATRIX1& A,
const MATRIX2& B)
54 size_t rows(
void)
const {
return A_.rows(); }
55 size_t columns(
void)
const {
return B_.columns(); }
57 double operator()(
size_t row,
size_t column)
const 58 {
return gsl_matrix_get(this->gsl_matrix_p(), row, column); }
60 void calculate_matrix(gsl_matrix*& result)
const 62 detail::reallocate(result, this->rows(), this->columns());
63 YAT_ASSERT(detail::rows(result) == this->rows());
64 YAT_ASSERT(detail::columns(result) == this->columns());
65 YAT_ASSERT(A_.columns() == B_.rows());
66 MatrixTraits<MATRIX1> traits1;
67 MatrixTraits<MATRIX2> traits2;
68 gsl_blas_dgemm(traits1.transpose_type(), traits2.transpose_type(),
69 traits1.factor(A_) * traits2.factor(B_),
70 traits1.get_gsl_matrix_p(A_),
71 traits2.get_gsl_matrix_p(B_),
The Department of Theoretical Physics namespace as we define it.