XX CMake Package
Loading...
Searching...
No Matches
XXLinalgMatrix.h
Go to the documentation of this file.
1#ifndef XXLinalgMatrixH
2#define XXLinalgMatrixH
3
4#include "XXMathExportDef.h"
5
6#include <QVector>
7
8#include <QDebug>
9#include <QTextStream>
10
11namespace XX
12{
13 namespace Linalg
14 {
17
19 {
20 public:
21 Matrix(const size_t& rowCount = 0, const size_t& columnCount = 0);
22
23 public:
24 struct Cell
25 {
26 size_t rowIndex;
28 double value;
29
30 using List = QList<Cell>;
31 };
32
33 public:
34 bool operator==(const Matrix& other) const;
35 bool operator!=(const Matrix& other) const;
36
37 Matrix operator+(const Matrix& other) const;
38 Matrix operator-(const Matrix& other) const;
39 Matrix operator*(const Matrix& other) const;
40 Matrix operator*(const double& value) const;
41 Matrix operator/(const double& value) const;
42
43 Matrix& operator+=(const Matrix& other);
44 Matrix& operator-=(const Matrix& other);
45 Matrix& operator*=(const double& value);
46 Matrix& operator/=(const double& value);
47
48 const double& operator()(const size_t& rowIndex, const size_t& columnIndex) const;
49 double& operator()(const size_t& rowIndex, const size_t& columnIndex);
50
51 public:
52 double getValue(const size_t& rowIndex, const size_t& columnIndex) const;
53 void setValue(const size_t& rowIndex, const size_t& columnIndex, const double& value);
54 void setValues(const Cell::List& cellList);
55
56 bool sizeMatch(const Matrix& other) const;
57 bool isNull() const;
58
59 size_t getRowCount() const;
60 size_t getColumnCount() const;
61
63 double determinant() const;
64
65 Matrix inverse() const;
67
68 private:
69 friend XXMATH_DECLSPEC QDebug operator<<(QDebug stream, const Matrix& matrix);
70 friend XXMATH_DECLSPEC QTextStream& operator>>(QTextStream& stream, Matrix& matrix);
71 friend XXMATH_DECLSPEC QTextStream& operator<<(QTextStream& stream, const Matrix& matrix);
72
73 private:
74 double subDeterminant(const Matrix& matrix) const;
75 size_t dataIndex(const size_t& rowIndex, const size_t& columnIndex) const;
76
77 private:
78 const size_t rowCount;
79 const size_t columnCount;
80 QVector<double> data;
81 };
82
88
89 XXMATH_DECLSPEC QDebug operator<<(QDebug stream, const Matrix& matrix);
90 XXMATH_DECLSPEC QTextStream& operator>>(QTextStream& stream, Matrix& matrix);
91 XXMATH_DECLSPEC QTextStream& operator<<(QTextStream& stream, const Matrix& matrix);
92
94
95 } // namespace Linalg
96} // namespace XX
97
98#endif // NOT XXLinalgMatrixH
#define XXMATH_DECLSPEC
Definition XXMathExportDef.h:17
NxM martix.
Definition XXLinalgMatrix.h:19
friend QTextStream & operator>>(QTextStream &stream, Matrix &matrix)
Matrix & operator/=(const double &value)
Matrix cofactor() const
bool sizeMatch(const Matrix &other) const
double determinant() const
friend QDebug operator<<(QDebug stream, const Matrix &matrix)
Matrix & operator*=(const double &value)
double & operator()(const size_t &rowIndex, const size_t &columnIndex)
size_t getRowCount() const
friend QTextStream & operator<<(QTextStream &stream, const Matrix &matrix)
Matrix operator+(const Matrix &other) const
double getValue(const size_t &rowIndex, const size_t &columnIndex) const
bool operator==(const Matrix &other) const
void setValue(const size_t &rowIndex, const size_t &columnIndex, const double &value)
Matrix operator/(const double &value) const
bool operator!=(const Matrix &other) const
Matrix inverse() const
bool isNull() const
Matrix(const size_t &rowCount=0, const size_t &columnCount=0)
Matrix transpose() const
size_t getColumnCount() const
const double & operator()(const size_t &rowIndex, const size_t &columnIndex) const
Matrix operator*(const Matrix &other) const
Matrix operator-(const Matrix &other) const
Matrix operator*(const double &value) const
Matrix & operator+=(const Matrix &other)
void setValues(const Cell::List &cellList)
Matrix & operator-=(const Matrix &other)
QDebug operator<<(QDebug stream, const Matrix &matrix)
QTextStream & operator>>(QTextStream &stream, Matrix &matrix)
Definition XXLinalg.h:10
Definition XXPopulatedAbstract.h:11
Definition XXLinalgMatrix.h:25
QList< Cell > List
Definition XXLinalgMatrix.h:30
size_t rowIndex
Definition XXLinalgMatrix.h:26
double value
Definition XXLinalgMatrix.h:28
size_t columnIndex
Definition XXLinalgMatrix.h:27