Jpp  18.2.1-ARCA-DF-PATCH
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 > JMATH::JMatrixNS JFIT::JMatrixNZ

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...
 

Protected Member Functions

JMatrixND_tgetInstance ()
 Get work space. More...
 
void rswap (size_t r1, size_t r2)
 
void cswap (size_t c1, size_t c2)
 Swap columns. More...
 

Protected Attributes

JMatrixND_t ws
 
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 345 of file JMatrixND.hh.

Constructor & Destructor Documentation

JMATH::JMatrixND::JMatrixND ( )
inline

Default constructor.

Definition at line 370 of file JMatrixND.hh.

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

Constructor.

The matrix is set to zero.

Parameters
sizedimension

Definition at line 381 of file JMatrixND.hh.

382  {
383  resize(size);
384  reset();
385  }
JMatrixND & reset()
Set matrix to the null matrix.
Definition: JMatrixND.hh:456
void resize(const size_t size)
Resize matrix.
Definition: JMatrixND.hh:443
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:199
JMATH::JMatrixND::JMatrixND ( const JMatrixND A)
inline

Copy constructor.

Parameters
Amatrix

Definition at line 393 of file JMatrixND.hh.

394  {
395  set(A);
396  }
void set(const JMatrixND_t &A)
Set matrix.
Definition: JMatrixND.hh:152
JMATH::JMatrixND::JMatrixND ( JMatrixND &&  A)
inline

Move constructor.

Parameters
Amatrix

Definition at line 404 of file JMatrixND.hh.

405  {
406  swap(A);
407  }
void swap(JMatrixND_t &A)
Swap matrices.
Definition: JMatrixND.hh:165

Member Function Documentation

JMatrixND_t& JMATH::JMatrixND::getInstance ( )
inlineprotected

Get work space.

Returns
work space

Definition at line 358 of file JMatrixND.hh.

359  {
360  return ws;
361  }
JMatrixND_t ws
Definition: JMatrixND.hh:351
JMatrixND& JMATH::JMatrixND::operator= ( const JMatrixND A)
inline

Assignment operator.

Parameters
Amatrix

Definition at line 415 of file JMatrixND.hh.

416  {
417  this->set(A);
418 
419  return *this;
420  }
void set(const JMatrixND_t &A)
Set matrix.
Definition: JMatrixND.hh:152
JMatrixND& JMATH::JMatrixND::operator= ( JMatrixND &&  A)
inline

Move assignment operator.

Parameters
Amatrix

Definition at line 428 of file JMatrixND.hh.

429  {
430  this->swap(A);
431 
432  return *this;
433  }
void swap(JMatrixND_t &A)
Swap matrices.
Definition: JMatrixND.hh:165
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 443 of file JMatrixND.hh.

444  {
445  static_cast<JMatrixND_t&>(*this).resize(size);
446 
448  }
JMatrixND_t & getInstance()
Get work space.
Definition: JMatrixND.hh:358
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:199
void resize(const size_t size)
Resize matrix.
Definition: JMatrixND.hh:102
Basic NxN matrix.
Definition: JMatrixND.hh:36
JMatrixND& JMATH::JMatrixND::reset ( )
inline

Set matrix to the null matrix.

Returns
this matrix

Definition at line 456 of file JMatrixND.hh.

457  {
459 
461 
462  A.resize(this->size());
463 
464  return *this;
465  }
JMatrixND_t & getInstance()
Get work space.
Definition: JMatrixND.hh:358
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:199
void resize(const size_t size)
Resize matrix.
Definition: JMatrixND.hh:102
JMatrixND_t & reset()
Set matrix to the null matrix.
Definition: JMatrixND.hh:130
source $JPP_DIR setenv csh $JPP_DIR &dev null eval JShellParser o a A
Basic NxN matrix.
Definition: JMatrixND.hh:36
JMatrixND& JMATH::JMatrixND::setIdentity ( )
inline

Set to identity matrix.

Returns
this matrix

Definition at line 473 of file JMatrixND.hh.

474  {
475  reset();
476 
477  for (size_t i = 0; i != this->size(); ++i) {
478  (*this)(i,i) = 1.0;
479  }
480 
481  return *this;
482  }
JMatrixND & reset()
Set matrix to the null matrix.
Definition: JMatrixND.hh:456
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:199
JMatrixND& JMATH::JMatrixND::negate ( )
inline

Negate matrix.

Returns
this matrix

Definition at line 490 of file JMatrixND.hh.

491  {
492  double* p = this->data();
493 
494  for (size_t i = this->size()*this->size(); i != 0; --i, ++p) {
495  *p = -*p;
496  }
497 
498  return *this;
499  }
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:199
const double * data() const
Get pointer to data.
Definition: JMatrixND.hh:232
JMatrixND& JMATH::JMatrixND::add ( const JMatrixND A)
inline

Matrix addition.

Parameters
Amatrix
Returns
this matrix

Definition at line 508 of file JMatrixND.hh.

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

Matrix subtraction.

Parameters
Amatrix
Returns
this matrix

Definition at line 533 of file JMatrixND.hh.

534  {
535  if (this->size() == A.size()) {
536 
537  double* p = this->data();
538  const double* q = A.data();
539 
540  for (size_t i = this->size()*this->size(); i != 0; --i, ++p, ++q) {
541  *p -= *q;
542  }
543 
544  } else {
545  THROW(JException, "JMatrixND::sub() inconsistent matrix dimensions " << this->size() << ' ' << A.size());
546  }
547 
548  return *this;
549  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:199
const double * data() const
Get pointer to data.
Definition: JMatrixND.hh:232
JMatrixND& JMATH::JMatrixND::mul ( const double  factor)
inline

Scale matrix.

Parameters
factorfactor
Returns
this matrix

Definition at line 558 of file JMatrixND.hh.

559  {
560  double* p = this->data();
561 
562  for (size_t i = this->size()*this->size(); i != 0; --i, ++p) {
563  *p *= factor;
564  }
565 
566  return *this;
567  }
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:199
const double * data() const
Get pointer to data.
Definition: JMatrixND.hh:232
JMatrixND& JMATH::JMatrixND::div ( const double  factor)
inline

Scale matrix.

Parameters
factorfactor
Returns
this matrix

Definition at line 576 of file JMatrixND.hh.

577  {
578  double* p = this->data();
579 
580  for (size_t i = this->size()*this->size(); i != 0; --i, ++p) {
581  *p /= factor;
582  }
583 
584  return *this;
585  }
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:199
const double * data() const
Get pointer to data.
Definition: JMatrixND.hh:232
JMatrixND& JMATH::JMatrixND::mul ( const JMatrixND A,
const JMatrixND B 
)
inline

Matrix multiplication.

Parameters
Amatrix
Bmatrix
Returns
this matrix

Definition at line 595 of file JMatrixND.hh.

597  {
598  if (A.size() == B.size()) {
599 
600  this->resize(A.size());
601 
602  if (!this->empty()) {
603 
605 
606  C.set(B);
607  C.transpose();
608 
609  size_t i, row;
610 
611  for (row = 0; row + 4 <= this->size(); row += 4) { // process rows by four
612 
613  double* p0 = (*this)[row + 0];
614  double* p1 = (*this)[row + 1];
615  double* p2 = (*this)[row + 2];
616  double* p3 = (*this)[row + 3];
617 
618  for (size_t col = 0; col != this->size(); ++col, ++p0, ++p1, ++p2, ++p3) {
619 
620  double w0 = 0.0;
621  double w1 = 0.0;
622  double w2 = 0.0;
623  double w3 = 0.0;
624 
625  const double* a0 = A[row + 0];
626  const double* a1 = A[row + 1];
627  const double* a2 = A[row + 2];
628  const double* a3 = A[row + 3];
629 
630  const double* c0 = C[col];
631 
632  for (i = 0; i + 4 <= this->size(); i += 4, a0 += 4, a1 += 4, a2 += 4, a3 += 4, c0 += 4) {
633  w0 += a0[0] * c0[0] + a0[1] * c0[1] + a0[2] * c0[2] + a0[3] * c0[3];
634  w1 += a1[0] * c0[0] + a1[1] * c0[1] + a1[2] * c0[2] + a1[3] * c0[3];
635  w2 += a2[0] * c0[0] + a2[1] * c0[1] + a2[2] * c0[2] + a2[3] * c0[3];
636  w3 += a3[0] * c0[0] + a3[1] * c0[1] + a3[2] * c0[2] + a3[3] * c0[3];
637  }
638 
639  for ( ; i != this->size(); ++i, ++a0, ++a1, ++a2, ++a3, ++c0) {
640  w0 += (*a0) * (*c0);
641  w1 += (*a1) * (*c0);
642  w2 += (*a2) * (*c0);
643  w3 += (*a3) * (*c0);
644  }
645 
646  *p0 = w0;
647  *p1 = w1;
648  *p2 = w2;
649  *p3 = w3;
650  }
651  }
652 
653  for ( ; row != this->size(); ++row) { // remaining rows
654 
655  double* p0 = (*this)[row + 0];
656 
657  for (size_t col = 0; col != this->size(); ++col, ++p0) {
658 
659  double w0 = 0.0;
660 
661  const double* a0 = A[row + 0];
662  const double* c0 = C[col];
663 
664  for (i = 0; i + 4 <= this->size(); i += 4, a0 += 4, c0 += 4) {
665  w0 += a0[0] * c0[0] + a0[1] * c0[1] + a0[2] * c0[2] + a0[3] * c0[3];
666  }
667 
668  for ( ; i != this->size(); ++i, ++a0, ++c0) {
669  w0 += (*a0) * (*c0);
670  }
671 
672  *p0 = w0;
673  }
674  }
675  }
676 
677  } else {
678  THROW(JException, "JMatrixND::mul() inconsistent matrix dimensions " << A.size() << ' ' << B.size());
679  }
680 
681  return *this;
682  }
TPaveText * p1
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
void resize(const size_t size)
Resize matrix.
Definition: JMatrixND.hh:443
JMatrixND_t & getInstance()
Get work space.
Definition: JMatrixND.hh:358
static const double C
Physics constants.
void set(const JMatrixND_t &A)
Set matrix.
Definition: JMatrixND.hh:152
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:199
p2
Definition: module-Z:fit.sh:74
JMatrixND_t & transpose()
Transpose.
Definition: JMatrixND.hh:180
bool empty() const
Check emptyness.
Definition: JMatrixND.hh:221
p3
Definition: module-Z:fit.sh:74
Basic NxN matrix.
Definition: JMatrixND.hh:36
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 692 of file JMatrixND.hh.

694  {
695  if (this->size() == A.size()) {
696 
697  for (size_t row = 0; row != this->size(); ++row) {
698 
699  const double* p = (*this)[row];
700  const double* q = A [row];
701 
702  for (size_t i = this->size(); i != 0; --i, ++p, ++q) {
703  if (fabs(*p - *q) > eps) {
704  return false;
705  }
706  }
707  }
708 
709  return true;
710 
711  } else {
712  THROW(JException, "JMatrixND::equals() inconsistent matrix dimensions " << this->size() << ' ' << A.size());
713  }
714  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:199
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 723 of file JMatrixND.hh.

724  {
725  for (size_t i = 0; i != this->size(); ++i) {
726 
727  if (fabs(1.0 - (*this)(i,i)) > eps) {
728  return false;
729  };
730 
731  for (size_t j = 0; j != i; ++j) {
732  if (fabs((*this)(i,j)) > eps || fabs((*this)(j,i)) > eps) {
733  return false;
734  };
735  }
736  }
737 
738  return true;
739  }
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:199
int j
Definition: JPolint.hh:792
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 748 of file JMatrixND.hh.

749  {
750  for (size_t i = 0; i != this->size(); ++i) {
751  for (size_t j = 0; j != i; ++j) {
752  if (fabs((*this)(i,j) - (*this)(j,i)) > eps) {
753  return false;
754  };
755  }
756  }
757 
758  return true;
759  }
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:199
int j
Definition: JPolint.hh:792
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 770 of file JMatrixND.hh.

771  {
772  double dot = 0.0;
773 
774  for (size_t i = 0; i != v.size(); ++i) {
775 
776  const double* p = (*this)[i];
777 
778  double w = 0.0;
779 
780  for (JVectorND::const_iterator y = v.begin(); y != v.end(); ++y, ++p) {
781  w += (*p) * (*y);
782  }
783 
784  dot += v[i] * w;
785  }
786 
787  return dot;
788  }
data_type w[N+1][M+1]
Definition: JPolint.hh:867
void JMATH::JMatrixND::rswap ( size_t  r1,
size_t  r2 
)
inlineprotected

Definition at line 870 of file JMatrixND.hh.

871  {
873 
874  A.resize(this->size());
875 
876  memcpy(A.data(), (*this)[r1], this->size() * sizeof(double));
877  memcpy((*this)[r1], (*this)[r2], this->size() * sizeof(double));
878  memcpy((*this)[r2], A.data(), this->size() * sizeof(double));
879  }
JMatrixND_t & getInstance()
Get work space.
Definition: JMatrixND.hh:358
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:199
void resize(const size_t size)
Resize matrix.
Definition: JMatrixND.hh:102
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:232
Basic NxN matrix.
Definition: JMatrixND.hh:36
void JMATH::JMatrixND::cswap ( size_t  c1,
size_t  c2 
)
inlineprotected

Swap columns.

Parameters
c1column
c2column

Definition at line 888 of file JMatrixND.hh.

889  {
890  using std::swap;
891 
892  double* p1 = this->data() + c1;
893  double* p2 = this->data() + c2;
894 
895  for (size_t i = this->size(); i != 0; --i, p1 += this->size(), p2 += this->size()) {
896  swap(*p1, *p2);
897  }
898  }
TPaveText * p1
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:199
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:165
const double * data() const
Get pointer to data.
Definition: JMatrixND.hh:232
void JMATH::JMatrixND_t::clear ( )
inlineinherited

Clear memory.

Definition at line 83 of file JMatrixND.hh.

84  {
85  if (__p != NULL) {
86  delete [] __p;
87  }
88 
89  __p = NULL;
90  __n = 0;
91  __m = 0;
92  }
size_t __n
dimension of matrix
Definition: JMatrixND.hh:337
double * __p
pointer to data
Definition: JMatrixND.hh:336
size_t __m
capacity of matrix
Definition: JMatrixND.hh:338
void JMATH::JMatrixND_t::set ( const JMatrixND_t A)
inlineinherited

Set matrix.

Parameters
Amatrix

Definition at line 152 of file JMatrixND.hh.

153  {
154  this->resize(A.size());
155 
156  memcpy(this->data(), A.data(), A.size() * A.size() * sizeof(double));
157  }
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:199
void resize(const size_t size)
Resize matrix.
Definition: JMatrixND.hh:102
const double * data() const
Get pointer to data.
Definition: JMatrixND.hh:232
void JMATH::JMatrixND_t::swap ( JMatrixND_t A)
inlineinherited

Swap matrices.

Parameters
Amatrix

Definition at line 165 of file JMatrixND.hh.

166  {
167  using std::swap;
168 
169  swap(this->__p, A.__p);
170  swap(this->__n, A.__n);
171  swap(this->__m, A.__m);
172  }
size_t __n
dimension of matrix
Definition: JMatrixND.hh:337
double * __p
pointer to data
Definition: JMatrixND.hh:336
void swap(JMatrixND_t &A)
Swap matrices.
Definition: JMatrixND.hh:165
size_t __m
capacity of matrix
Definition: JMatrixND.hh:338
JMatrixND_t& JMATH::JMatrixND_t::transpose ( )
inlineinherited

Transpose.

Returns
this matrix

Definition at line 180 of file JMatrixND.hh.

181  {
182  using std::swap;
183 
184  for (size_t row = 0; row != this->size(); ++row) {
185  for (size_t col = 0; col != row; ++col) {
186  swap((*this)(row,col), (*this)(col,row));
187  }
188  }
189 
190  return *this;
191  }
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:199
void swap(JMatrixND_t &A)
Swap matrices.
Definition: JMatrixND.hh:165
size_t JMATH::JMatrixND_t::size ( ) const
inlineinherited

Get dimension of matrix.

Returns
dimension

Definition at line 199 of file JMatrixND.hh.

200  {
201  return __n;
202  }
size_t __n
dimension of matrix
Definition: JMatrixND.hh:337
size_t JMATH::JMatrixND_t::capacity ( ) const
inlineinherited

Get capacity of dimension.

Returns
capacity

Definition at line 210 of file JMatrixND.hh.

211  {
212  return __m;
213  }
size_t __m
capacity of matrix
Definition: JMatrixND.hh:338
bool JMATH::JMatrixND_t::empty ( ) const
inlineinherited

Check emptyness.

Returns
true if empty; else false

Definition at line 221 of file JMatrixND.hh.

222  {
223  return __n == 0;
224  }
size_t __n
dimension of matrix
Definition: JMatrixND.hh:337
const double* JMATH::JMatrixND_t::data ( ) const
inlineinherited

Get pointer to data.

Returns
pointer to data.

Definition at line 232 of file JMatrixND.hh.

233  {
234  return __p;
235  }
double * __p
pointer to data
Definition: JMatrixND.hh:336
double* JMATH::JMatrixND_t::data ( )
inlineinherited

Get pointer to data.

Returns
pointer to data.

Definition at line 243 of file JMatrixND.hh.

244  {
245  return __p;
246  }
double * __p
pointer to data
Definition: JMatrixND.hh:336
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 255 of file JMatrixND.hh.

256  {
257  return __p + row*__n;
258  }
size_t __n
dimension of matrix
Definition: JMatrixND.hh:337
double * __p
pointer to data
Definition: JMatrixND.hh:336
double* JMATH::JMatrixND_t::operator[] ( size_t  row)
inlineinherited

Get row data.

Parameters
rowrow number
Returns
pointer to row data

Definition at line 267 of file JMatrixND.hh.

268  {
269  return __p + row*__n;
270  }
size_t __n
dimension of matrix
Definition: JMatrixND.hh:337
double * __p
pointer to data
Definition: JMatrixND.hh:336
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 280 of file JMatrixND.hh.

281  {
282  return *(__p + row*__n + col);
283  }
size_t __n
dimension of matrix
Definition: JMatrixND.hh:337
double * __p
pointer to data
Definition: JMatrixND.hh:336
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 293 of file JMatrixND.hh.

294  {
295  return *(__p + row*__n + col);
296  }
size_t __n
dimension of matrix
Definition: JMatrixND.hh:337
double * __p
pointer to data
Definition: JMatrixND.hh:336
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 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:712
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:199
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 324 of file JMatrixND.hh.

325  {
326  if (row >= this->size() ||
327  col >= this->size()) {
328  THROW(JIndexOutOfRange, "JMatrixND::at(" << row << "," << col << "): index out of range.");
329  }
330 
331  return (*this)(row, col);
332  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:199
JMatrixND & JMATH::JMath< JMatrixND , JNullType >::mul ( const JNullType object)
inlineinherited

Multiply with object.

Parameters
objectobject
Returns
result object

Definition at line 354 of file JMath.hh.

355  {
356  return static_cast<JFirst_t&>(*this) = JFirst_t().mul(static_cast<const JFirst_t&>(*this), object);
357  }

Friends And Related Function Documentation

JReader& operator>> ( JReader in,
JMatrixND A 
)
friend

Read matrix from input.

Parameters
inreader
Amatrix
Returns
reader

Definition at line 798 of file JMatrixND.hh.

799  {
800  size_t size;
801 
802  in >> size;
803 
804  A.resize(size);
805 
806  size_t n = A.size() * A.size();
807 
808  for (double* p = A.data(); n != 0; --n, ++p) {
809  in >> *p;
810  }
811 
812  return in;
813  }
void resize(const size_t size)
Resize matrix.
Definition: JMatrixND.hh:443
const int n
Definition: JPolint.hh:786
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:199
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:232
JWriter& operator<< ( JWriter out,
const JMatrixND A 
)
friend

Write matrix to output.

Parameters
outwriter
Amatrix
Returns
writer

Definition at line 823 of file JMatrixND.hh.

824  {
825  out << A.size();
826 
827  size_t n = A.size() * A.size();
828 
829  for (const double* p = A.data(); n != 0; --n, ++p) {
830  out << *p;
831  }
832 
833  return out;
834  }
const int n
Definition: JPolint.hh:786
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:199
const double * data() const
Get pointer to data.
Definition: JMatrixND.hh:232
std::ostream& operator<< ( std::ostream &  out,
const JMatrixND A 
)
friend

Print ASCII formatted output.

Parameters
outoutput stream
Amatrix
Returns
output stream

Definition at line 844 of file JMatrixND.hh.

845  {
846  using namespace std;
847 
848  const JFormat format(out, getFormat<JMatrixND>(JFormat_t(10, 3, std::ios::fixed | std::ios::showpos)));
849 
850  for (size_t row = 0; row != A.size(); ++row) {
851 
852  for (size_t col = 0; col != A.size(); ++col) {
853  out << format << A(row,col) << ' ';
854  }
855 
856  out << endl;
857  }
858 
859  return out;
860  }
Auxiliary class to temporarily define format specifications.
Definition: JManip.hh:632
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:199
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

JMatrixND_t JMATH::JMatrixND::ws
protected

Definition at line 351 of file JMatrixND.hh.

double* JMATH::JMatrixND_t::__p
protectedinherited

pointer to data

Definition at line 336 of file JMatrixND.hh.

size_t JMATH::JMatrixND_t::__n
protectedinherited

dimension of matrix

Definition at line 337 of file JMatrixND.hh.

size_t JMATH::JMatrixND_t::__m
protectedinherited

capacity of matrix

Definition at line 338 of file JMatrixND.hh.


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