1 #ifndef _theplu_yat_utility_blas_level2 2 #define _theplu_yat_utility_blas_level2 25 #include "BasicMatrix.h" 26 #include "BasicVector.h" 27 #include "yat_assert.h" 29 #include "VectorExpression.h" 31 #include "gsl/gsl_blas.h" 44 namespace expression {
46 template<
typename MATRIX,
typename VECTOR>
47 class MatrixVector :
public VectorExpression<MatrixVector<MATRIX, VECTOR> >
50 MatrixVector(
const BasicMatrix<MATRIX>& lhs,
51 const BasicVector<VECTOR>& rhs)
53 YAT_ASSERT(lhs.columns() == rhs.size());
54 YAT_ASSERT(lhs.rows());
55 this->allocate_memory(lhs.rows());
56 gsl_blas_dgemv(CblasNoTrans, 1.0, lhs.gsl_matrix_p(),
57 rhs.gsl_vector_p(), 0.0, this->v_);
60 MatrixVector(
const BasicVector<VECTOR>& lhs,
61 const BasicMatrix<MATRIX>& rhs)
63 YAT_ASSERT(lhs.size() == rhs.rows());
64 YAT_ASSERT(rhs.columns());
65 this->allocate_memory(rhs.columns());
66 gsl_blas_dgemv(CblasTrans, 1.0, rhs.gsl_matrix_p(),
67 lhs.gsl_vector_p(), 0.0, this->v_);
72 double operator()(
size_t i)
const 75 return gsl_vector_get(this->v_, i);
79 size_t size(
void)
const 82 return this->v_->size;
86 void calculate_gsl_vector_p(
void)
const 106 template<
class MATRIX,
class VECTOR>
107 expression::MatrixVector<MATRIX, VECTOR>
111 return expression::MatrixVector<MATRIX, VECTOR>(lhs, rhs);
123 template<
class MATRIX,
class VECTOR>
124 expression::MatrixVector<MATRIX, VECTOR>
127 YAT_ASSERT(lhs.
size() == rhs.
rows());
128 return expression::MatrixVector<MATRIX, VECTOR>(lhs, rhs);
size_t size(void) const
Definition: BasicVector.h:71
The Department of Theoretical Physics namespace as we define it.
size_t rows(void) const
Definition: BasicMatrix.h:61
size_t columns(void) const
Definition: BasicMatrix.h:67
expression::MatrixVector< MATRIX, VECTOR > operator*(const BasicVector< VECTOR > &lhs, const BasicMatrix< MATRIX > &rhs)
Definition: BLAS_level2.h:125
Definition: BasicVector.h:48
Definition: BasicMatrix.h:38
expression::MatrixVector< MATRIX, VECTOR > operator*(const BasicMatrix< MATRIX > &lhs, const BasicVector< VECTOR > &rhs)
Definition: BLAS_level2.h:108