# Changeset 28

Ignore:
Timestamp:
Aug 20, 2003, 3:57:08 PM (17 years ago)
Message:

Added two operators: "*" which is defined as dotproduct and
mul_elements which is def as elementwise multiplication (returning a vector).

Location:
trunk/src
Files:
2 edited

Unmodified
Removed
• ## trunk/src/vector.cc

 r27 vector vector::operator*( const vector &other ) const { assert( size() == other.size() ); vector res( *this ); gsl_vector_mul( res.get_gsl_vector(), other.get_gsl_vector() ); double vector::operator*( const vector &other ) const { assert( size() == other.size() ); double res = 0.0;; for ( size_t i = 0; i < other.size(); ++i ) { res += other.get( i ) * get( i ); } return res; } vector vector::mul_elements( const vector& other ) { assert( size() == other.size() ); vector res( *this ); gsl_vector_mul( res.get_gsl_vector(), other.get_gsl_vector() ); return res; } std::ostream& thep_gsl_api::operator<< ( std::ostream& s_out, const vector& a )
• ## trunk/src/vector.h

 r27 int operator/=( const double& c ); int operator/=( const vector& other ) const; vector operator*( const vector &other ) const; /** This operator is implemented as dot-product. I case of discussions later on; Jari decided this! */ double operator*( const vector &other ) const; /** This function multiplies all elements in two vectors and returns a third vector containing the result. res = a*b; where size(a) = size(b) = size(res) */ vector vector::mul_elements( const vector& other ); /** standard output operator is defined standard output operator is defined */ friend std::ostream& operator<< ( std::ostream&, const vector& ); private:
Note: See TracChangeset for help on using the changeset viewer.