10 #include "DecompLU.hh"
11 #include "DecompQR.hh"
30 Matrix(
const size_t m,
const size_t n);
33 Matrix(
const size_t m,
const size_t n,
const T& value);
36 Matrix(
const std::vector<T>& v);
39 Matrix(
const std::vector<std::vector<T>>& mat);
51 explicit operator bool()
const;
93 const std::vector<T>&
operator[](
const size_t i)
const;
105 T
Cofactor(
const size_t i,
const size_t j)
const;
123 std::vector<T>
Column(
const size_t i)
const;
138 void Fill(
const T& value);
161 const size_t Nrows()
const;
167 const size_t Ncols()
const;
183 void Resize(
const size_t m,
const size_t n);
189 const std::vector<T>&
Row(
const size_t i)
const;
195 std::vector<T>&
Row(
const size_t i);
201 std::vector<T>
Solve(
const std::vector<T>& b)
const;
207 const std::vector<std::vector<T>>&
std()
const;
217 std::vector<std::vector<T>>
_mat;
220 #include "Matrix-inl.hh"
const size_t Ncols() const
Returns the number of columns.
Definition: Matrix-inl.hh:486
Matrix & operator=(const Matrix &mat)
Equality operator.
Definition: Matrix-inl.hh:43
Matrix operator*(const Matrix &mat) const
Overload the matrix product.
Definition: Matrix-inl.hh:127
Matrix operator/(const T &factor) const
Overload the matrix ratio with a scalar.
Definition: Matrix-inl.hh:208
void RemoveColumn(const size_t i)
Removes the i^th column of the matrix.
Definition: Matrix-inl.hh:504
void operator-=(const Matrix &mat)
Overload the matrix substraction.
Definition: Matrix-inl.hh:115
bool operator!() const
Boolean not operator.
Definition: Matrix-inl.hh:56
Object that can host any type of data in a vector arrangement.
Definition: Vector.hh:17
std::vector< std::vector< T > > _mat
Underlying std::vector<std::vector>>
Definition: Matrix.hh:217
Matrix< T > Inverse() const
Returns the inverse of the matrix.
Definition: Matrix-inl.hh:401
void operator/=(const T &factor)
Overload the matrix ratio with a scalar.
Definition: Matrix-inl.hh:223
void Identity()
Sets the matrix to an identity matrix.
Definition: Matrix-inl.hh:392
const std::vector< T > & Row(const size_t i) const
Returns the i^th row of the matrix as a vector.
Definition: Matrix-inl.hh:526
void Resize(const size_t m, const size_t n)
Resizes the matrix to chosen dimension.
Definition: Matrix-inl.hh:518
Matrix operator-() const
Overload the unary minus for matrix algebra.
Definition: Matrix-inl.hh:61
bool IsSymmetric() const
Checks whether the matrix is symmetric or not.
Definition: Matrix-inl.hh:470
Matrix< T > CofactorMatrix() const
Returns the inverse of the matrix.
Definition: Matrix-inl.hh:283
std::vector< T > Column(const size_t i) const
Returns the i^th column of the matrix as a vector.
Definition: Matrix-inl.hh:301
const std::vector< T > & operator[](const size_t i) const
Overload the subscript operator, return an std::vector row.
Definition: Matrix-inl.hh:235
void Fill(const T &value)
Fills the matrix with a certain value.
Definition: Matrix-inl.hh:384
Matrix()
Default constructor, initilizes an empty matrix of dimension 0x0.
Definition: Matrix-inl.hh:1
const size_t Nrows() const
Returns the number of rows.
Definition: Matrix-inl.hh:482
Matrix operator+(const Matrix &mat) const
Overload the matrix sum.
Definition: Matrix-inl.hh:73
void Invert()
Inverts the matrix in place.
Definition: Matrix-inl.hh:409
Object that can host any type of data in an matrix arrangement.
Definition: Matrix.hh:21
const std::vector< std::vector< T > > & std() const
Returns the underlying std vector.
Definition: Matrix-inl.hh:583
T Determinant() const
Returns the deterimant of the matrix.
Definition: Matrix-inl.hh:312
void RemoveRow(const size_t i)
Removes the i^th row of the matrix.
Definition: Matrix-inl.hh:512
~Matrix()
Destructor.
Definition: Matrix-inl.hh:41
std::vector< T > Solve(const std::vector< T > &b) const
Solves A*x=b, provided with b.
Definition: Matrix-inl.hh:538
void Print() const
Print the matrix.
Definition: Matrix-inl.hh:494
Matrix< T > Transpose() const
Returns the matrix transpose.
Definition: Matrix-inl.hh:588
void operator*=(const Matrix &mat)
Overload the matrix product equality.
Definition: Matrix-inl.hh:143
T Cofactor(const size_t i, const size_t j) const
Returns the ith-jth cofactor of the matrix.
Definition: Matrix-inl.hh:266
Matrix< T > EigenVectors(std::vector< T > &lambdas, const double eps=1e-6) const
Returns the matrix of which the columns are the eigenvectors of the matrix.
Definition: Matrix-inl.hh:334
void operator+=(const Matrix &mat)
Overload the matrix sum.
Definition: Matrix-inl.hh:88