| 1 | /*
|
|---|
| 2 | * gslmatrix.hpp
|
|---|
| 3 | *
|
|---|
| 4 | * Created on: Jan 8, 2010
|
|---|
| 5 | * Author: heber
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | #ifndef GSLMATRIX_HPP_
|
|---|
| 9 | #define GSLMATRIX_HPP_
|
|---|
| 10 |
|
|---|
| 11 | /*********************************************** includes ***********************************/
|
|---|
| 12 |
|
|---|
| 13 | // include config.h
|
|---|
| 14 | #ifdef HAVE_CONFIG_H
|
|---|
| 15 | #include <config.h>
|
|---|
| 16 | #endif
|
|---|
| 17 |
|
|---|
| 18 | #include <iosfwd>
|
|---|
| 19 |
|
|---|
| 20 | #include <gsl/gsl_matrix.h>
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 | /****************************************** forward declarations *****************************/
|
|---|
| 24 |
|
|---|
| 25 | class GSLMatrix;
|
|---|
| 26 |
|
|---|
| 27 | /********************************************** declarations *******************************/
|
|---|
| 28 |
|
|---|
| 29 | class GSLMatrix {
|
|---|
| 30 | friend class LinearSystemOfEquations;
|
|---|
| 31 | friend std::ostream &operator<<(std::ostream &ost,const GSLMatrix &mat);
|
|---|
| 32 |
|
|---|
| 33 | public:
|
|---|
| 34 | GSLMatrix(size_t m, size_t n);
|
|---|
| 35 | GSLMatrix(const GSLMatrix * const src);
|
|---|
| 36 | GSLMatrix(size_t m, size_t n, gsl_matrix *&src);
|
|---|
| 37 | ~GSLMatrix();
|
|---|
| 38 |
|
|---|
| 39 | // Accessing
|
|---|
| 40 | void SetFromDoubleArray(double * x);
|
|---|
| 41 | double Get(size_t m, size_t n) const;
|
|---|
| 42 | void Set(size_t m, size_t n, double x);
|
|---|
| 43 | double *Pointer(size_t m, size_t n);
|
|---|
| 44 | const double *const_Pointer(size_t m, size_t n) const;
|
|---|
| 45 | size_t getRowCount() const;
|
|---|
| 46 | size_t getColumnCount() const;
|
|---|
| 47 |
|
|---|
| 48 | // Initializing
|
|---|
| 49 | void SetAll(double x);
|
|---|
| 50 | void SetZero();
|
|---|
| 51 | void SetIdentity();
|
|---|
| 52 |
|
|---|
| 53 | // Exchanging elements
|
|---|
| 54 | bool SwapRows(size_t i, size_t j);
|
|---|
| 55 | bool SwapColumns(size_t i, size_t j);
|
|---|
| 56 | bool SwapRowColumn(size_t i, size_t j);
|
|---|
| 57 |
|
|---|
| 58 | // Properties
|
|---|
| 59 | bool Transpose();
|
|---|
| 60 | bool IsNull() const;
|
|---|
| 61 | bool IsPositive() const;
|
|---|
| 62 | bool IsNegative() const;
|
|---|
| 63 | bool IsNonNegative() const;
|
|---|
| 64 | bool IsPositiveDefinite() const;
|
|---|
| 65 | double Determinant() const;
|
|---|
| 66 |
|
|---|
| 67 | // Operators
|
|---|
| 68 | GSLMatrix &operator=(const GSLMatrix &src);
|
|---|
| 69 | const GSLMatrix &operator+=(const GSLMatrix &rhs);
|
|---|
| 70 | const GSLMatrix &operator-=(const GSLMatrix &rhs);
|
|---|
| 71 | const GSLMatrix &operator*=(const GSLMatrix &rhs);
|
|---|
| 72 | const GSLMatrix operator+(const GSLMatrix &rhs) const;
|
|---|
| 73 | const GSLMatrix operator-(const GSLMatrix &rhs) const;
|
|---|
| 74 | const GSLMatrix operator*(const GSLMatrix &rhs) const;
|
|---|
| 75 |
|
|---|
| 76 | private:
|
|---|
| 77 | gsl_matrix *matrix;
|
|---|
| 78 |
|
|---|
| 79 | size_t rows;
|
|---|
| 80 | size_t columns;
|
|---|
| 81 | };
|
|---|
| 82 |
|
|---|
| 83 | std::ostream &operator<<(std::ostream &ost,const GSLMatrix &mat);
|
|---|
| 84 |
|
|---|
| 85 | #endif /* GSLMATRIX_HPP_ */
|
|---|