1 #ifndef _theplu_yat_utility_vector_expression 2 #define _theplu_yat_utility_vector_expression 27 #include "BasicVector.h" 28 #include "MatrixExpression.h" 29 #include "yat_assert.h" 31 #include <gsl/gsl_blas.h> 32 #include <gsl/gsl_matrix.h> 33 #include <gsl/gsl_vector.h> 66 template<
class Derived>
89 if (gsl_vector_memcpy(
v_, other.
v_))
90 throw GSL_error(
"VectorExpression: gsl_vector_memcpy failed");
94 #ifdef YAT_HAVE_RVALUE 99 std::swap(
v_, other.v_);
105 {
return static_cast<const Derived*
>(
this)->
size(); }
109 {
return (*static_cast<const Derived*>(
this))(i); }
115 static_cast<const Derived*
>(
this)->calculate_gsl_vector_p();
123 static_cast<const Derived*
>(
this)->calculate_gsl_vector_p();
137 mutable gsl_vector*
v_;
142 v_ = gsl_vector_alloc(n);
144 throw GSL_error(
"Vector: failed to allocate memory");
VectorExpression(void)
default constructor
Definition: VectorExpression.h:75
gsl_vector * gsl_vector_p(void)
return a mutable GSL vector pointer
Definition: VectorExpression.h:120
size_t size(void) const
Definition: VectorExpression.h:104
~VectorExpression(void)
destructor, free allocated memory
Definition: VectorExpression.h:78
Class for errors reported from underlying GSL calls.
Definition: Exception.h:87
The Department of Theoretical Physics namespace as we define it.
gsl_vector * v_
Definition: VectorExpression.h:137
void allocate_memory(size_t n) const
allocate memory and throw if fails
Definition: VectorExpression.h:140
void delete_allocated_memory(void)
clean up
Definition: VectorExpression.h:148
const gsl_vector * gsl_vector_p(void) const
return a GSL vector pointer
Definition: VectorExpression.h:112
double operator()(size_t i) const
access an element
Definition: VectorExpression.h:108
An expression that can be converted to a Vector.
Definition: VectorExpression.h:67
VectorExpression(const VectorExpression &other)
Cop constructor.
Definition: VectorExpression.h:84
Definition: BasicVector.h:48
Derived derived_type
Derived class.
Definition: VectorExpression.h:72
void gsl_vector_p(gsl_vector *v)
set underlying GSL vector
Definition: VectorExpression.h:129