Changeset 28
Legend:
 Unmodified
 Added
 Removed

trunk/src/vector.cc
r27 r28 167 167 168 168 169 vector vector::operator*( const vector &other ) const 170 { 171 assert( size() == other.size() ); 172 vector res( *this ); 173 gsl_vector_mul( res.get_gsl_vector(), other.get_gsl_vector() ); 169 double vector::operator*( const vector &other ) const 170 { 171 assert( size() == other.size() ); 172 double res = 0.0;; 173 for ( size_t i = 0; i < other.size(); ++i ) 174 { 175 res += other.get( i ) * get( i ); 176 } 174 177 return res; 175 178 } … … 200 203 201 204 205 206 vector vector::mul_elements( const vector& other ) 207 { 208 assert( size() == other.size() ); 209 vector res( *this ); 210 gsl_vector_mul( res.get_gsl_vector(), other.get_gsl_vector() ); 211 return res; 212 } 213 202 214 std::ostream& thep_gsl_api::operator<< ( std::ostream& s_out, 203 215 const vector& a ) 
trunk/src/vector.h
r27 r28 153 153 int operator/=( const double& c ); 154 154 int operator/=( const vector& other ) const; 155 vector operator*( const vector &other ) const; 155 /** 156 This operator is implemented as dotproduct. 157 I case of discussions later on; Jari decided 158 this! 159 */ 160 double operator*( const vector &other ) const; 156 161 162 /** 163 This function multiplies all elements in two vectors 164 and returns a third vector containing the result. 165 res = a*b; where size(a) = size(b) = size(res) 166 */ 167 vector vector::mul_elements( const vector& other ); 168 169 157 170 /** 158 171 standard output operator is defined 159 172 */ 160 173 friend std::ostream& operator<< ( std::ostream&, const vector& ); 161 162 163 174 164 175 165 176 private:
Note: See TracChangeset
for help on using the changeset viewer.