Isis Developer Reference
Matrix.h
Go to the documentation of this file.
1#ifndef Matrix_h
2#define Matrix_h
8/* SPDX-License-Identifier: CC0-1.0 */
9#include <vector>
10#include "tnt/tnt_array2d.h"
11
12namespace 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);
62
63 inline double *operator[](int index) {
64 return p_matrix[index];
65 };
67 return Add(matrix);
68 };
70 return Subtract(matrix);
71 };
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
Matrix class.
Definition Matrix.h:34
int Columns()
Definition Matrix.h:45
double Determinant()
Compute the determinant of the matrix.
Definition Matrix.cpp:60
std::vector< double > Eigenvalues()
Compute the eigenvalues of the matrix.
Definition Matrix.cpp:203
Matrix Transpose()
Compute the transpose of the matrix.
Definition Matrix.cpp:170
Matrix Subtract(Matrix &matrix)
Subtract the input matrix from this matrix.
Definition Matrix.cpp:121
Matrix Eigenvectors()
Compute the eigenvectors of the matrix and return them as columns of a matrix in ascending order.
Definition Matrix.cpp:224
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
double Trace()
Compute the determinant of the matrix.
Definition Matrix.cpp:72
Matrix operator*(Matrix &matrix)
Definition Matrix.h:72
double * operator[](int index)
Definition Matrix.h:63
~Matrix()
Destroys the Matrix object.
Definition Matrix.cpp:40
Matrix Inverse()
Compute the inverse of the matrix.
Definition Matrix.cpp:183
Matrix operator-(Matrix &matrix)
Definition Matrix.h:69
Matrix Add(Matrix &matrix)
Add the two matrices.
Definition Matrix.cpp:104
int Rows()
Definition Matrix.h:42
static Matrix Identity(const int n)
Create an n x n identity matrix.
Definition Matrix.cpp:45
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
Matrix Multiply(Matrix &matrix)
Multiply the two matrices.
Definition Matrix.cpp:87
Matrix operator+(Matrix &matrix)
Definition Matrix.h:66
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
QDebug operator<<(QDebug debug, const Hillshade &hillshade)
Print this class out to a QDebug object.
Definition Hillshade.cpp:313