LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Public Member Functions | List of all members
lsst::sphgeom::Matrix3d Class Reference

A 3x3 matrix with real entries stored in double precision. More...

#include <Matrix3d.h>

Public Member Functions

 Matrix3d ()
 This constructor creates a zero matrix. More...
 
 Matrix3d (double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22)
 This constructor creates a matrix from its components, where mij specifies the component for row i and column j. More...
 
 Matrix3d (Vector3d const &v)
 This constructor creates a diagonal matrix with diagonal components set to the components of v. More...
 
 Matrix3d (double s)
 This constructor returns the identity matrix scaled by s. More...
 
bool operator== (Matrix3d const &m) const
 
bool operator!= (Matrix3d const &m) const
 
Vector3d getRow (int r) const
 getRow returns the r-th matrix row. Bounds are not checked. More...
 
Vector3d const & getColumn (int c) const
 getColumn returns the c-th matrix column. Bounds are not checked. More...
 
double operator() (int r, int c) const
 The function call operator returns the scalar at row r and column c. More...
 
double inner (Matrix3d const &m) const
 inner returns the Frobenius inner product of this matrix with m. More...
 
double getSquaredNorm () const
 getSquaredNorm returns the Frobenius inner product of this matrix with itself. More...
 
double getNorm () const
 getNorm returns the L2 (Frobenius) norm of this matrix. More...
 
Vector3d operator* (Vector3d const &v) const
 The multiplication operator returns the product of this matrix with vector v. More...
 
Matrix3d operator* (Matrix3d const &m) const
 The multiplication operator returns the product of this matrix with matrix m. More...
 
Matrix3d operator+ (Matrix3d const &m) const
 The addition operator returns the sum of this matrix and m. More...
 
Matrix3d operator- (Matrix3d const &m) const
 The subtraction operator returns the difference between this matrix and m. More...
 
Matrix3d cwiseProduct (Matrix3d const &m) const
 cwiseProduct returns the component-wise product of this matrix and m. More...
 
Matrix3d transpose () const
 transpose returns the transpose of this matrix. More...
 
Matrix3d inverse () const
 inverse returns the inverse of this matrix. More...
 

Detailed Description

A 3x3 matrix with real entries stored in double precision.

Definition at line 38 of file Matrix3d.h.

Constructor & Destructor Documentation

◆ Matrix3d() [1/4]

lsst::sphgeom::Matrix3d::Matrix3d ( )
inline

This constructor creates a zero matrix.

Definition at line 41 of file Matrix3d.h.

41 {}

◆ Matrix3d() [2/4]

lsst::sphgeom::Matrix3d::Matrix3d ( double  m00,
double  m01,
double  m02,
double  m10,
double  m11,
double  m12,
double  m20,
double  m21,
double  m22 
)
inline

This constructor creates a matrix from its components, where mij specifies the component for row i and column j.

Definition at line 45 of file Matrix3d.h.

48  {
49  _c[0] = Vector3d(m00, m10, m20);
50  _c[1] = Vector3d(m01, m11, m21);
51  _c[2] = Vector3d(m02, m12, m22);
52  }

◆ Matrix3d() [3/4]

lsst::sphgeom::Matrix3d::Matrix3d ( Vector3d const &  v)
inlineexplicit

This constructor creates a diagonal matrix with diagonal components set to the components of v.

Definition at line 56 of file Matrix3d.h.

56  {
57  _c[0] = Vector3d(v.x(), 0.0, 0.0);
58  _c[1] = Vector3d(0.0, v.y(), 0.0);
59  _c[2] = Vector3d(0.0, 0.0, v.z());
60  }

◆ Matrix3d() [4/4]

lsst::sphgeom::Matrix3d::Matrix3d ( double  s)
inlineexplicit

This constructor returns the identity matrix scaled by s.

Definition at line 63 of file Matrix3d.h.

63  {
64  _c[0] = Vector3d(s, 0.0, 0.0);
65  _c[1] = Vector3d(0.0, s, 0.0);
66  _c[2] = Vector3d(0.0, 0.0, s);
67  }

Member Function Documentation

◆ cwiseProduct()

Matrix3d lsst::sphgeom::Matrix3d::cwiseProduct ( Matrix3d const &  m) const
inline

cwiseProduct returns the component-wise product of this matrix and m.

Definition at line 136 of file Matrix3d.h.

136  {
137  Matrix3d r;
138  for (int i = 0; i < 3; ++i) { r._c[i] = _c[i].cwiseProduct(m._c[i]); }
139  return r;
140  }
int m
Definition: SpanSet.cc:48
Matrix3d()
This constructor creates a zero matrix.
Definition: Matrix3d.h:41
Vector3d cwiseProduct(Vector3d const &v) const
cwiseProduct returns the component-wise product of this vector and v.
Definition: Vector3d.h:150

◆ getColumn()

Vector3d const& lsst::sphgeom::Matrix3d::getColumn ( int  c) const
inline

getColumn returns the c-th matrix column. Bounds are not checked.

Definition at line 87 of file Matrix3d.h.

87 { return _c[c]; }

◆ getNorm()

double lsst::sphgeom::Matrix3d::getNorm ( ) const
inline

getNorm returns the L2 (Frobenius) norm of this matrix.

Definition at line 105 of file Matrix3d.h.

105 { return std::sqrt(getSquaredNorm()); }
double getSquaredNorm() const
getSquaredNorm returns the Frobenius inner product of this matrix with itself.
Definition: Matrix3d.h:102
T sqrt(T... args)

◆ getRow()

Vector3d lsst::sphgeom::Matrix3d::getRow ( int  r) const
inline

getRow returns the r-th matrix row. Bounds are not checked.

Definition at line 82 of file Matrix3d.h.

82  {
83  return Vector3d(getColumn(0)(r), getColumn(1)(r), getColumn(2)(r));
84  }
Vector3d const & getColumn(int c) const
getColumn returns the c-th matrix column. Bounds are not checked.
Definition: Matrix3d.h:87

◆ getSquaredNorm()

double lsst::sphgeom::Matrix3d::getSquaredNorm ( ) const
inline

getSquaredNorm returns the Frobenius inner product of this matrix with itself.

Definition at line 102 of file Matrix3d.h.

102 { return inner(*this); }
double inner(Matrix3d const &m) const
inner returns the Frobenius inner product of this matrix with m.
Definition: Matrix3d.h:94

◆ inner()

double lsst::sphgeom::Matrix3d::inner ( Matrix3d const &  m) const
inline

inner returns the Frobenius inner product of this matrix with m.

Definition at line 94 of file Matrix3d.h.

94  {
95  Matrix3d p = cwiseProduct(m);
96  Vector3d sum = p._c[0] + p._c[1] + p._c[2];
97  return sum(0) + sum(1) + sum(2);
98  }
Matrix3d cwiseProduct(Matrix3d const &m) const
cwiseProduct returns the component-wise product of this matrix and m.
Definition: Matrix3d.h:136

◆ inverse()

Matrix3d lsst::sphgeom::Matrix3d::inverse ( ) const
inline

inverse returns the inverse of this matrix.

Definition at line 152 of file Matrix3d.h.

152  {
153  Matrix3d inv;
154  Matrix3d const & m = *this;
155  // Find the first column of Adj(m), the adjugate matrix of m.
156  Vector3d a0(m(1, 1) * m(2, 2) - m(2, 1) * m(1, 2),
157  m(1, 2) * m(2, 0) - m(2, 2) * m(1, 0),
158  m(1, 0) * m(2, 1) - m(2, 0) * m(1, 1));
159  // Find 1.0/det(m), where the determinant of m is the dot product of
160  // the first row of m with the first column of Adj(m).
161  double rdet = 1.0 / (a0(0) * m(0,0) + a0(1) * m(0,1) + a0(2) * m(0,2));
162  // The inverse of m is Adj(m)/det(m); compute it column by column.
163  inv._c[0] = a0 * rdet;
164  inv._c[1] = Vector3d((m(0, 2) * m(2, 1) - m(2, 2) * m(0, 1)) * rdet,
165  (m(0, 0) * m(2, 2) - m(2, 0) * m(0, 2)) * rdet,
166  (m(0, 1) * m(2, 0) - m(2, 1) * m(0, 0)) * rdet);
167  inv._c[2] = Vector3d((m(0, 1) * m(1, 2) - m(1, 1) * m(0, 2)) * rdet,
168  (m(0, 2) * m(1, 0) - m(1, 2) * m(0, 0)) * rdet,
169  (m(0, 0) * m(1, 1) - m(1, 0) * m(0, 1)) * rdet);
170  return inv;
171  }

◆ operator!=()

bool lsst::sphgeom::Matrix3d::operator!= ( Matrix3d const &  m) const
inline

Definition at line 75 of file Matrix3d.h.

75  {
76  return _c[0] != m._c[0] ||
77  _c[1] != m._c[1] ||
78  _c[2] != m._c[2];
79  }

◆ operator()()

double lsst::sphgeom::Matrix3d::operator() ( int  r,
int  c 
) const
inline

The function call operator returns the scalar at row r and column c.

Bounds are not checked.

Definition at line 91 of file Matrix3d.h.

91 { return getColumn(c)(r); }

◆ operator*() [1/2]

Matrix3d lsst::sphgeom::Matrix3d::operator* ( Matrix3d const &  m) const
inline

The multiplication operator returns the product of this matrix with matrix m.

Definition at line 115 of file Matrix3d.h.

115  {
116  Matrix3d r;
117  for (int i = 0; i < 3; ++i) { r._c[i] = this->operator*(m._c[i]); }
118  return r;
119  }
Vector3d operator*(Vector3d const &v) const
The multiplication operator returns the product of this matrix with vector v.
Definition: Matrix3d.h:109

◆ operator*() [2/2]

Vector3d lsst::sphgeom::Matrix3d::operator* ( Vector3d const &  v) const
inline

The multiplication operator returns the product of this matrix with vector v.

Definition at line 109 of file Matrix3d.h.

109  {
110  return Vector3d(_c[0] * v(0) + _c[1] * v(1) + _c[2] * v(2));
111  }

◆ operator+()

Matrix3d lsst::sphgeom::Matrix3d::operator+ ( Matrix3d const &  m) const
inline

The addition operator returns the sum of this matrix and m.

Definition at line 122 of file Matrix3d.h.

122  {
123  Matrix3d r;
124  for (int i = 0; i < 3; ++i) { r._c[i] = _c[i] + m._c[i]; }
125  return r;
126  }

◆ operator-()

Matrix3d lsst::sphgeom::Matrix3d::operator- ( Matrix3d const &  m) const
inline

The subtraction operator returns the difference between this matrix and m.

Definition at line 129 of file Matrix3d.h.

129  {
130  Matrix3d r;
131  for (int i = 0; i < 3; ++i) { r._c[i] = _c[i] - m._c[i]; }
132  return r;
133  }

◆ operator==()

bool lsst::sphgeom::Matrix3d::operator== ( Matrix3d const &  m) const
inline

Definition at line 69 of file Matrix3d.h.

69  {
70  return _c[0] == m._c[0] &&
71  _c[1] == m._c[1] &&
72  _c[2] == m._c[2];
73  }

◆ transpose()

Matrix3d lsst::sphgeom::Matrix3d::transpose ( ) const
inline

transpose returns the transpose of this matrix.

Definition at line 143 of file Matrix3d.h.

143  {
144  Matrix3d t;
145  t._c[0] = Vector3d(_c[0].x(), _c[1].x(), _c[2].x());
146  t._c[1] = Vector3d(_c[0].y(), _c[1].y(), _c[2].y());
147  t._c[2] = Vector3d(_c[0].z(), _c[1].z(), _c[2].z());
148  return t;
149  }
double x
double z
Definition: Match.cc:44
int y
Definition: SpanSet.cc:48

The documentation for this class was generated from the following file: