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
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 to the null matrix.
127  *
128  * \return this matrix
129  */
131  {
132  double* p0 = this->data();
133  double* p1 = this->data();
134 
135  for (size_t i = this->size(); i != 0; --i, ++p1) {
136  *p1 = 0.0;
137  }
138 
139  for (size_t i = this->size(); i != 1; --i, p1 += this->size()) {
140  memcpy(p1, p0, this->size() * sizeof(double));
141  }
142 
143  return *this;
144  }
145 
146 
147  /**
148  * Set matrix.
149  *
150  * \param A matrix
151  */
152  void set(const JMatrixND_t& A)
153  {
154  this->resize(A.size());
155 
156  memcpy(this->data(), A.data(), A.size() * A.size() * sizeof(double));
157  }
158 
159 
160  /**
161  * Swap matrices
162  *
163  * \param A matrix
164  */
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  }
173 
174 
175  /**
176  * Transpose.
177  *
178  * \return this matrix
179  */
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  }
192 
193 
194  /**
195  * Get dimension of matrix.
196  *
197  * \return dimension
198  */
199  size_t size() const
200  {
201  return __n;
202  }
203 
204 
205  /**
206  * Get capacity of dimension.
207  *
208  * \return capacity
209  */
210  size_t capacity() const
211  {
212  return __m;
213  }
214 
215 
216  /**
217  * Check emptyness.
218  *
219  * \return true if empty; else false
220  */
221  bool empty() const
222  {
223  return __n == 0;
224  }
225 
226 
227  /**
228  * Get pointer to data.
229  *
230  * \return pointer to data.
231  */
232  const double* data() const
233  {
234  return __p;
235  }
236 
237 
238  /**
239  * Get pointer to data.
240  *
241  * \return pointer to data.
242  */
243  double* data()
244  {
245  return __p;
246  }
247 
248 
249  /**
250  * Get row data.
251  *
252  * \param row row number
253  * \return pointer to row data
254  */
255  const double* operator[](size_t row) const
256  {
257  return __p + row*__n;
258  }
259 
260 
261  /**
262  * Get row data.
263  *
264  * \param row row number
265  * \return pointer to row data
266  */
267  double* operator[](size_t row)
268  {
269  return __p + row*__n;
270  }
271 
272 
273  /**
274  * Get matrix element.
275  *
276  * \param row row number
277  * \param col column number
278  * \return matrix element at (row,col)
279  */
280  double operator()(const size_t row, const size_t col) const
281  {
282  return *(__p + row*__n + col);
283  }
284 
285 
286  /**
287  * Get matrix element.
288  *
289  * \param row row number
290  * \param col column number
291  * \return matrix element at (row,col)
292  */
293  double& operator()(const size_t row, const size_t col)
294  {
295  return *(__p + row*__n + col);
296  }
297 
298 
299  /**
300  * Get matrix element.
301  *
302  * \param row row number
303  * \param col column number
304  * \return matrix element at (row,col)
305  */
306  double at(size_t row, size_t col) const
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  }
315 
316 
317  /**
318  * Get matrix element.
319  *
320  * \param row row number
321  * \param col column number
322  * \return matrix element at (row,col)
323  */
324  double& at(size_t row, size_t col)
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  }
333 
334 
335  protected:
336  double* __p; //!< pointer to data
337  size_t __n; //!< dimension of matrix
338  size_t __m; //!< capacity of matrix
339  };
340 
341 
342  /**
343  * NxN matrix.
344  */
345  struct JMatrixND :
346  public JMatrixND_t,
347  public JMath <JMatrixND>,
348  public JEquals<JMatrixND>
349  {
350  protected:
352 
353  /**
354  * Get work space.
355  *
356  * \return work space
357  */
359  {
360  return ws;
361  }
362 
363  public:
364 
365  using JMath<JMatrixND>::mul;
366 
367  /**
368  * Default constructor.
369  */
371  {}
372 
373 
374  /**
375  * Constructor.
376  *
377  * The matrix is set to zero.
378  *
379  * \param size dimension
380  */
381  JMatrixND(const size_t size)
382  {
383  resize(size);
384  reset();
385  }
386 
387 
388  /**
389  * Copy constructor.
390  *
391  * \param A matrix
392  */
394  {
395  set(A);
396  }
397 
398 
399  /**
400  * Move constructor.
401  *
402  * \param A matrix
403  */
405  {
406  swap(A);
407  }
408 
409 
410  /**
411  * Assignment operator.
412  *
413  * \param A matrix
414  */
416  {
417  this->set(A);
418 
419  return *this;
420  }
421 
422 
423  /**
424  * Move assignment operator.
425  *
426  * \param A matrix
427  */
429  {
430  this->swap(A);
431 
432  return *this;
433  }
434 
435 
436  /**
437  * Resize matrix.
438  *
439  * Note that this method does not maintain data in the matrix.
440  *
441  * \param size dimension
442  */
443  void resize(const size_t size)
444  {
445  static_cast<JMatrixND_t&>(*this).resize(size);
446 
447  getInstance().resize(size);
448  }
449 
450 
451  /**
452  * Set matrix to the null matrix.
453  *
454  * \return this matrix
455  */
457  {
459 
461 
462  A.resize(this->size());
463 
464  return *this;
465  }
466 
467 
468  /**
469  * Set to identity matrix
470  *
471  * \return this matrix
472  */
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  }
483 
484 
485  /**
486  * Negate matrix.
487  *
488  * \return this matrix
489  */
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  }
500 
501 
502  /**
503  * Matrix addition.
504  *
505  * \param A matrix
506  * \return this matrix
507  */
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  }
525 
526 
527  /**
528  * Matrix subtraction.
529  *
530  * \param A matrix
531  * \return this matrix
532  */
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  }
550 
551 
552  /**
553  * Scale matrix.
554  *
555  * \param factor factor
556  * \return this matrix
557  */
558  JMatrixND& mul(const double factor)
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  }
568 
569 
570  /**
571  * Scale matrix.
572  *
573  * \param factor factor
574  * \return this matrix
575  */
576  JMatrixND& div(const double factor)
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  }
586 
587 
588  /**
589  * Matrix multiplication.
590  *
591  * \param A matrix
592  * \param B matrix
593  * \return this matrix
594  */
596  const JMatrixND& B)
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  }
683 
684 
685  /**
686  * Equality.
687  *
688  * \param A matrix
689  * \param eps numerical precision
690  * \return true if matrices identical; else false
691  */
692  bool equals(const JMatrixND& A,
693  const double eps = std::numeric_limits<double>::min()) const
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  }
715 
716 
717  /**
718  * Test identity.
719  *
720  * \param eps numerical precision
721  * \return true if identity matrix; else false
722  */
723  bool isIdentity(const double eps = std::numeric_limits<double>::min()) const
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  }
740 
741 
742  /**
743  * Test symmetry.
744  *
745  * \param eps numerical precision
746  * \return true if symmetric matrix; else false
747  */
748  bool isSymmetric(const double eps = std::numeric_limits<double>::min()) const
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  }
760 
761 
762  /**
763  * Get dot product.
764  *
765  * The dot product corresponds to \f[ v^{T} \times A \times v \f].
766  *
767  * \param v vector
768  * \return dot product
769  */
770  double getDot(const JVectorND& v) const
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  }
789 
790 
791  /**
792  * Read matrix from input.
793  *
794  * \param in reader
795  * \param A matrix
796  * \return reader
797  */
798  friend inline JReader& operator>>(JReader& in, JMatrixND& A)
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  }
814 
815 
816  /**
817  * Write matrix to output.
818  *
819  * \param out writer
820  * \param A matrix
821  * \return writer
822  */
823  friend inline JWriter& operator<<(JWriter& out, const JMatrixND& A)
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  }
835 
836 
837  /**
838  * Print ASCII formatted output.
839  *
840  * \param out output stream
841  * \param A matrix
842  * \return output stream
843  */
844  friend inline std::ostream& operator<<(std::ostream& out, const JMatrixND& A)
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  }
861 
862 
863  protected:
864  /*
865  * Swap rows.
866  *
867  * \param r1 row
868  * \param r2 row
869  */
870  void rswap(size_t r1, size_t r2)
871  {
872  JMatrixND_t& A = getInstance();
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  }
880 
881 
882  /**
883  * Swap columns.
884  *
885  * \param c1 column
886  * \param c2 column
887  */
888  void cswap(size_t c1, size_t c2)
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  }
899  };
900 }
901 
902 #endif
JMatrixND(const JMatrixND &A)
Copy constructor.
Definition: JMatrixND.hh:393
JMatrixND_t ws
Definition: JMatrixND.hh:351
Exception for failure of memory allocation.
Definition: JException.hh:322
General exception.
Definition: JException.hh:24
data_type w[N+1][M+1]
Definition: JPolint.hh:867
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:533
double at(size_t row, size_t col) const
Get matrix element.
Definition: JMatrixND.hh:306
void clear()
Clear memory.
Definition: JMatrixND.hh:83
JMatrixND & mul(const double factor)
Scale matrix.
Definition: JMatrixND.hh:558
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
JMatrixND & reset()
Set matrix to the null matrix.
Definition: JMatrixND.hh:456
void resize(const size_t size)
Resize matrix.
Definition: JMatrixND.hh:443
const double * operator[](size_t row) const
Get row data.
Definition: JMatrixND.hh:255
JMatrixND_t & getInstance()
Get work space.
Definition: JMatrixND.hh:358
JMatrixND & operator=(const JMatrixND &A)
Assignment operator.
Definition: JMatrixND.hh:415
~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:280
JMatrixND(const size_t size)
Constructor.
Definition: JMatrixND.hh:381
NxN matrix.
Definition: JMatrixND.hh:345
friend JWriter & operator<<(JWriter &out, const JMatrixND &A)
Write matrix to output.
Definition: JMatrixND.hh:823
static const double C
Physics constants.
const int n
Definition: JPolint.hh:786
void set(const JMatrixND_t &A)
Set matrix.
Definition: JMatrixND.hh:152
JMatrixND_t()
Default constructor.
Definition: JMatrixND.hh:40
bool isIdentity(const double eps=std::numeric_limits< double >::min()) const
Test identity.
Definition: JMatrixND.hh:723
Template definition of auxiliary base class for comparison of data structures.
Definition: JEquals.hh:24
double * data()
Get pointer to data.
Definition: JMatrixND.hh:243
JMatrixND & add(const JMatrixND &A)
Matrix addition.
Definition: JMatrixND.hh:508
Interface for binary input.
bool equals(const JMatrixND &A, const double eps=std::numeric_limits< double >::min()) const
Equality.
Definition: JMatrixND.hh:692
void rswap(size_t r1, size_t r2)
Definition: JMatrixND.hh:870
friend JReader & operator>>(JReader &in, JMatrixND &A)
Read matrix from input.
Definition: JMatrixND.hh:798
I/O manipulators.
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
JMatrixND & negate()
Negate matrix.
Definition: JMatrixND.hh:490
double & at(size_t row, size_t col)
Get matrix element.
Definition: JMatrixND.hh:324
size_t __n
dimension of matrix
Definition: JMatrixND.hh:337
JMatrixND & operator=(JMatrixND &&A)
Move assignment operator.
Definition: JMatrixND.hh:428
JMatrixND_t(JMatrixND_t &&A)
Move constructor.
Definition: JMatrixND.hh:64
double * __p
pointer to data
Definition: JMatrixND.hh:336
bool isSymmetric(const double eps=std::numeric_limits< double >::min()) const
Test symmetry.
Definition: JMatrixND.hh:748
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
JMatrixND_t & transpose()
Transpose.
Definition: JMatrixND.hh:180
Base class for data structures with artithmetic capabilities.
void cswap(size_t c1, size_t c2)
Swap columns.
Definition: JMatrixND.hh:888
size_t capacity() const
Get capacity of dimension.
Definition: JMatrixND.hh:210
JMatrixND()
Default constructor.
Definition: JMatrixND.hh:370
void swap(JMatrixND_t &A)
Swap matrices.
Definition: JMatrixND.hh:165
int j
Definition: JPolint.hh:792
JMatrixND(JMatrixND &&A)
Move constructor.
Definition: JMatrixND.hh:404
Exception for accessing an index in a collection that is outside of its range.
Definition: JException.hh:106
data_type v[N+1][M+1]
Definition: JPolint.hh:866
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:770
const double * data() const
Get pointer to data.
Definition: JMatrixND.hh:232
bool empty() const
Check emptyness.
Definition: JMatrixND.hh:221
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:293
size_t __m
capacity of matrix
Definition: JMatrixND.hh:338
p3
Definition: module-Z:fit.sh:74
Basic NxN matrix.
Definition: JMatrixND.hh:36
JMatrixND & setIdentity()
Set to identity matrix.
Definition: JMatrixND.hh:473
double * operator[](size_t row)
Get row data.
Definition: JMatrixND.hh:267
Nx1 matrix.
Definition: JVectorND.hh:21
JMatrixND & div(const double factor)
Scale matrix.
Definition: JMatrixND.hh:576
friend std::ostream & operator<<(std::ostream &out, const JMatrixND &A)
Print ASCII formatted output.
Definition: JMatrixND.hh:844
JMatrixND & mul(const JMatrixND &A, const JMatrixND &B)
Matrix multiplication.
Definition: JMatrixND.hh:595