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

NxN matrix. More...

#include <JMatrixND.hh>

Inheritance diagram for JMATH::JMatrixND:
JMATH::JMatrixND_t JMATH::JMath< JMatrixND > JLANG::JEquals< JFirst_t, JSecond_t > JLANG::JSingleton< T > JMATH::JMatrixNS JFIT::JMatrixNZ

Public Types

typedef T data_type
 

Public Member Functions

 JMatrixND ()
 Default constructor. More...
 
 JMatrixND (const size_t size)
 Constructor. More...
 
 JMatrixND (const JMatrixND &A)
 Copy constructor. More...
 
 JMatrixND (JMatrixND &&A)
 Move constructor. More...
 
JMatrixNDoperator= (const JMatrixND &A)
 Assignment operator. More...
 
JMatrixNDoperator= (JMatrixND &&A)
 Move assignment operator. More...
 
void resize (const size_t size)
 Resize matrix. More...
 
JMatrixNDreset ()
 Set matrix to the null matrix. More...
 
JMatrixNDsetIdentity ()
 Set to identity matrix. More...
 
JMatrixNDnegate ()
 Negate matrix. More...
 
JMatrixNDadd (const JMatrixND &A)
 Matrix addition. More...
 
JMatrixNDsub (const JMatrixND &A)
 Matrix subtraction. More...
 
JMatrixNDmul (const double factor)
 Scale matrix. More...
 
JMatrixNDdiv (const double factor)
 Scale matrix. More...
 
JMatrixNDmul (const JMatrixND &A, const JMatrixND &B)
 Matrix multiplication. More...
 
bool equals (const JMatrixND &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...
 
bool isSymmetric (const double eps=std::numeric_limits< double >::min()) const
 Test symmetry. More...
 
double getDot (const JVectorND &v) const
 Get dot product. More...
 
void clear ()
 Clear memory. More...
 
void set (const JMatrixND_t &A)
 Set matrix. More...
 
void swap (JMatrixND_t &A)
 Swap matrices. More...
 
JMatrixND_ttranspose ()
 Transpose. More...
 
size_t size () const
 Get dimension of matrix. More...
 
size_t capacity () const
 Get capacity of dimension. More...
 
bool empty () const
 Check emptyness. More...
 
const double * data () const
 Get pointer to data. More...
 
double * data ()
 Get pointer to data. More...
 
const double * operator[] (size_t row) const
 Get row data. More...
 
double * operator[] (size_t row)
 Get row data. More...
 
double operator() (const size_t row, const size_t col) const
 Get matrix element. More...
 
double & operator() (const size_t row, const size_t col)
 Get matrix element. More...
 
double at (size_t row, size_t col) const
 Get matrix element. More...
 
double & at (size_t row, size_t col)
 Get matrix element. More...
 
JMatrixNDmul (const JNullType &object)
 Multiply with object. More...
 

Static Public Member Functions

static data_typegetInstance ()
 Get unique instance of template class. More...
 

Protected Member Functions

void rswap (size_t r1, size_t r2)
 
void cswap (size_t c1, size_t c2)
 Swap columns. More...
 

Protected Attributes

double * __p
 pointer to data More...
 
size_t __n
 dimension of matrix More...
 
size_t __m
 capacity of matrix More...
 

Friends

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

Detailed Description

NxN matrix.

Definition at line 327 of file JMatrixND.hh.

Member Typedef Documentation

template<class T>
typedef T JLANG::JSingleton< T >::data_type
inherited

Definition at line 20 of file JSingleton.hh.

Constructor & Destructor Documentation

JMATH::JMatrixND::JMatrixND ( )
inline

Default constructor.

Definition at line 337 of file JMatrixND.hh.

338  {}
JMATH::JMatrixND::JMatrixND ( const size_t  size)
inline

Constructor.

The matrix is set to zero.

Parameters
sizedimension

Definition at line 348 of file JMatrixND.hh.

349  {
350  resize(size);
351  reset();
352  }
JMatrixND & reset()
Set matrix to the null matrix.
Definition: JMatrixND.hh:423
void resize(const size_t size)
Resize matrix.
Definition: JMatrixND.hh:410
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:181
JMATH::JMatrixND::JMatrixND ( const JMatrixND A)
inline

Copy constructor.

Parameters
Amatrix

Definition at line 360 of file JMatrixND.hh.

361  {
362  set(A);
363  }
void set(const JMatrixND_t &A)
Set matrix.
Definition: JMatrixND.hh:134
JMATH::JMatrixND::JMatrixND ( JMatrixND &&  A)
inline

Move constructor.

Parameters
Amatrix

Definition at line 371 of file JMatrixND.hh.

372  {
373  swap(A);
374  }
void swap(JMatrixND_t &A)
Swap matrices.
Definition: JMatrixND.hh:147

Member Function Documentation

JMatrixND& JMATH::JMatrixND::operator= ( const JMatrixND A)
inline

Assignment operator.

Parameters
Amatrix

Definition at line 382 of file JMatrixND.hh.

383  {
384  this->set(A);
385 
386  return *this;
387  }
void set(const JMatrixND_t &A)
Set matrix.
Definition: JMatrixND.hh:134
JMatrixND& JMATH::JMatrixND::operator= ( JMatrixND &&  A)
inline

Move assignment operator.

Parameters
Amatrix

Definition at line 395 of file JMatrixND.hh.

396  {
397  this->swap(A);
398 
399  return *this;
400  }
void swap(JMatrixND_t &A)
Swap matrices.
Definition: JMatrixND.hh:147
void JMATH::JMatrixND::resize ( const size_t  size)
inline

Resize matrix.

Note that this method does not maintain data in the matrix.

Parameters
sizedimension

Definition at line 410 of file JMatrixND.hh.

411  {
412  static_cast<JMatrixND_t&>(*this).resize(size);
413 
414  getInstance().resize(size);
415  }
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:181
static data_type & getInstance()
Get unique instance of template class.
Definition: JSingleton.hh:27
void resize(const size_t size)
Resize matrix.
Definition: JMatrixND.hh:106
Basic NxN matrix.
Definition: JMatrixND.hh:38
JMatrixND& JMATH::JMatrixND::reset ( )
inline

Set matrix to the null matrix.

Returns
this matrix

Definition at line 423 of file JMatrixND.hh.

424  {
426 
427  double* p = A.data();
428 
429  for (size_t i = this->size(); i != 0; --i, ++p) {
430  *p = 0.0;
431  }
432 
433  p = this->data();
434 
435  for (size_t i = this->size(); i != 0; --i, p += this->size()) {
436  memcpy(p, A.data(), this->size() * sizeof(double));
437  }
438 
439  return *this;
440  }
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:181
static data_type & getInstance()
Get unique instance of template class.
Definition: JSingleton.hh:27
source $JPP_DIR setenv csh $JPP_DIR &dev null eval JShellParser o a A
const double * data() const
Get pointer to data.
Definition: JMatrixND.hh:214
Basic NxN matrix.
Definition: JMatrixND.hh:38
JMatrixND& JMATH::JMatrixND::setIdentity ( )
inline

Set to identity matrix.

Returns
this matrix

Definition at line 448 of file JMatrixND.hh.

449  {
450  reset();
451 
452  for (size_t i = 0; i != this->size(); ++i) {
453  (*this)(i,i) = 1.0;
454  }
455 
456  return *this;
457  }
JMatrixND & reset()
Set matrix to the null matrix.
Definition: JMatrixND.hh:423
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:181
JMatrixND& JMATH::JMatrixND::negate ( )
inline

Negate matrix.

Returns
this matrix

Definition at line 465 of file JMatrixND.hh.

466  {
467  double* p = this->data();
468 
469  for (size_t i = this->size()*this->size(); i != 0; --i, ++p) {
470  *p = -*p;
471  }
472 
473  return *this;
474  }
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:181
const double * data() const
Get pointer to data.
Definition: JMatrixND.hh:214
JMatrixND& JMATH::JMatrixND::add ( const JMatrixND A)
inline

Matrix addition.

Parameters
Amatrix
Returns
this matrix

Definition at line 483 of file JMatrixND.hh.

484  {
485  if (this->size() == A.size()) {
486 
487  double* p = this->data();
488  const double* q = A.data();
489 
490  for (size_t i = this->size()*this->size(); i != 0; --i, ++p, ++q) {
491  *p += *q;
492  }
493 
494  } else {
495  THROW(JException, "JMatrixND::add() inconsistent matrix dimensions " << this->size() << ' ' << A.size());
496  }
497  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:181
const double * data() const
Get pointer to data.
Definition: JMatrixND.hh:214
JMatrixND& JMATH::JMatrixND::sub ( const JMatrixND A)
inline

Matrix subtraction.

Parameters
Amatrix
Returns
this matrix

Definition at line 506 of file JMatrixND.hh.

507  {
508  if (this->size() == A.size()) {
509 
510  double* p = this->data();
511  const double* q = A.data();
512 
513  for (size_t i = this->size()*this->size(); i != 0; --i, ++p, ++q) {
514  *p -= *q;
515  }
516 
517  } else {
518  THROW(JException, "JMatrixND::sub() inconsistent matrix dimensions " << this->size() << ' ' << A.size());
519  }
520 
521  return *this;
522  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:181
const double * data() const
Get pointer to data.
Definition: JMatrixND.hh:214
JMatrixND& JMATH::JMatrixND::mul ( const double  factor)
inline

Scale matrix.

Parameters
factorfactor
Returns
this matrix

Definition at line 531 of file JMatrixND.hh.

532  {
533  double* p = this->data();
534 
535  for (size_t i = this->size()*this->size(); i != 0; --i, ++p) {
536  *p *= factor;
537  }
538 
539  return *this;
540  }
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:181
const double * data() const
Get pointer to data.
Definition: JMatrixND.hh:214
JMatrixND& JMATH::JMatrixND::div ( const double  factor)
inline

Scale matrix.

Parameters
factorfactor
Returns
this matrix

Definition at line 549 of file JMatrixND.hh.

550  {
551  double* p = this->data();
552 
553  for (size_t i = this->size()*this->size(); i != 0; --i, ++p) {
554  *p /= factor;
555  }
556 
557  return *this;
558  }
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:181
const double * data() const
Get pointer to data.
Definition: JMatrixND.hh:214
JMatrixND& JMATH::JMatrixND::mul ( const JMatrixND A,
const JMatrixND B 
)
inline

Matrix multiplication.

Parameters
Amatrix
Bmatrix
Returns
this matrix

Definition at line 568 of file JMatrixND.hh.

570  {
571  if (A.size() == B.size()) {
572 
573  this->resize(A.size());
574 
575  if (!this->empty()) {
576 
578 
579  C.set(B);
580  C.transpose();
581 
582  size_t i, row;
583 
584  for (row = 0; row + 4 <= this->size(); row += 4) { // process rows by four
585 
586  double* p0 = (*this)[row + 0];
587  double* p1 = (*this)[row + 1];
588  double* p2 = (*this)[row + 2];
589  double* p3 = (*this)[row + 3];
590 
591  for (size_t col = 0; col != this->size(); ++col, ++p0, ++p1, ++p2, ++p3) {
592 
593  double w0 = 0.0;
594  double w1 = 0.0;
595  double w2 = 0.0;
596  double w3 = 0.0;
597 
598  const double* a0 = A[row + 0];
599  const double* a1 = A[row + 1];
600  const double* a2 = A[row + 2];
601  const double* a3 = A[row + 3];
602 
603  const double* c0 = C[col];
604 
605  for (i = 0; i + 4 <= this->size(); i += 4, a0 += 4, a1 += 4, a2 += 4, a3 += 4, c0 += 4) {
606  w0 += a0[0] * c0[0] + a0[1] * c0[1] + a0[2] * c0[2] + a0[3] * c0[3];
607  w1 += a1[0] * c0[0] + a1[1] * c0[1] + a1[2] * c0[2] + a1[3] * c0[3];
608  w2 += a2[0] * c0[0] + a2[1] * c0[1] + a2[2] * c0[2] + a2[3] * c0[3];
609  w3 += a3[0] * c0[0] + a3[1] * c0[1] + a3[2] * c0[2] + a3[3] * c0[3];
610  }
611 
612  for ( ; i != this->size(); ++i, ++a0, ++a1, ++a2, ++a3, ++c0) {
613  w0 += (*a0) * (*c0);
614  w1 += (*a1) * (*c0);
615  w2 += (*a2) * (*c0);
616  w3 += (*a3) * (*c0);
617  }
618 
619  *p0 = w0;
620  *p1 = w1;
621  *p2 = w2;
622  *p3 = w3;
623  }
624  }
625 
626  for ( ; row != this->size(); ++row) { // remaining rows
627 
628  double* p0 = (*this)[row + 0];
629 
630  for (size_t col = 0; col != this->size(); ++col, ++p0) {
631 
632  double w0 = 0.0;
633 
634  const double* a0 = A[row + 0];
635  const double* c0 = C[col];
636 
637  for (i = 0; i + 4 <= this->size(); i += 4, a0 += 4, c0 += 4) {
638  w0 += a0[0] * c0[0] + a0[1] * c0[1] + a0[2] * c0[2] + a0[3] * c0[3];
639  }
640 
641  for ( ; i != this->size(); ++i, ++a0, ++c0) {
642  w0 += (*a0) * (*c0);
643  }
644 
645  *p0 = w0;
646  }
647  }
648  }
649 
650  } else {
651  THROW(JException, "JMatrixND::mul() inconsistent matrix dimensions " << A.size() << ' ' << B.size());
652  }
653 
654  return *this;
655  }
TPaveText * p1
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
void resize(const size_t size)
Resize matrix.
Definition: JMatrixND.hh:410
static const double C
Physics constants.
void set(const JMatrixND_t &A)
Set matrix.
Definition: JMatrixND.hh:134
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:181
p2
Definition: module-Z:fit.sh:74
static data_type & getInstance()
Get unique instance of template class.
Definition: JSingleton.hh:27
JMatrixND_t & transpose()
Transpose.
Definition: JMatrixND.hh:162
bool empty() const
Check emptyness.
Definition: JMatrixND.hh:203
p3
Definition: module-Z:fit.sh:74
Basic NxN matrix.
Definition: JMatrixND.hh:38
bool JMATH::JMatrixND::equals ( const JMatrixND 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 665 of file JMatrixND.hh.

667  {
668  if (this->size() == A.size()) {
669 
670  for (size_t row = 0; row != this->size(); ++row) {
671 
672  const double* p = (*this)[row];
673  const double* q = A [row];
674 
675  for (size_t i = this->size(); i != 0; --i, ++p, ++q) {
676  if (fabs(*p - *q) > eps) {
677  return false;
678  }
679  }
680  }
681 
682  return true;
683 
684  } else {
685  THROW(JException, "JMatrixND::equals() inconsistent matrix dimensions " << this->size() << ' ' << A.size());
686  }
687  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:181
bool JMATH::JMatrixND::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 696 of file JMatrixND.hh.

697  {
698  for (size_t i = 0; i != this->size(); ++i) {
699 
700  if (fabs(1.0 - (*this)(i,i)) > eps) {
701  return false;
702  };
703 
704  for (size_t j = 0; j != i; ++j) {
705  if (fabs((*this)(i,j)) > eps || fabs((*this)(j,i)) > eps) {
706  return false;
707  };
708  }
709  }
710 
711  return true;
712  }
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:181
int j
Definition: JPolint.hh:703
bool JMATH::JMatrixND::isSymmetric ( const double  eps = std::numeric_limits<double>::min()) const
inline

Test symmetry.

Parameters
epsnumerical precision
Returns
true if symmetric matrix; else false

Definition at line 721 of file JMatrixND.hh.

722  {
723  for (size_t i = 0; i != this->size(); ++i) {
724  for (size_t j = 0; j != i; ++j) {
725  if (fabs((*this)(i,j) - (*this)(j,i)) > eps) {
726  return false;
727  };
728  }
729  }
730 
731  return true;
732  }
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:181
int j
Definition: JPolint.hh:703
double JMATH::JMatrixND::getDot ( const JVectorND v) const
inline

Get dot product.

The dot product corresponds to

\[ v^{T} \times A \times v \]

.

Parameters
vvector
Returns
dot product

Definition at line 743 of file JMatrixND.hh.

744  {
745  double dot = 0.0;
746 
747  for (size_t i = 0; i != v.size(); ++i) {
748 
749  const double* p = (*this)[i];
750 
751  double w = 0.0;
752 
753  for (JVectorND::const_iterator y = v.begin(); y != v.end(); ++y, ++p) {
754  w += (*p) * (*y);
755  }
756 
757  dot += v[i] * w;
758  }
759 
760  return dot;
761  }
data_type w[N+1][M+1]
Definition: JPolint.hh:778
void JMATH::JMatrixND::rswap ( size_t  r1,
size_t  r2 
)
inlineprotected

Definition at line 843 of file JMatrixND.hh.

844  {
846 
847  memcpy(A.data(), (*this)[r1], this->size() * sizeof(double));
848  memcpy((*this)[r1], (*this)[r2], this->size() * sizeof(double));
849  memcpy((*this)[r2], A.data(), this->size() * sizeof(double));
850  }
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:181
static data_type & getInstance()
Get unique instance of template class.
Definition: JSingleton.hh:27
source $JPP_DIR setenv csh $JPP_DIR &dev null eval JShellParser o a A
const double * data() const
Get pointer to data.
Definition: JMatrixND.hh:214
Basic NxN matrix.
Definition: JMatrixND.hh:38
void JMATH::JMatrixND::cswap ( size_t  c1,
size_t  c2 
)
inlineprotected

Swap columns.

Parameters
c1column
c2column

Definition at line 859 of file JMatrixND.hh.

860  {
861  using std::swap;
862 
863  double* p1 = this->data() + c1;
864  double* p2 = this->data() + c2;
865 
866  for (size_t i = this->size(); i != 0; --i, p1 += this->size(), p2 += this->size()) {
867  swap(*p1, *p2);
868  }
869  }
TPaveText * p1
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:181
TCanvas * c1
Global variables to handle mouse events.
p2
Definition: module-Z:fit.sh:74
void swap(JMatrixND_t &A)
Swap matrices.
Definition: JMatrixND.hh:147
const double * data() const
Get pointer to data.
Definition: JMatrixND.hh:214
void JMATH::JMatrixND_t::clear ( )
inlineinherited

Clear memory.

Definition at line 87 of file JMatrixND.hh.

88  {
89  if (__p != NULL) {
90  delete [] __p;
91  }
92 
93  __p = NULL;
94  __n = 0;
95  __m = 0;
96  }
size_t __n
dimension of matrix
Definition: JMatrixND.hh:319
double * __p
pointer to data
Definition: JMatrixND.hh:318
size_t __m
capacity of matrix
Definition: JMatrixND.hh:320
void JMATH::JMatrixND_t::set ( const JMatrixND_t A)
inlineinherited

Set matrix.

Parameters
Amatrix

Definition at line 134 of file JMatrixND.hh.

135  {
136  this->resize(A.size());
137 
138  memcpy(this->data(), A.data(), A.size() * A.size() * sizeof(double));
139  }
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:181
void resize(const size_t size)
Resize matrix.
Definition: JMatrixND.hh:106
const double * data() const
Get pointer to data.
Definition: JMatrixND.hh:214
void JMATH::JMatrixND_t::swap ( JMatrixND_t A)
inlineinherited

Swap matrices.

Parameters
Amatrix

Definition at line 147 of file JMatrixND.hh.

148  {
149  using std::swap;
150 
151  swap(this->__p, A.__p);
152  swap(this->__n, A.__n);
153  swap(this->__m, A.__m);
154  }
size_t __n
dimension of matrix
Definition: JMatrixND.hh:319
double * __p
pointer to data
Definition: JMatrixND.hh:318
void swap(JMatrixND_t &A)
Swap matrices.
Definition: JMatrixND.hh:147
size_t __m
capacity of matrix
Definition: JMatrixND.hh:320
JMatrixND_t& JMATH::JMatrixND_t::transpose ( )
inlineinherited

Transpose.

Returns
this matrix

Definition at line 162 of file JMatrixND.hh.

163  {
164  using std::swap;
165 
166  for (size_t row = 0; row != this->size(); ++row) {
167  for (size_t col = 0; col != row; ++col) {
168  swap((*this)(row,col), (*this)(col,row));
169  }
170  }
171 
172  return *this;
173  }
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:181
void swap(JMatrixND_t &A)
Swap matrices.
Definition: JMatrixND.hh:147
size_t JMATH::JMatrixND_t::size ( ) const
inlineinherited

Get dimension of matrix.

Returns
dimension

Definition at line 181 of file JMatrixND.hh.

182  {
183  return __n;
184  }
size_t __n
dimension of matrix
Definition: JMatrixND.hh:319
size_t JMATH::JMatrixND_t::capacity ( ) const
inlineinherited

Get capacity of dimension.

Returns
capacity

Definition at line 192 of file JMatrixND.hh.

193  {
194  return __m;
195  }
size_t __m
capacity of matrix
Definition: JMatrixND.hh:320
bool JMATH::JMatrixND_t::empty ( ) const
inlineinherited

Check emptyness.

Returns
true if empty; else false

Definition at line 203 of file JMatrixND.hh.

204  {
205  return __n == 0;
206  }
size_t __n
dimension of matrix
Definition: JMatrixND.hh:319
const double* JMATH::JMatrixND_t::data ( ) const
inlineinherited

Get pointer to data.

Returns
pointer to data.

Definition at line 214 of file JMatrixND.hh.

215  {
216  return __p;
217  }
double * __p
pointer to data
Definition: JMatrixND.hh:318
double* JMATH::JMatrixND_t::data ( )
inlineinherited

Get pointer to data.

Returns
pointer to data.

Definition at line 225 of file JMatrixND.hh.

226  {
227  return __p;
228  }
double * __p
pointer to data
Definition: JMatrixND.hh:318
const double* JMATH::JMatrixND_t::operator[] ( size_t  row) const
inlineinherited

Get row data.

Parameters
rowrow number
Returns
pointer to row data

Definition at line 237 of file JMatrixND.hh.

238  {
239  return __p + row*__n;
240  }
size_t __n
dimension of matrix
Definition: JMatrixND.hh:319
double * __p
pointer to data
Definition: JMatrixND.hh:318
double* JMATH::JMatrixND_t::operator[] ( size_t  row)
inlineinherited

Get row data.

Parameters
rowrow number
Returns
pointer to row data

Definition at line 249 of file JMatrixND.hh.

250  {
251  return __p + row*__n;
252  }
size_t __n
dimension of matrix
Definition: JMatrixND.hh:319
double * __p
pointer to data
Definition: JMatrixND.hh:318
double JMATH::JMatrixND_t::operator() ( const size_t  row,
const size_t  col 
) const
inlineinherited

Get matrix element.

Parameters
rowrow number
colcolumn number
Returns
matrix element at (row,col)

Definition at line 262 of file JMatrixND.hh.

263  {
264  return *(__p + row*__n + col);
265  }
size_t __n
dimension of matrix
Definition: JMatrixND.hh:319
double * __p
pointer to data
Definition: JMatrixND.hh:318
double& JMATH::JMatrixND_t::operator() ( const size_t  row,
const size_t  col 
)
inlineinherited

Get matrix element.

Parameters
rowrow number
colcolumn number
Returns
matrix element at (row,col)

Definition at line 275 of file JMatrixND.hh.

276  {
277  return *(__p + row*__n + col);
278  }
size_t __n
dimension of matrix
Definition: JMatrixND.hh:319
double * __p
pointer to data
Definition: JMatrixND.hh:318
double JMATH::JMatrixND_t::at ( size_t  row,
size_t  col 
) const
inlineinherited

Get matrix element.

Parameters
rowrow number
colcolumn number
Returns
matrix element at (row,col)

Definition at line 288 of file JMatrixND.hh.

289  {
290  if (row >= this->size() ||
291  col >= this->size()) {
292  THROW(JIndexOutOfRange, "JMatrixND::at(" << row << "," << col << "): index out of range.");
293  }
294 
295  return (*this)(row, col);
296  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:181
double& JMATH::JMatrixND_t::at ( size_t  row,
size_t  col 
)
inlineinherited

Get matrix element.

Parameters
rowrow number
colcolumn number
Returns
matrix element at (row,col)

Definition at line 306 of file JMatrixND.hh.

307  {
308  if (row >= this->size() ||
309  col >= this->size()) {
310  THROW(JIndexOutOfRange, "JMatrixND::at(" << row << "," << col << "): index out of range.");
311  }
312 
313  return (*this)(row, col);
314  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:181
template<class T>
static data_type& JLANG::JSingleton< T >::getInstance ( )
inlinestaticinherited

Get unique instance of template class.

Returns
object

Definition at line 27 of file JSingleton.hh.

28  {
29  static data_type value;
30 
31  return value;
32  }
JMatrixND & JMATH::JMath< JMatrixND , 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,
JMatrixND A 
)
friend

Read matrix from input.

Parameters
inreader
Amatrix
Returns
reader

Definition at line 771 of file JMatrixND.hh.

772  {
773  size_t size;
774 
775  in >> size;
776 
777  A.resize(size);
778 
779  size_t n = A.size() * A.size();
780 
781  for (double* p = A.data(); n != 0; --n, ++p) {
782  in >> *p;
783  }
784 
785  return in;
786  }
void resize(const size_t size)
Resize matrix.
Definition: JMatrixND.hh:410
const int n
Definition: JPolint.hh:697
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:181
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 JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
const double * data() const
Get pointer to data.
Definition: JMatrixND.hh:214
JWriter& operator<< ( JWriter out,
const JMatrixND A 
)
friend

Write matrix to output.

Parameters
outwriter
Amatrix
Returns
writer

Definition at line 796 of file JMatrixND.hh.

797  {
798  out << A.size();
799 
800  size_t n = A.size() * A.size();
801 
802  for (const double* p = A.data(); n != 0; --n, ++p) {
803  out << *p;
804  }
805 
806  return out;
807  }
const int n
Definition: JPolint.hh:697
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:181
const double * data() const
Get pointer to data.
Definition: JMatrixND.hh:214
std::ostream& operator<< ( std::ostream &  out,
const JMatrixND A 
)
friend

Print ASCII formatted output.

Parameters
outoutput stream
Amatrix
Returns
output stream

Definition at line 817 of file JMatrixND.hh.

818  {
819  using namespace std;
820 
821  const JFormat format(out, getFormat<JMatrixND>(JFormat_t(10, 3, std::ios::fixed | std::ios::showpos)));
822 
823  for (size_t row = 0; row != A.size(); ++row) {
824 
825  for (size_t col = 0; col != A.size(); ++col) {
826  out << format << A(row,col) << ' ';
827  }
828 
829  out << endl;
830  }
831 
832  return out;
833  }
Auxiliary class to temporarily define format specifications.
Definition: JManip.hh:632
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:181
source $JPP_DIR setenv csh $JPP_DIR &dev null eval JShellParser o a A
Data structure for format specifications.
Definition: JManip.hh:522

Member Data Documentation

double* JMATH::JMatrixND_t::__p
protectedinherited

pointer to data

Definition at line 318 of file JMatrixND.hh.

size_t JMATH::JMatrixND_t::__n
protectedinherited

dimension of matrix

Definition at line 319 of file JMatrixND.hh.

size_t JMATH::JMatrixND_t::__m
protectedinherited

capacity of matrix

Definition at line 320 of file JMatrixND.hh.


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