Changeset 773
 Timestamp:
 Mar 1, 2007, 1:51:25 AM (17 years ago)
 Location:
 trunk/yat/utility
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/yat/utility/matrix.cc
r762 r773 160 160 161 161 162 void matrix::add(const matrix& b)163 {164 int status=gsl_matrix_add(m_, b.m_);165 if (status)166 throw utility::GSL_error(std::string("matrix::add",status));167 }168 169 170 void matrix::add(double d)171 {172 gsl_matrix_add_constant(m_, d);173 }174 175 176 162 size_t matrix::columns(void) const 177 163 { … … 290 276 291 277 292 void matrix::scale(const double d)293 {294 gsl_matrix_scale(m_, d);295 }296 297 298 278 void matrix::set(const matrix& mat) 299 279 { … … 322 302 if (status) 323 303 throw utility::GSL_error(std::string("matrix::set_row",status)); 324 }325 326 327 void matrix::sub(const matrix& b)328 {329 int status=gsl_matrix_sub(m_, b.m_);330 if (status)331 throw utility::GSL_error(std::string("matrix::sub",status));332 304 } 333 305 … … 430 402 const matrix& matrix::operator+=(const matrix& m) 431 403 { 432 add(m); 404 int status=gsl_matrix_add(m_, m.m_); 405 if (status) 406 throw utility::GSL_error(std::string("matrix::operator+=", status)); 433 407 return *this; 434 408 } … … 437 411 const matrix& matrix::operator+=(const double d) 438 412 { 439 add(d);413 gsl_matrix_add_constant(m_, d); 440 414 return *this; 441 415 } … … 444 418 const matrix& matrix::operator=(const matrix& m) 445 419 { 446 sub(m); 420 int status=gsl_matrix_sub(m_, m.m_); 421 if (status) 422 throw utility::GSL_error(std::string("matrix::operator=", status)); 423 return *this; 424 } 425 426 427 const matrix& matrix::operator=(const double d) 428 { 429 gsl_matrix_add_constant(m_, d); 447 430 return *this; 448 431 } … … 467 450 const matrix& matrix::operator*=(const double d) 468 451 { 469 scale(d);452 gsl_matrix_scale(m_, d); 470 453 return *this; 471 454 } 
trunk/yat/utility/matrix.h
r767 r773 143 143 ~matrix(void); 144 144 145 /**146 Elementwise addition of the elements of matrix \a b to the147 elements of the calling matrix ,\f$ a_{ij} = a_{ij} + b_{ij} \;148 \forall i,j \f$. The result is stored into the calling matrix.149 150 \throw GSL_error if dimensions mismatch.151 */152 void add(const matrix& b);153 154 /**155 Add the scalar value \a d to the elements of the calling156 matrix, \f$ a_{ij} = a_{ij} + d \; \forall i,j \f$. The result157 is stored into the calling matrix.158 */159 void add(double d);160 161 145 /// 162 146 /// @return The number of columns in the matrix. … … 248 232 249 233 /** 250 Multiply the elements of the calling matrix with a scalar \a d,251 \f$ a_{ij} = d * a_{ij} \; \forall i,j \f$. The result is252 stored into the calling matrix.253 */254 void scale(const double d);255 256 /**257 234 \brief Set element values to values in \a mat. 258 235 … … 289 266 */ 290 267 void set_row(const size_t row, const vector& vec); 291 292 /**293 Subtract the elements of matrix \a b from the elements of the294 calling matrix ,\f$ a_{ij} = a_{ij}  b_{ij} \; \forall i,j295 \f$. The result is stored into the calling matrix.296 297 \throw GSL_error if dimensions mismatch.298 */299 void sub(const matrix& b);300 268 301 269 /** … … 403 371 \brief Add and assign operator. 404 372 373 Elementwise addition of the elements of matrix \a b to the left 374 hand side matrix ,\f$ a_{ij} = a_{ij} + b_{ij} \; \forall i,j 375 \f$. 376 405 377 \return A const reference to the resulting matrix. 406 378 407 379 \throw GSL_error if dimensions mismatch. 408 380 */ 409 const matrix& operator+=(const matrix&); 410 411 /// 412 /// @brief Add and assign operator. 413 /// 414 const matrix& operator+=(const double); 381 const matrix& operator+=(const matrix& b); 382 383 /** 384 \brief Add and assign operator 385 386 Add the scalar value \a d to the left hand side matrix, \f$ 387 a_{ij} = a_{ij} + d \; \forall i,j \f$. 388 */ 389 const matrix& operator+=(const double d); 415 390 416 391 /** 417 392 \brief Subtract and assign operator. 418 393 394 Elementwise subtraction of the elements of matrix \a b to the 395 left hand side matrix ,\f$ a_{ij} = a_{ij} + b_{ij} \; \forall 396 i,j \f$. 397 419 398 \return A const reference to the resulting matrix. 420 399 … … 424 403 425 404 /** 405 \brief Subtract and assign operator 406 407 Subtract the scalar value \a d to the left hand side matrix, 408 \f$ a_{ij} = a_{ij} + d \; \forall i,j \f$. 409 */ 410 const matrix& operator=(const double d); 411 412 /** 426 413 \brief Multiply and assigment operator. 427 414 … … 435 422 \brief Multiply and assignment operator 436 423 424 Multiply the elements of the left hand side matrix with a 425 scalar \a d, \f$ a_{ij} = d * a_{ij} \; \forall i,j \f$. 426 437 427 \throw GSL_error if memory allocation fails. 438 428 */ 439 const matrix& operator*=( const double);429 const matrix& operator*=(double d); 440 430 441 431 private:
Note: See TracChangeset
for help on using the changeset viewer.