Jpp  18.0.0-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JMatrixND.hh
Go to the documentation of this file.
1 #ifndef __JMATH__JMATRIXND__
2 #define __JMATH__JMATRIXND__
3 
4 #include <cstring>
5 #include <limits>
6 #include <cmath>
7 #include <algorithm>
8 
9 #include "JIO/JSerialisable.hh"
10 #include "JLang/JException.hh"
11 #include "JLang/JEquals.hh"
12 #include "JLang/JManip.hh"
13 #include "JMath/JMath.hh"
14 #include "JMath/JVectorND.hh"
15 
16 /**
17  * \author mdejong
18  */
19 
20 namespace JMATH {}
21 namespace JPP { using namespace JMATH; }
22 
23 namespace JMATH {
24 
25  using JIO::JReader;
26  using JIO::JWriter;
27  using JLANG::JEquals;
28  using JLANG::JException;
31 
32 
33  /**
34  * Basic NxN matrix.
35  */
36  struct JMatrixND_t {
37  /**
38  * Default constructor.
39  */
41  __p(NULL),
42  __n(0),
43  __m(0)
44  {}
45 
46 
47  /**
48  * Copy constructor.
49  *
50  * \param A matrix
51  */
53  JMatrixND_t()
54  {
55  set(A);
56  }
57 
58 
59  /**
60  * Move constructor.
61  *
62  * \param A matrix
63  */
65  JMatrixND_t()
66  {
67  swap(A);
68  }
69 
70 
71  /**
72  * Destructor.
73  */
75  {
76  clear();
77  }
78 
79 
80  /**
81  * Clear memory.
82  */
83  void clear()
84  {
85  if (__p != NULL) {
86  delete [] __p;
87  }
88 
89  __p = NULL;
90  __n = 0;
91  __m = 0;
92  }
93 
94 
95  /**
96  * Resize matrix.
97  *
98  * Note that this method does not maintain data in the matrix.
99  *
100  * \param size dimension
101  */
102  void resize(const size_t size)
103  {
104  if (size != this->__n) {
105 
106  if (size > this->__m) {
107 
108  if (__p != NULL) {
109  delete[] __p;
110  }
111 
112  __m = size;
113  __p = new double[__m*__m];
114 
115  if (__p == NULL) {
116  THROW(JNewException, "JMatrixND::resize(" << size << "): Memory allocation failure.");
117  }
118  }
119 
120  __n = size;
121  }
122  }
123 
124 
125  /**
126  * Set matrix.
127  *
128  * \param A matrix
129  */
130  void set(const JMatrixND_t& A)
131  {
132  this->resize(A.size());
133 
134  memcpy(this->data(), A.data(), A.size() * A.size() * sizeof(double));
135  }
136 
137 
138  /**
139  * Swap matrices
140  *
141  * \param A matrix
142  */
144  {
145  using std::swap;
146 
147  swap(this->__p, A.__p);
148  swap(this->__n, A.__n);
149  swap(this->__m, A.__m);
150  }
151 
152 
153  /**
154  * Transpose.
155  *
156  * \return this matrix
157  */
159  {
160  using std::swap;
161 
162  for (size_t row = 0; row != this->size(); ++row) {
163  for (size_t col = 0; col != row; ++col) {
164  swap((*this)(row,col), (*this)(col,row));
165  }
166  }
167 
168  return *this;
169  }
170 
171 
172  /**
173  * Get dimension of matrix.
174  *
175  * \return dimension
176  */
177  size_t size() const
178  {
179  return __n;
180  }
181 
182 
183  /**
184  * Get capacity of dimension.
185  *
186  * \return capacity
187  */
188  size_t capacity() const
189  {
190  return __m;
191  }
192 
193 
194  /**
195  * Check emptyness.
196  *
197  * \return true if empty; else false
198  */
199  bool empty() const
200  {
201  return __n == 0;
202  }
203 
204 
205  /**
206  * Get pointer to data.
207  *
208  * \return pointer to data.
209  */
210  const double* data() const
211  {
212  return __p;
213  }
214 
215 
216  /**
217  * Get pointer to data.
218  *
219  * \return pointer to data.
220  */
221  double* data()
222  {
223  return __p;
224  }
225 
226 
227  /**
228  * Get row data.
229  *
230  * \param row row number
231  * \return pointer to row data
232  */
233  const double* operator[](size_t row) const
234  {
235  return __p + row*__n;
236  }
237 
238 
239  /**
240  * Get row data.
241  *
242  * \param row row number
243  * \return pointer to row data
244  */
245  double* operator[](size_t row)
246  {
247  return __p + row*__n;
248  }
249 
250 
251  /**
252  * Get matrix element.
253  *
254  * \param row row number
255  * \param col column number
256  * \return matrix element at (row,col)
257  */
258  double operator()(const size_t row, const size_t col) const
259  {
260  return *(__p + row*__n + col);
261  }
262 
263 
264  /**
265  * Get matrix element.
266  *
267  * \param row row number
268  * \param col column number
269  * \return matrix element at (row,col)
270  */
271  double& operator()(const size_t row, const size_t col)
272  {
273  return *(__p + row*__n + col);
274  }
275 
276 
277  /**
278  * Get matrix element.
279  *
280  * \param row row number
281  * \param col column number
282  * \return matrix element at (row,col)
283  */
284  double at(size_t row, size_t col) const
285  {
286  if (row >= this->size() ||
287  col >= this->size()) {
288  THROW(JIndexOutOfRange, "JMatrixND::at(" << row << "," << col << "): index out of range.");
289  }
290 
291  return (*this)(row, col);
292  }
293 
294 
295  /**
296  * Get matrix element.
297  *
298  * \param row row number
299  * \param col column number
300  * \return matrix element at (row,col)
301  */
302  double& at(size_t row, size_t col)
303  {
304  if (row >= this->size() ||
305  col >= this->size()) {
306  THROW(JIndexOutOfRange, "JMatrixND::at(" << row << "," << col << "): index out of range.");
307  }
308 
309  return (*this)(row, col);
310  }
311 
312 
313  protected:
314  double* __p; //!< pointer to data
315  size_t __n; //!< dimension of matrix
316  size_t __m; //!< capacity of matrix
317  };
318 
319 
320  /**
321  * NxN matrix.
322  */
323  struct JMatrixND :
324  public JMatrixND_t,
325  public JMath <JMatrixND>,
326  public JEquals<JMatrixND>
327  {
328  protected:
330 
331  /**
332  * Get work space.
333  *
334  * \return work space
335  */
337  {
338  return ws;
339  }
340 
341  public:
342 
343  using JMath<JMatrixND>::mul;
344 
345  /**
346  * Default constructor.
347  */
349  {}
350 
351 
352  /**
353  * Constructor.
354  *
355  * The matrix is set to zero.
356  *
357  * \param size dimension
358  */
359  JMatrixND(const size_t size)
360  {
361  resize(size);
362  reset();
363  }
364 
365 
366  /**
367  * Copy constructor.
368  *
369  * \param A matrix
370  */
372  {
373  set(A);
374  }
375 
376 
377  /**
378  * Move constructor.
379  *
380  * \param A matrix
381  */
383  {
384  swap(A);
385  }
386 
387 
388  /**
389  * Assignment operator.
390  *
391  * \param A matrix
392  */
394  {
395  this->set(A);
396 
397  return *this;
398  }
399 
400 
401  /**
402  * Move assignment operator.
403  *
404  * \param A matrix
405  */
407  {
408  this->swap(A);
409 
410  return *this;
411  }
412 
413 
414  /**
415  * Resize matrix.
416  *
417  * Note that this method does not maintain data in the matrix.
418  *
419  * \param size dimension
420  */
421  void resize(const size_t size)
422  {
423  static_cast<JMatrixND_t&>(*this).resize(size);
424 
425  getInstance().resize(size);
426  }
427 
428 
429  /**
430  * Set matrix to the null matrix.
431  *
432  * \return this matrix
433  */
435  {
437 
438  A.resize(this->size());
439 
440  double* p = A.data();
441 
442  for (size_t i = this->size(); i != 0; --i, ++p) {
443  *p = 0.0;
444  }
445 
446  p = this->data();
447 
448  for (size_t i = this->size(); i != 0; --i, p += this->size()) {
449  memcpy(p, A.data(), this->size() * sizeof(double));
450  }
451 
452  return *this;
453  }
454 
455 
456  /**
457  * Set to identity matrix
458  *
459  * \return this matrix
460  */
462  {
463  reset();
464 
465  for (size_t i = 0; i != this->size(); ++i) {
466  (*this)(i,i) = 1.0;
467  }
468 
469  return *this;
470  }
471 
472 
473  /**
474  * Negate matrix.
475  *
476  * \return this matrix
477  */
479  {
480  double* p = this->data();
481 
482  for (size_t i = this->size()*this->size(); i != 0; --i, ++p) {
483  *p = -*p;
484  }
485 
486  return *this;
487  }
488 
489 
490  /**
491  * Matrix addition.
492  *
493  * \param A matrix
494  * \return this matrix
495  */
497  {
498  if (this->size() == A.size()) {
499 
500  double* p = this->data();
501  const double* q = A.data();
502 
503  for (size_t i = this->size()*this->size(); i != 0; --i, ++p, ++q) {
504  *p += *q;
505  }
506 
507  } else {
508  THROW(JException, "JMatrixND::add() inconsistent matrix dimensions " << this->size() << ' ' << A.size());
509  }
510  }
511 
512 
513  /**
514  * Matrix subtraction.
515  *
516  * \param A matrix
517  * \return this matrix
518  */
520  {
521  if (this->size() == A.size()) {
522 
523  double* p = this->data();
524  const double* q = A.data();
525 
526  for (size_t i = this->size()*this->size(); i != 0; --i, ++p, ++q) {
527  *p -= *q;
528  }
529 
530  } else {
531  THROW(JException, "JMatrixND::sub() inconsistent matrix dimensions " << this->size() << ' ' << A.size());
532  }
533 
534  return *this;
535  }
536 
537 
538  /**
539  * Scale matrix.
540  *
541  * \param factor factor
542  * \return this matrix
543  */
544  JMatrixND& mul(const double factor)
545  {
546  double* p = this->data();
547 
548  for (size_t i = this->size()*this->size(); i != 0; --i, ++p) {
549  *p *= factor;
550  }
551 
552  return *this;
553  }
554 
555 
556  /**
557  * Scale matrix.
558  *
559  * \param factor factor
560  * \return this matrix
561  */
562  JMatrixND& div(const double factor)
563  {
564  double* p = this->data();
565 
566  for (size_t i = this->size()*this->size(); i != 0; --i, ++p) {
567  *p /= factor;
568  }
569 
570  return *this;
571  }
572 
573 
574  /**
575  * Matrix multiplication.
576  *
577  * \param A matrix
578  * \param B matrix
579  * \return this matrix
580  */
582  const JMatrixND& B)
583  {
584  if (A.size() == B.size()) {
585 
586  this->resize(A.size());
587 
588  if (!this->empty()) {
589 
591 
592  C.set(B);
593  C.transpose();
594 
595  size_t i, row;
596 
597  for (row = 0; row + 4 <= this->size(); row += 4) { // process rows by four
598 
599  double* p0 = (*this)[row + 0];
600  double* p1 = (*this)[row + 1];
601  double* p2 = (*this)[row + 2];
602  double* p3 = (*this)[row + 3];
603 
604  for (size_t col = 0; col != this->size(); ++col, ++p0, ++p1, ++p2, ++p3) {
605 
606  double w0 = 0.0;
607  double w1 = 0.0;
608  double w2 = 0.0;
609  double w3 = 0.0;
610 
611  const double* a0 = A[row + 0];
612  const double* a1 = A[row + 1];
613  const double* a2 = A[row + 2];
614  const double* a3 = A[row + 3];
615 
616  const double* c0 = C[col];
617 
618  for (i = 0; i + 4 <= this->size(); i += 4, a0 += 4, a1 += 4, a2 += 4, a3 += 4, c0 += 4) {
619  w0 += a0[0] * c0[0] + a0[1] * c0[1] + a0[2] * c0[2] + a0[3] * c0[3];
620  w1 += a1[0] * c0[0] + a1[1] * c0[1] + a1[2] * c0[2] + a1[3] * c0[3];
621  w2 += a2[0] * c0[0] + a2[1] * c0[1] + a2[2] * c0[2] + a2[3] * c0[3];
622  w3 += a3[0] * c0[0] + a3[1] * c0[1] + a3[2] * c0[2] + a3[3] * c0[3];
623  }
624 
625  for ( ; i != this->size(); ++i, ++a0, ++a1, ++a2, ++a3, ++c0) {
626  w0 += (*a0) * (*c0);
627  w1 += (*a1) * (*c0);
628  w2 += (*a2) * (*c0);
629  w3 += (*a3) * (*c0);
630  }
631 
632  *p0 = w0;
633  *p1 = w1;
634  *p2 = w2;
635  *p3 = w3;
636  }
637  }
638 
639  for ( ; row != this->size(); ++row) { // remaining rows
640 
641  double* p0 = (*this)[row + 0];
642 
643  for (size_t col = 0; col != this->size(); ++col, ++p0) {
644 
645  double w0 = 0.0;
646 
647  const double* a0 = A[row + 0];
648  const double* c0 = C[col];
649 
650  for (i = 0; i + 4 <= this->size(); i += 4, a0 += 4, c0 += 4) {
651  w0 += a0[0] * c0[0] + a0[1] * c0[1] + a0[2] * c0[2] + a0[3] * c0[3];
652  }
653 
654  for ( ; i != this->size(); ++i, ++a0, ++c0) {
655  w0 += (*a0) * (*c0);
656  }
657 
658  *p0 = w0;
659  }
660  }
661  }
662 
663  } else {
664  THROW(JException, "JMatrixND::mul() inconsistent matrix dimensions " << A.size() << ' ' << B.size());
665  }
666 
667  return *this;
668  }
669 
670 
671  /**
672  * Equality.
673  *
674  * \param A matrix
675  * \param eps numerical precision
676  * \return true if matrices identical; else false
677  */
678  bool equals(const JMatrixND& A,
679  const double eps = std::numeric_limits<double>::min()) const
680  {
681  if (this->size() == A.size()) {
682 
683  for (size_t row = 0; row != this->size(); ++row) {
684 
685  const double* p = (*this)[row];
686  const double* q = A [row];
687 
688  for (size_t i = this->size(); i != 0; --i, ++p, ++q) {
689  if (fabs(*p - *q) > eps) {
690  return false;
691  }
692  }
693  }
694 
695  return true;
696 
697  } else {
698  THROW(JException, "JMatrixND::equals() inconsistent matrix dimensions " << this->size() << ' ' << A.size());
699  }
700  }
701 
702 
703  /**
704  * Test identity.
705  *
706  * \param eps numerical precision
707  * \return true if identity matrix; else false
708  */
709  bool isIdentity(const double eps = std::numeric_limits<double>::min()) const
710  {
711  for (size_t i = 0; i != this->size(); ++i) {
712 
713  if (fabs(1.0 - (*this)(i,i)) > eps) {
714  return false;
715  };
716 
717  for (size_t j = 0; j != i; ++j) {
718  if (fabs((*this)(i,j)) > eps || fabs((*this)(j,i)) > eps) {
719  return false;
720  };
721  }
722  }
723 
724  return true;
725  }
726 
727 
728  /**
729  * Test symmetry.
730  *
731  * \param eps numerical precision
732  * \return true if symmetric matrix; else false
733  */
734  bool isSymmetric(const double eps = std::numeric_limits<double>::min()) const
735  {
736  for (size_t i = 0; i != this->size(); ++i) {
737  for (size_t j = 0; j != i; ++j) {
738  if (fabs((*this)(i,j) - (*this)(j,i)) > eps) {
739  return false;
740  };
741  }
742  }
743 
744  return true;
745  }
746 
747 
748  /**
749  * Get dot product.
750  *
751  * The dot product corresponds to \f[ v^{T} \times A \times v \f].
752  *
753  * \param v vector
754  * \return dot product
755  */
756  double getDot(const JVectorND& v) const
757  {
758  double dot = 0.0;
759 
760  for (size_t i = 0; i != v.size(); ++i) {
761 
762  const double* p = (*this)[i];
763 
764  double w = 0.0;
765 
766  for (JVectorND::const_iterator y = v.begin(); y != v.end(); ++y, ++p) {
767  w += (*p) * (*y);
768  }
769 
770  dot += v[i] * w;
771  }
772 
773  return dot;
774  }
775 
776 
777  /**
778  * Read matrix from input.
779  *
780  * \param in reader
781  * \param A matrix
782  * \return reader
783  */
784  friend inline JReader& operator>>(JReader& in, JMatrixND& A)
785  {
786  size_t size;
787 
788  in >> size;
789 
790  A.resize(size);
791 
792  size_t n = A.size() * A.size();
793 
794  for (double* p = A.data(); n != 0; --n, ++p) {
795  in >> *p;
796  }
797 
798  return in;
799  }
800 
801 
802  /**
803  * Write matrix to output.
804  *
805  * \param out writer
806  * \param A matrix
807  * \return writer
808  */
809  friend inline JWriter& operator<<(JWriter& out, const JMatrixND& A)
810  {
811  out << A.size();
812 
813  size_t n = A.size() * A.size();
814 
815  for (const double* p = A.data(); n != 0; --n, ++p) {
816  out << *p;
817  }
818 
819  return out;
820  }
821 
822 
823  /**
824  * Print ASCII formatted output.
825  *
826  * \param out output stream
827  * \param A matrix
828  * \return output stream
829  */
830  friend inline std::ostream& operator<<(std::ostream& out, const JMatrixND& A)
831  {
832  using namespace std;
833 
834  const JFormat format(out, getFormat<JMatrixND>(JFormat_t(10, 3, std::ios::fixed | std::ios::showpos)));
835 
836  for (size_t row = 0; row != A.size(); ++row) {
837 
838  for (size_t col = 0; col != A.size(); ++col) {
839  out << format << A(row,col) << ' ';
840  }
841 
842  out << endl;
843  }
844 
845  return out;
846  }
847 
848 
849  protected:
850  /*
851  * Swap rows.
852  *
853  * \param r1 row
854  * \param r2 row
855  */
856  void rswap(size_t r1, size_t r2)
857  {
858  JMatrixND_t& A = getInstance();
859 
860  A.resize(this->size());
861 
862  memcpy(A.data(), (*this)[r1], this->size() * sizeof(double));
863  memcpy((*this)[r1], (*this)[r2], this->size() * sizeof(double));
864  memcpy((*this)[r2], A.data(), this->size() * sizeof(double));
865  }
866 
867 
868  /**
869  * Swap columns.
870  *
871  * \param c1 column
872  * \param c2 column
873  */
874  void cswap(size_t c1, size_t c2)
875  {
876  using std::swap;
877 
878  double* p1 = this->data() + c1;
879  double* p2 = this->data() + c2;
880 
881  for (size_t i = this->size(); i != 0; --i, p1 += this->size(), p2 += this->size()) {
882  swap(*p1, *p2);
883  }
884  }
885  };
886 }
887 
888 #endif
JMatrixND(const JMatrixND &A)
Copy constructor.
Definition: JMatrixND.hh:371
JMatrixND_t ws
Definition: JMatrixND.hh:329
Exception for failure of memory allocation.
Definition: JException.hh:306
General exception.
Definition: JException.hh:23
data_type w[N+1][M+1]
Definition: JPolint.hh:778
Exceptions.
Interface for binary output.
Auxiliary base class for aritmetic operations of derived class types.
Definition: JMath.hh:109
TPaveText * p1
JMatrixND_t(const JMatrixND_t &A)
Copy constructor.
Definition: JMatrixND.hh:52
JMatrixND & sub(const JMatrixND &A)
Matrix subtraction.
Definition: JMatrixND.hh:519
double at(size_t row, size_t col) const
Get matrix element.
Definition: JMatrixND.hh:284
void clear()
Clear memory.
Definition: JMatrixND.hh:83
JMatrixND & mul(const double factor)
Scale matrix.
Definition: JMatrixND.hh:544
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
JMatrixND & reset()
Set matrix to the null matrix.
Definition: JMatrixND.hh:434
void resize(const size_t size)
Resize matrix.
Definition: JMatrixND.hh:421
const double * operator[](size_t row) const
Get row data.
Definition: JMatrixND.hh:233
JMatrixND_t & getInstance()
Get work space.
Definition: JMatrixND.hh:336
JMatrixND & operator=(const JMatrixND &A)
Assignment operator.
Definition: JMatrixND.hh:393
~JMatrixND_t()
Destructor.
Definition: JMatrixND.hh:74
Auxiliary class to temporarily define format specifications.
Definition: JManip.hh:632
double operator()(const size_t row, const size_t col) const
Get matrix element.
Definition: JMatrixND.hh:258
JMatrixND(const size_t size)
Constructor.
Definition: JMatrixND.hh:359
NxN matrix.
Definition: JMatrixND.hh:323
friend JWriter & operator<<(JWriter &out, const JMatrixND &A)
Write matrix to output.
Definition: JMatrixND.hh:809
static const double C
Physics constants.
const int n
Definition: JPolint.hh:697
void set(const JMatrixND_t &A)
Set matrix.
Definition: JMatrixND.hh:130
JMatrixND_t()
Default constructor.
Definition: JMatrixND.hh:40
bool isIdentity(const double eps=std::numeric_limits< double >::min()) const
Test identity.
Definition: JMatrixND.hh:709
Template definition of auxiliary base class for comparison of data structures.
Definition: JEquals.hh:24
double * data()
Get pointer to data.
Definition: JMatrixND.hh:221
JMatrixND & add(const JMatrixND &A)
Matrix addition.
Definition: JMatrixND.hh:496
Interface for binary input.
bool equals(const JMatrixND &A, const double eps=std::numeric_limits< double >::min()) const
Equality.
Definition: JMatrixND.hh:678
void rswap(size_t r1, size_t r2)
Definition: JMatrixND.hh:856
friend JReader & operator>>(JReader &in, JMatrixND &A)
Read matrix from input.
Definition: JMatrixND.hh:784
I/O manipulators.
size_t size() const
Get dimension of matrix.
Definition: JMatrixND.hh:177
TCanvas * c1
Global variables to handle mouse events.
p2
Definition: module-Z:fit.sh:74
JMatrixND & negate()
Negate matrix.
Definition: JMatrixND.hh:478
double & at(size_t row, size_t col)
Get matrix element.
Definition: JMatrixND.hh:302
size_t __n
dimension of matrix
Definition: JMatrixND.hh:315
JMatrixND & operator=(JMatrixND &&A)
Move assignment operator.
Definition: JMatrixND.hh:406
JMatrixND_t(JMatrixND_t &&A)
Move constructor.
Definition: JMatrixND.hh:64
double * __p
pointer to data
Definition: JMatrixND.hh:314
bool isSymmetric(const double eps=std::numeric_limits< double >::min()) const
Test symmetry.
Definition: JMatrixND.hh:734
void resize(const size_t size)
Resize matrix.
Definition: JMatrixND.hh:102
JMatrixND_t & transpose()
Transpose.
Definition: JMatrixND.hh:158
Base class for data structures with artithmetic capabilities.
void cswap(size_t c1, size_t c2)
Swap columns.
Definition: JMatrixND.hh:874
size_t capacity() const
Get capacity of dimension.
Definition: JMatrixND.hh:188
JMatrixND()
Default constructor.
Definition: JMatrixND.hh:348
void swap(JMatrixND_t &A)
Swap matrices.
Definition: JMatrixND.hh:143
int j
Definition: JPolint.hh:703
JMatrixND(JMatrixND &&A)
Move constructor.
Definition: JMatrixND.hh:382
Exception for accessing an index in a collection that is outside of its range.
Definition: JException.hh:90
data_type v[N+1][M+1]
Definition: JPolint.hh:777
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
source $JPP_DIR setenv csh $JPP_DIR &dev null eval JShellParser o a A
double getDot(const JVectorND &v) const
Get dot product.
Definition: JMatrixND.hh:756
const double * data() const
Get pointer to data.
Definition: JMatrixND.hh:210
bool empty() const
Check emptyness.
Definition: JMatrixND.hh:199
Data structure for format specifications.
Definition: JManip.hh:522
double & operator()(const size_t row, const size_t col)
Get matrix element.
Definition: JMatrixND.hh:271
size_t __m
capacity of matrix
Definition: JMatrixND.hh:316
p3
Definition: module-Z:fit.sh:74
Basic NxN matrix.
Definition: JMatrixND.hh:36
JMatrixND & setIdentity()
Set to identity matrix.
Definition: JMatrixND.hh:461
double * operator[](size_t row)
Get row data.
Definition: JMatrixND.hh:245
Nx1 matrix.
Definition: JVectorND.hh:21
JMatrixND & div(const double factor)
Scale matrix.
Definition: JMatrixND.hh:562
friend std::ostream & operator<<(std::ostream &out, const JMatrixND &A)
Print ASCII formatted output.
Definition: JMatrixND.hh:830
JMatrixND & mul(const JMatrixND &A, const JMatrixND &B)
Matrix multiplication.
Definition: JMatrixND.hh:581