Isis 3 Programmer Reference
Matrix.h
1 #ifndef Matrix_h
2 #define Matrix_h
3 
8 /* SPDX-License-Identifier: CC0-1.0 */
9 #include <vector>
10 #include "tnt/tnt_array2d.h"
11 
12 namespace Isis {
34  class Matrix {
35  public:
36  Matrix(const int n, const int m, const double value = 0.0);
37  Matrix(TNT::Array2D<double> matrix);
38  ~Matrix();
39 
40  static Matrix Identity(const int n);
41 
42  inline int Rows() {
43  return p_matrix.dim1();
44  };
45  inline int Columns() {
46  return p_matrix.dim2();
47  };
48 
49  double Determinant();
50  double Trace();;
51 
52  std::vector<double> Eigenvalues();
53 
54  Matrix Add(Matrix &matrix);
55  Matrix Subtract(Matrix &matrix);
56  Matrix Multiply(Matrix &matrix);
57  Matrix Multiply(double scalar);
59  Matrix Transpose();
60  Matrix Inverse();
62 
63  inline double *operator[](int index) {
64  return p_matrix[index];
65  };
66  Matrix operator+ (Matrix &matrix) {
67  return Add(matrix);
68  };
69  Matrix operator- (Matrix &matrix) {
70  return Subtract(matrix);
71  };
72  Matrix operator* (Matrix &matrix) {
73  return Multiply(matrix);
74  };
75  Matrix operator* (double scalar) {
76  return Multiply(scalar);
77  };
78 
79  private:
80  TNT::Array2D<double> p_matrix;
81  };
82 
83  std::ostream &operator<<(std::ostream &os, Matrix &matrix);
84 };
85 
86 #endif
Isis::Matrix::Eigenvalues
std::vector< double > Eigenvalues()
Compute the eigenvalues of the matrix.
Definition: Matrix.cpp:203
Isis::Matrix::Eigenvectors
Matrix Eigenvectors()
Compute the eigenvectors of the matrix and return them as columns of a matrix in ascending order.
Definition: Matrix.cpp:224
Isis::Matrix::Transpose
Matrix Transpose()
Compute the transpose of the matrix.
Definition: Matrix.cpp:170
Isis::operator<<
QDebug operator<<(QDebug debug, const Hillshade &hillshade)
Print this class out to a QDebug object.
Definition: Hillshade.cpp:314
Isis::Matrix::Add
Matrix Add(Matrix &matrix)
Add the two matrices.
Definition: Matrix.cpp:104
Isis::Matrix
Matrix class.
Definition: Matrix.h:34
Isis::Matrix::Matrix
Matrix(const int n, const int m, const double value=0.0)
Constructs an n x m Matrix containing the specified default value.
Definition: Matrix.cpp:24
Isis::Matrix::Multiply
Matrix Multiply(Matrix &matrix)
Multiply the two matrices.
Definition: Matrix.cpp:87
Isis::Matrix::Inverse
Matrix Inverse()
Compute the inverse of the matrix.
Definition: Matrix.cpp:183
Isis::Matrix::Trace
double Trace()
Compute the determinant of the matrix.
Definition: Matrix.cpp:72
Isis::Matrix::Determinant
double Determinant()
Compute the determinant of the matrix.
Definition: Matrix.cpp:60
Isis::Matrix::Identity
static Matrix Identity(const int n)
Create an n x n identity matrix.
Definition: Matrix.cpp:45
Isis::Matrix::Subtract
Matrix Subtract(Matrix &matrix)
Subtract the input matrix from this matrix.
Definition: Matrix.cpp:121
Isis::Matrix::~Matrix
~Matrix()
Destroys the Matrix object.
Definition: Matrix.cpp:40
Isis::Matrix::MultiplyElementWise
Matrix MultiplyElementWise(Matrix &matrix)
Multiply the two matrices element-wise (ie compute C such that C[i][j] = A[i][j]*B[i][j])
Definition: Matrix.cpp:140
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16