Changeset 1121 for trunk/yat/utility/Matrix.h
 Timestamp:
 Feb 22, 2008, 4:29:56 PM (14 years ago)
 File:

 1 moved
Legend:
 Unmodified
 Added
 Removed

trunk/yat/utility/Matrix.h
r1120 r1121 62 62 /// superdiagonals. 63 63 /// 64 class matrix64 class Matrix 65 65 { 66 66 public: … … 95 95 structures. 96 96 */ 97 matrix(void);97 Matrix(void); 98 98 99 99 /** … … 103 103 \throw GSL_error if memory allocation fails. 104 104 */ 105 matrix(const size_t& r, const size_t& c, double init_value=0);105 Matrix(const size_t& r, const size_t& c, double init_value=0); 106 106 107 107 /** … … 111 111 fails. 112 112 */ 113 matrix(const matrix&);113 Matrix(const Matrix&); 114 114 115 115 /** … … 127 127 unexpected input is found in the input stream. 128 128 */ 129 explicit matrix(std::istream &, char sep='\0')129 explicit Matrix(std::istream &, char sep='\0') 130 130 throw(utility::IO_error, std::exception); 131 131 … … 133 133 \brief The destructor. 134 134 */ 135 ~ matrix(void);135 ~Matrix(void); 136 136 137 137 /// … … 206 206 \throw GSL_error if dimensions mismatch. 207 207 */ 208 void div(const matrix& b);208 void div(const Matrix& b); 209 209 210 210 /** … … 247 247 \see operator== and operator!= 248 248 */ 249 bool equal(const matrix&, const double precision=0) const;249 bool equal(const Matrix&, const double precision=0) const; 250 250 251 251 /// … … 260 260 261 261 /** 262 Multiply the elements of matrix \a b with the elements of the263 calling matrix ,\f$ a_{ij} = a_{ij} * b_{ij} \; \forall i,j264 \f$. The result is stored into the calling matrix.262 Multiply the elements of Matrix \a b with the elements of the 263 calling Matrix ,\f$ a_{ij} = a_{ij} * b_{ij} \; \forall i,j 264 \f$. The result is stored into the calling Matrix. 265 265 266 266 \throw GSL_error if dimensions mismatch. 267 267 */ 268 void mul(const matrix& b);269 270 /** 271 \brief Resize matrix268 void mul(const Matrix& b); 269 270 /** 271 \brief Resize Matrix 272 272 273 273 All elements are set to @a init_value. 274 274 275 275 \note underlying GSL matrix is destroyed and views into this 276 matrix becomes invalid.276 Matrix becomes invalid. 277 277 */ 278 278 void resize(size_t, size_t, double init_value=0); … … 303 303 \brief Swap row \a i and column \a j. 304 304 305 The matrix must be square.305 The Matrix must be square. 306 306 307 307 \throw GSL_error if either index is out of bounds, or if matrix … … 359 359 \see equal 360 360 */ 361 bool operator==(const matrix& other) const;361 bool operator==(const Matrix& other) const; 362 362 363 363 /** … … 372 372 \see equal 373 373 */ 374 bool operator!=(const matrix& other) const;374 bool operator!=(const Matrix& other) const; 375 375 376 376 /** 377 377 \brief The assignment operator. 378 378 379 \return A const reference to the resulting matrix.380 */ 381 const matrix& operator=(const matrix& other);379 \return A const reference to the resulting Matrix. 380 */ 381 const Matrix& operator=(const Matrix& other); 382 382 383 383 /** 384 384 \brief Add and assign operator. 385 385 386 Elementwise addition of the elements of matrix \a b to the left387 hand side matrix ,\f$ a_{ij} = a_{ij} + b_{ij} \; \forall i,j386 Elementwise addition of the elements of Matrix \a b to the left 387 hand side Matrix ,\f$ a_{ij} = a_{ij} + b_{ij} \; \forall i,j 388 388 \f$. 389 389 390 \return A const reference to the resulting matrix.390 \return A const reference to the resulting Matrix. 391 391 392 392 \throw GSL_error if dimensions mismatch. 393 393 */ 394 const matrix& operator+=(const matrix& b);394 const Matrix& operator+=(const Matrix& b); 395 395 396 396 /** 397 397 \brief Add and assign operator 398 398 399 Add the scalar value \a d to the left hand side matrix, \f$399 Add the scalar value \a d to the left hand side Matrix, \f$ 400 400 a_{ij} = a_{ij} + d \; \forall i,j \f$. 401 401 */ 402 const matrix& operator+=(const double d);402 const Matrix& operator+=(const double d); 403 403 404 404 /** 405 405 \brief Subtract and assign operator. 406 406 407 Elementwise subtraction of the elements of matrix \a b to the408 left hand side matrix ,\f$ a_{ij} = a_{ij} + b_{ij} \; \forall407 Elementwise subtraction of the elements of Matrix \a b to the 408 left hand side Matrix ,\f$ a_{ij} = a_{ij} + b_{ij} \; \forall 409 409 i,j \f$. 410 410 411 \return A const reference to the resulting matrix.411 \return A const reference to the resulting Matrix. 412 412 413 413 \throw GSL_error if dimensions mismatch. 414 414 */ 415 const matrix& operator=(const matrix&);415 const Matrix& operator=(const Matrix&); 416 416 417 417 /** 418 418 \brief Subtract and assign operator 419 419 420 Subtract the scalar value \a d to the left hand side matrix,420 Subtract the scalar value \a d to the left hand side Matrix, 421 421 \f$ a_{ij} = a_{ij} + d \; \forall i,j \f$. 422 422 */ 423 const matrix& operator=(const double d);423 const Matrix& operator=(const double d); 424 424 425 425 /** 426 426 \brief Multiply and assigment operator. 427 427 428 \return Const reference to the resulting matrix.428 \return Const reference to the resulting Matrix. 429 429 430 430 \throw GSL_error if memory allocation fails. 431 431 */ 432 const matrix& operator*=(const matrix&);432 const Matrix& operator*=(const Matrix&); 433 433 434 434 /** 435 435 \brief Multiply and assignment operator 436 436 437 Multiply the elements of the left hand side matrix with a437 Multiply the elements of the left hand side Matrix with a 438 438 scalar \a d, \f$ a_{ij} = d * a_{ij} \; \forall i,j \f$. 439 439 440 440 \throw GSL_error if memory allocation fails. 441 441 */ 442 const matrix& operator*=(double d);442 const Matrix& operator*=(double d); 443 443 444 444 private: … … 473 473 474 474 /** 475 \brief Check if all elements of the matrix are zero.476 477 \return True if all elements in the matrix is zero, false475 \brief Check if all elements of the Matrix are zero. 476 477 \return True if all elements in the Matrix is zero, false 478 478 othwerwise. 479 479 */ 480 bool isnull(const matrix&);481 482 /** 483 \brief Get the maximum value of the matrix.484 485 \return The maximum value of the matrix.486 */ 487 double max(const matrix&);488 489 /** 490 \brief Get the minimum value of the matrix.491 492 \return The minimum value of the matrix.493 */ 494 double min(const matrix&);495 496 /** 497 \brief Locate the maximum and minumum element in the matrix.480 bool isnull(const Matrix&); 481 482 /** 483 \brief Get the maximum value of the Matrix. 484 485 \return The maximum value of the Matrix. 486 */ 487 double max(const Matrix&); 488 489 /** 490 \brief Get the minimum value of the Matrix. 491 492 \return The minimum value of the Matrix. 493 */ 494 double min(const Matrix&); 495 496 /** 497 \brief Locate the maximum and minumum element in the Matrix. 498 498 499 499 \return The indecies to the element with the minimum and maximum 500 values of the matrix, respectively.500 values of the Matrix, respectively. 501 501 502 502 \note Lower index has precedence (searching in rowmajor order). 503 503 */ 504 void minmax_index(const matrix&,504 void minmax_index(const Matrix&, 505 505 std::pair<size_t,size_t>& min, 506 506 std::pair<size_t,size_t>& max); 507 507 508 508 /** 509 \brief Create a matrix \a flag indicating NaN's in another matrix509 \brief Create a Matrix \a flag indicating NaN's in another Matrix 510 510 \a templat. 511 511 512 The \a flag matrix is changed to contain 1's and 0's only. A 1513 means that the corresponding element in the \a templat matrix is512 The \a flag Matrix is changed to contain 1's and 0's only. A 1 513 means that the corresponding element in the \a templat Matrix is 514 514 valid and a zero means that the corresponding element is a NaN. 515 515 516 \note Space for matrix \a flag is reallocated to fit the size of517 matrix \a templat if sizes mismatch.518 519 \return True if the \a templat matrix contains at least one NaN.520 */ 521 bool nan(const matrix& templat, matrix& flag);516 \note Space for Matrix \a flag is reallocated to fit the size of 517 Matrix \a templat if sizes mismatch. 518 519 \return True if the \a templat Matrix contains at least one NaN. 520 */ 521 bool nan(const Matrix& templat, Matrix& flag); 522 522 523 523 /** … … 528 528 \throw GSL_error if either index is out of bounds. 529 529 */ 530 void swap( matrix&, matrix&);531 532 /** 533 \brief The output operator for the matrix class.534 */ 535 std::ostream& operator<< (std::ostream& s, const matrix&);536 537 /** 538 \brief vector matrix multiplication530 void swap(Matrix&, Matrix&); 531 532 /** 533 \brief The output operator for the Matrix class. 534 */ 535 std::ostream& operator<< (std::ostream& s, const Matrix&); 536 537 /** 538 \brief vector Matrix multiplication 539 539 */ 540 Vector operator*(const matrix&, const VectorBase&);541 542 /** 543 \brief matrix vector multiplication540 Vector operator*(const Matrix&, const VectorBase&); 541 542 /** 543 \brief Matrix vector multiplication 544 544 */ 545 Vector operator*(const VectorBase&, const matrix&);545 Vector operator*(const VectorBase&, const Matrix&); 546 546 547 547 }}} // of namespace utility, yat, and theplu
Note: See TracChangeset
for help on using the changeset viewer.