Jpp  15.0.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
JMATH::JMatrix2D Class Reference

2 x 2 matrix More...

#include <JMatrix2D.hh>

Inheritance diagram for JMATH::JMatrix2D:
JMATH::JMath< JMatrix2D > JLANG::JEquals< JFirst_t, JSecond_t > JGEOMETRY2D::JRotation2D JMATH::JMatrix2S JGEOMETRY3D::JRotation3X JGEOMETRY3D::JRotation3Y JGEOMETRY3D::JRotation3Z

Public Member Functions

 JMatrix2D ()
 Default constructor. More...
 
 JMatrix2D (const double __a00, const double __a01, const double __a10, const double __a11)
 Contructor. More...
 
JMatrix2DsetIdentity ()
 Set to identity matrix. More...
 
void set (const JMatrix2D &A)
 Set matrix. More...
 
JMatrix2Dreset ()
 Set matrix to the null matrix. More...
 
JMatrix2Dtranspose ()
 Transpose. More...
 
JMatrix2Dnegate ()
 Negate matrix. More...
 
JMatrix2Dadd (const JMatrix2D &A)
 Matrix addition. More...
 
JMatrix2Dsub (const JMatrix2D &A)
 Matrix subtraction. More...
 
JMatrix2Dmul (const double factor)
 Scale matrix. More...
 
JMatrix2Ddiv (const double factor)
 Scale matrix. More...
 
JMatrix2Dmul (const JMatrix2D &A, const JMatrix2D &B)
 Matrix multiplication. More...
 
bool equals (const JMatrix2D &A, const double eps=std::numeric_limits< double >::min()) const
 Equality. More...
 
bool isIdentity (const double eps=std::numeric_limits< double >::min()) const
 Test identity. More...
 
double getDeterminant () const
 Get determinant of matrix. More...
 
void transform (double &__x, double &__y) const
 Transform. More...
 
JMatrix2Dmul (const JNullType &object)
 Multiply with object. More...
 

Static Public Member Functions

static const JMatrix2DgetInstance ()
 Get reference to unique instance of this class object. More...
 
static const JMatrix2DgetIdentity ()
 Get reference to unique instance of this class object. More...
 

Public Attributes

double a00
 
double a01
 
double a10
 
double a11
 

Friends

JReaderoperator>> (JReader &in, JMatrix2D &matrix)
 Read matrix from input. More...
 
JWriteroperator<< (JWriter &out, const JMatrix2D &matrix)
 Write matrix to output. More...
 
std::ostream & operator<< (std::ostream &out, const JMatrix2D &A)
 Print ASCII formatted output. More...
 

Detailed Description

2 x 2 matrix

Definition at line 32 of file JMath/JMatrix2D.hh.

Constructor & Destructor Documentation

JMATH::JMatrix2D::JMatrix2D ( )
inline

Default constructor.

Definition at line 44 of file JMath/JMatrix2D.hh.

44  :
45  a00(0.0), a01(0.0),
46  a10(0.0), a11(0.0)
47  {}
JMATH::JMatrix2D::JMatrix2D ( const double  __a00,
const double  __a01,
const double  __a10,
const double  __a11 
)
inline

Contructor.

Parameters
__a00(0,0)
__a01(0,1)
__a10(1,0)
__a11(1,1)

Definition at line 58 of file JMath/JMatrix2D.hh.

59  :
60  a00(__a00), a01(__a01),
61  a10(__a10), a11(__a11)
62  {}

Member Function Documentation

static const JMatrix2D& JMATH::JMatrix2D::getInstance ( )
inlinestatic

Get reference to unique instance of this class object.

Returns
zero matrix

Definition at line 70 of file JMath/JMatrix2D.hh.

71  {
72  static JMatrix2D matrix;
73 
74  return matrix;
75  }
2 x 2 matrix
JMatrix2D& JMATH::JMatrix2D::setIdentity ( )
inline

Set to identity matrix.

Returns
this matrix

Definition at line 83 of file JMath/JMatrix2D.hh.

84  {
85  a00 = 1.0; a01 = 0.0;
86  a10 = 0.0; a11 = 1.0;
87 
88  return *this;
89  }
static const JMatrix2D& JMATH::JMatrix2D::getIdentity ( )
inlinestatic

Get reference to unique instance of this class object.

Returns
identity matrix

Definition at line 97 of file JMath/JMatrix2D.hh.

98  {
99  static JMatrix2D matrix(JMatrix2D().setIdentity());
100 
101  return matrix;
102  }
JMatrix2D()
Default constructor.
2 x 2 matrix
JMatrix2D & setIdentity()
Set to identity matrix.
void JMATH::JMatrix2D::set ( const JMatrix2D A)
inline

Set matrix.

Parameters
Amatrix

Definition at line 110 of file JMath/JMatrix2D.hh.

111  {
112  static_cast<JMatrix2D&>(*this) = A;
113  }
2 x 2 matrix
source $JPP_DIR setenv csh $JPP_DIR eval JShellParser o a A
JMatrix2D& JMATH::JMatrix2D::reset ( )
inline

Set matrix to the null matrix.

Returns
this matrix

Definition at line 121 of file JMath/JMatrix2D.hh.

122  {
123  *this = JMatrix2D();
124 
125  return *this;
126  }
JMatrix2D()
Default constructor.
JMatrix2D& JMATH::JMatrix2D::transpose ( )
inline

Transpose.

Returns
this matrix

Definition at line 134 of file JMath/JMatrix2D.hh.

135  {
136  using std::swap;
137 
138  swap(a10, a01);
139 
140  return *this;
141  }
JMatrix2D& JMATH::JMatrix2D::negate ( )
inline

Negate matrix.

Returns
-this matrix

Definition at line 149 of file JMath/JMatrix2D.hh.

150  {
151  a00 = -a00; a01 = -a01;
152  a10 = -a10; a11 = -a11;
153 
154  return *this;
155  }
JMatrix2D& JMATH::JMatrix2D::add ( const JMatrix2D A)
inline

Matrix addition.

Parameters
Amatrix
Returns
this matrix + A

Definition at line 164 of file JMath/JMatrix2D.hh.

165  {
166  a00 += A.a00; a01 += A.a01;
167  a10 += A.a10; a11 += A.a11;
168 
169  return *this;
170  }
JMatrix2D& JMATH::JMatrix2D::sub ( const JMatrix2D A)
inline

Matrix subtraction.

Parameters
Amatrix
Returns
this matrix - A

Definition at line 179 of file JMath/JMatrix2D.hh.

180  {
181  a00 -= A.a00; a01 -= A.a01;
182  a10 -= A.a10; a11 -= A.a11;
183 
184  return *this;
185  }
JMatrix2D& JMATH::JMatrix2D::mul ( const double  factor)
inline

Scale matrix.

Parameters
factorfactor
Returns
this matrix * factor

Definition at line 194 of file JMath/JMatrix2D.hh.

195  {
196  a00 *= factor; a01 *= factor;
197  a10 *= factor; a11 *= factor;
198 
199  return *this;
200  }
JMatrix2D& JMATH::JMatrix2D::div ( const double  factor)
inline

Scale matrix.

Parameters
factorfactor
Returns
this matrix / factor

Definition at line 209 of file JMath/JMatrix2D.hh.

210  {
211  a00 /= factor; a01 /= factor;
212  a10 /= factor; a11 /= factor;
213 
214  return *this;
215  }
JMatrix2D& JMATH::JMatrix2D::mul ( const JMatrix2D A,
const JMatrix2D B 
)
inline

Matrix multiplication.

Parameters
Amatrix
Bmatrix
Returns
this matrix

Definition at line 225 of file JMath/JMatrix2D.hh.

227  {
228  a00 = A.a00 * B.a00 + A.a01 * B.a10;
229  a01 = A.a00 * B.a01 + A.a01 * B.a11;
230 
231  a10 = A.a10 * B.a00 + A.a11 * B.a10;
232  a11 = A.a10 * B.a01 + A.a11 * B.a11;
233 
234  return *this;
235  }
bool JMATH::JMatrix2D::equals ( const JMatrix2D A,
const double  eps = std::numeric_limits<double>::min() 
) const
inline

Equality.

Parameters
Amatrix
epsnumerical precision
Returns
true if matrices identical; else false

Definition at line 245 of file JMath/JMatrix2D.hh.

247  {
248  return (fabs(a00 - A.a00) <= eps &&
249  fabs(a01 - A.a01) <= eps &&
250  fabs(a10 - A.a10) <= eps &&
251  fabs(a11 - A.a11) <= eps);
252  }
bool JMATH::JMatrix2D::isIdentity ( const double  eps = std::numeric_limits<double>::min()) const
inline

Test identity.

Parameters
epsnumerical precision
Returns
true if identity matrix; else false

Definition at line 261 of file JMath/JMatrix2D.hh.

262  {
263  return equals(getIdentity(), eps);
264  }
static const JMatrix2D & getIdentity()
Get reference to unique instance of this class object.
bool equals(const JMatrix2D &A, const double eps=std::numeric_limits< double >::min()) const
Equality.
double JMATH::JMatrix2D::getDeterminant ( ) const
inline

Get determinant of matrix.

Returns
determinant of matrix

Definition at line 272 of file JMath/JMatrix2D.hh.

273  {
274  return a00 * a11 - a01 * a10;
275  }
void JMATH::JMatrix2D::transform ( double &  __x,
double &  __y 
) const
inline

Transform.

Parameters
__xx value
__yy value

Definition at line 284 of file JMath/JMatrix2D.hh.

285  {
286  const double x = a00 * __x + a01 * __y;
287  const double y = a10 * __x + a11 * __y;
288 
289  __x = x;
290  __y = y;
291  }
JMatrix2D & JMATH::JMath< JMatrix2D , JNullType >::mul ( const JNullType object)
inlineinherited

Multiply with object.

Parameters
objectobject
Returns
result object

Definition at line 357 of file JMath.hh.

358  {
359  return static_cast<JFirst_t&>(*this) = JCalculator<JFirst_t>::calculator.mul(static_cast<const JFirst_t&>(*this), object);
360  }
Auxiliary class for arithmetic operations on objects.
Definition: JCalculator.hh:18

Friends And Related Function Documentation

JReader& operator>> ( JReader in,
JMatrix2D matrix 
)
friend

Read matrix from input.

Parameters
inreader
matrixmatrix
Returns
reader

Definition at line 301 of file JMath/JMatrix2D.hh.

302  {
303  in >> matrix.a00; in >> matrix.a01;
304  in >> matrix.a10; in >> matrix.a11;
305 
306  return in;
307  }
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:41
JWriter& operator<< ( JWriter out,
const JMatrix2D matrix 
)
friend

Write matrix to output.

Parameters
outwriter
matrixmatrix
Returns
writer

Definition at line 317 of file JMath/JMatrix2D.hh.

318  {
319  out << matrix.a00; out << matrix.a01;
320  out << matrix.a10; out << matrix.a11;
321 
322  return out;
323  }
std::ostream& operator<< ( std::ostream &  out,
const JMatrix2D A 
)
friend

Print ASCII formatted output.

Parameters
outoutput stream
Amatrix
Returns
output stream

Definition at line 333 of file JMath/JMatrix2D.hh.

334  {
335  using namespace std;
336 
337  const JFormat format(out, getFormat<JMatrix2D>(JFormat_t(10, 3, std::ios::fixed | std::ios::showpos)));
338 
339  out << format << A.a00 << ' ' << format << A.a01 << endl;
340  out << format << A.a10 << ' ' << format << A.a11 << endl;
341 
342  return out;
343  }
Auxiliary class to temporarily define format specifications.
Definition: JManip.hh:632
Data structure for format specifications.
Definition: JManip.hh:522

Member Data Documentation

double JMATH::JMatrix2D::a00

Definition at line 346 of file JMath/JMatrix2D.hh.

double JMATH::JMatrix2D::a01

Definition at line 346 of file JMath/JMatrix2D.hh.

double JMATH::JMatrix2D::a10

Definition at line 347 of file JMath/JMatrix2D.hh.

double JMATH::JMatrix2D::a11

Definition at line 347 of file JMath/JMatrix2D.hh.


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