diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-05-02 22:57:13 -0400 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-05-02 22:57:13 -0400 |
| commit | 330f75e663c22e1198a92fd134865ada98c3957b (patch) | |
| tree | b78f8aa762fcc93c14a0905546b694cddaaa3041 /matrix3x3.h | |
| download | infinite-330f75e663c22e1198a92fd134865ada98c3957b.tar.gz infinite-330f75e663c22e1198a92fd134865ada98c3957b.tar.bz2 infinite-330f75e663c22e1198a92fd134865ada98c3957b.zip | |
Initial commit
Diffstat (limited to 'matrix3x3.h')
| -rw-r--r-- | matrix3x3.h | 54 |
1 files changed, 54 insertions, 0 deletions
| diff --git a/matrix3x3.h b/matrix3x3.h new file mode 100644 index 0000000..fe54aad --- /dev/null +++ b/matrix3x3.h | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | #ifndef MATRIX3X3_H_AEC5146F | ||
| 2 | #define MATRIX3X3_H_AEC5146F | ||
| 3 | |||
| 4 | #include "vector3d.h" | ||
| 5 | |||
| 6 | class Matrix3x3 { | ||
| 7 | public: | ||
| 8 | Matrix3x3(); | ||
| 9 | |||
| 10 | // Initializer should take three vectors representing the columns | ||
| 11 | Matrix3x3(std::initializer_list<Vector3D> vals); | ||
| 12 | |||
| 13 | void zero(double val = 0.0); | ||
| 14 | double det() const; | ||
| 15 | double norm() const; | ||
| 16 | |||
| 17 | static Matrix3x3 identity(); | ||
| 18 | static Matrix3x3 crossProduct(const Vector3D& u); | ||
| 19 | |||
| 20 | Vector3D& column(int i); | ||
| 21 | const Vector3D& column(int i) const; | ||
| 22 | |||
| 23 | Matrix3x3 T() const; | ||
| 24 | Matrix3x3 inv() const; | ||
| 25 | |||
| 26 | double& operator()(int i, int j); | ||
| 27 | const double& operator()(int i, int j) const; | ||
| 28 | |||
| 29 | Vector3D& operator[](int i); | ||
| 30 | const Vector3D& operator[](int i) const; | ||
| 31 | |||
| 32 | void operator+=(const Matrix3x3& B); | ||
| 33 | |||
| 34 | Matrix3x3 operator-() const; | ||
| 35 | Matrix3x3 operator-(const Matrix3x3& B) const; | ||
| 36 | Matrix3x3 operator*(double c) const; | ||
| 37 | Matrix3x3 operator*(const Matrix3x3& B) const; | ||
| 38 | Vector3D operator*(const Vector3D& x) const; | ||
| 39 | void operator/=(double x); | ||
| 40 | |||
| 41 | protected: | ||
| 42 | Vector3D entries[3]; | ||
| 43 | }; | ||
| 44 | |||
| 45 | // returns the outer product of u and v | ||
| 46 | Matrix3x3 outer(const Vector3D& u, const Vector3D& v); | ||
| 47 | |||
| 48 | // returns c*A | ||
| 49 | Matrix3x3 operator*(double c, const Matrix3x3& A); | ||
| 50 | |||
| 51 | // prints entries | ||
| 52 | std::ostream& operator<<(std::ostream& os, const Matrix3x3& A); | ||
| 53 | |||
| 54 | #endif /* end of include guard: MATRIX3X3_H_AEC5146F */ | ||
