00001
00002
00003
00004
00005
00006
00007 #ifndef MATRIX_H
00008 #define MATRIX_H
00009
00010 #include <QString>
00011 #include <QVector>
00012
00014 class Matrix
00015 {
00016 public:
00018 Matrix(int N);
00019
00021 Matrix (int rows, int cols);
00022
00024 Matrix (const Matrix &other);
00025
00027 Matrix &operator= (const Matrix &matrix);
00028
00030 int cols () const;
00031
00033 double determinant () const;
00034
00036 double get (int row, int col) const;
00037
00039 Matrix inverse () const;
00040
00042 Matrix minorReduced (int rowOmit, int colOmit) const;
00043
00045 Matrix operator* (const Matrix &other) const;
00046
00048 QVector<double> operator* (const QVector<double> other) const;
00049
00051 int rows () const;
00052
00054 void set (int row, int col, double value);
00055
00057 QString toString () const;
00058
00060 Matrix transpose () const;
00061
00062 private:
00063 Matrix();
00064
00065 void addRowToAnotherWithScaling (int rowFrom,
00066 int rowTo,
00067 double factor);
00068 int fold2dIndexes (int row, int col) const;
00069 void initialize (int rows,
00070 int cols);
00071 Matrix inverseCramersRule () const;
00072 Matrix inverseGaussianElimination () const;
00073 unsigned int leadingZeros (int row) const;
00074 void normalizeRow (int rowToNormalize,
00075 int colToNormalize);
00076 void switchRows (int row1,
00077 int row2);
00078
00079 int m_rows;
00080 int m_cols;
00081 QVector<double> m_vector;
00082 };
00083
00084 #endif // MATRIX_H