1#ifndef __JMATH__JMATRIXND__ 
    2#define __JMATH__JMATRIXND__ 
   21namespace JPP { 
using namespace JMATH; }
 
  106        if (size > this->
__m) {
 
 
  132      double* p0 = this->
data();
 
  133      double* 
p1 = this->
data();
 
  135      if (!this->
empty()) {
 
  137        for (
size_t i = this->
size(); i != 0; --i, ++
p1) {
 
  141        for (
size_t i = this->
size(); i != 1; --i, 
p1 += this->
size()) {
 
  142          memcpy(
p1, p0, this->
size() * 
sizeof(
double));
 
 
  159      memcpy(this->
data(), A.
data(), A.size() * A.size() * 
sizeof(
double));
 
 
  187      for (
size_t row = 0; row != this->
size(); ++row) {
 
  188        for (
size_t col = 0; col != row; ++col) {
 
  189          swap((*
this)(row,col), (*
this)(col,row));
 
 
  285      return *(
__p + row*
__n + col);
 
 
  298      return *(
__p + row*
__n + col);
 
 
  309    double at(
size_t row, 
size_t col)
 const 
  311      if (row >= this->
size() ||
 
  312          col >= this->
size()) {
 
  316      return (*
this)(row, col);
 
 
  327    double& 
at(
size_t row, 
size_t col)
 
  329      if (row >= this->
size() ||
 
  330          col >= this->
size()) {
 
  334      return (*
this)(row, col);
 
 
 
  350    public JMath  <JMatrixND>,
 
  465      A.resize(this->
size());
 
 
  480      for (
size_t i = 0; i != this->
size(); ++i) {
 
 
  495      double* p = this->
data();
 
  497      for (
size_t i = this->
size()*this->
size(); i != 0; --i, ++p) {
 
 
  515        double*       p = this->
data();
 
  516        const double* q = A.data();
 
  518        for (
size_t i = this->
size()*this->
size(); i != 0; --i, ++p, ++q) {
 
 
  540        double*       p = this->
data();
 
  541        const double* q = A.data();
 
  543        for (
size_t i = this->
size()*this->
size(); i != 0; --i, ++p, ++q) {
 
 
  563      double* p = this->
data();
 
  565      for (
size_t i = this->
size()*this->
size(); i != 0; --i, ++p) {
 
 
  581      double* p = this->
data();
 
  583      for (
size_t i = this->
size()*this->
size(); i != 0; --i, ++p) {
 
 
  601      if (A.size() == B.size()) {
 
  605        if (!this->
empty()) {
 
  614          for (row = 0; row + 4 <= this->
size(); row += 4) {              
 
  616            double* p0 = (*this)[row + 0];
 
  617            double* 
p1 = (*this)[row + 1];
 
  618            double* p2 = (*this)[row + 2];
 
  619            double* p3 = (*this)[row + 3];
 
  621            for (
size_t col = 0; col != this->
size(); ++col, ++p0, ++
p1, ++p2, ++p3) {
 
  628              const double* a0 =  A[row + 0];
 
  629              const double* a1 =  A[row + 1];
 
  630              const double* a2 =  A[row + 2];
 
  631              const double* a3 =  A[row + 3];
 
  633              const double* c0 =  C[col];
 
  635              for (i = 0; i + 4 <= this->
size(); i += 4, a0 += 4, a1 += 4, a2 += 4, a3 += 4, c0 += 4) {
 
  636                w0  +=  a0[0] * c0[0]  +  a0[1] * c0[1]  +  a0[2] * c0[2]  +  a0[3] * c0[3];
 
  637                w1  +=  a1[0] * c0[0]  +  a1[1] * c0[1]  +  a1[2] * c0[2]  +  a1[3] * c0[3];
 
  638                w2  +=  a2[0] * c0[0]  +  a2[1] * c0[1]  +  a2[2] * c0[2]  +  a2[3] * c0[3];
 
  639                w3  +=  a3[0] * c0[0]  +  a3[1] * c0[1]  +  a3[2] * c0[2]  +  a3[3] * c0[3];
 
  642              for ( ; i != this->
size(); ++i, ++a0, ++a1, ++a2, ++a3, ++c0) {
 
  656          for ( ; row != this->
size(); ++row) {                  
 
  658            double* p0 = (*this)[row + 0];
 
  660            for (
size_t col = 0; col != this->
size(); ++col, ++p0) {
 
  664              const double* a0 =  A[row + 0];
 
  665              const double* c0 =  C[col];
 
  667              for (i = 0; i + 4 <= this->
size(); i += 4, a0 += 4, c0 += 4) {
 
  668                w0  +=  a0[0] * c0[0]  +  a0[1] * c0[1]  +  a0[2] * c0[2]  +  a0[3] * c0[3];
 
  671              for ( ; i != this->
size(); ++i, ++a0, ++c0) {
 
  681        THROW(
JException, 
"JMatrixND::mul() inconsistent matrix dimensions " << A.size() << 
' ' << B.size());
 
 
  696                const double     eps = std::numeric_limits<double>::min())
 const 
  700        for (
size_t row = 0; row != this->
size(); ++row) {
 
  702          const double* p = (*this)[row];
 
  703          const double* q = A      [row];
 
  705          for (
size_t i = this->
size(); i != 0; --i, ++p, ++q) {
 
  706            if (fabs(*p - *q) > eps) {
 
 
  726    bool isIdentity(
const double eps = std::numeric_limits<double>::min())
 const 
  728      for (
size_t i = 0; i != this->
size(); ++i) {
 
  730        if (fabs(1.0 - (*
this)(i,i)) > eps) {
 
  734        for (
size_t j = 0; j != i; ++j) {
 
  735          if (fabs((*
this)(i,j)) > eps || fabs((*
this)(j,i)) > eps) {
 
 
  751    bool isSymmetric(
const double eps = std::numeric_limits<double>::min())
 const 
  753      for (
size_t i = 0; i != this->
size(); ++i) {
 
  754        for (
size_t j = 0; j != i; ++j) {
 
  755          if (fabs((*
this)(i,j) - (*
this)(j,i)) > eps) {
 
 
  777      for (
size_t i = 0; i != v.size(); ++i) {
 
  779        const double* p = (*this)[i];
 
  783        for (JVectorND::const_iterator y = v.begin(); y != v.end(); ++y, ++p) {
 
 
  809      size_t n = A.size() * A.size();      
 
  811      for (
double* p = A.data(); n != 0; --n, ++p) {
 
 
  830      size_t n = A.size() * A.size();
 
  832      for (
const double* p = A.data(); n != 0; --n, ++p) {
 
 
  853      for (
size_t row = 0; row != A.size(); ++row) {
 
  855        for (
size_t col = 0; col != A.size(); ++col) {
 
  856          out << format << A(row,col) << 
' ';
 
 
  877      A.resize(this->
size());
 
  879      memcpy(A.data(),    (*
this)[r1], this->size() * 
sizeof(
double));
 
  880      memcpy((*
this)[r1], (*
this)[r2], this->
size() * 
sizeof(
double));
 
  881      memcpy((*
this)[r2], A.data(),    this->size() * 
sizeof(
double));
 
 
  896      double* p2 = this->
data() + c2;
 
  898      for (
size_t i = this->
size(); i != 0; --i, 
p1 += this->
size(), p2 += this->
size()) {
 
 
 
TCanvas * c1
Global variables to handle mouse events.
 
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
 
JFormat_t & getFormat()
Get format for given type.
 
Base class for data structures with artithmetic capabilities.
 
Interface for binary input.
 
Interface for binary output.
 
Exception for accessing an index in a collection that is outside of its range.
 
Exception for failure of memory allocation.
 
Auxiliary classes and methods for mathematical operations.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
Template definition of auxiliary base class for comparison of data structures.
 
Auxiliary base class for aritmetic operations of derived class types.
 
size_t size() const
Get dimension of matrix.
 
double at(size_t row, size_t col) const
Get matrix element.
 
JMatrixND_t & reset()
Set matrix to the null matrix.
 
~JMatrixND_t()
Destructor.
 
void clear()
Clear memory.
 
void set(const JMatrixND_t &A)
Set matrix.
 
void swap(JMatrixND_t &A)
Swap matrices.
 
size_t capacity() const
Get capacity of dimension.
 
JMatrixND_t & transpose()
Transpose.
 
double & operator()(const size_t row, const size_t col)
Get matrix element.
 
JMatrixND_t(const JMatrixND_t &A)
Copy constructor.
 
double * __p
pointer to data
 
double operator()(const size_t row, const size_t col) const
Get matrix element.
 
JMatrixND_t()
Default constructor.
 
size_t __m
capacity of matrix
 
const double * data() const
Get pointer to data.
 
const double * operator[](size_t row) const
Get row data.
 
double * data()
Get pointer to data.
 
bool empty() const
Check emptyness.
 
double & at(size_t row, size_t col)
Get matrix element.
 
double * operator[](size_t row)
Get row data.
 
JMatrixND_t(JMatrixND_t &&A)
Move constructor.
 
void resize(const size_t size)
Resize matrix.
 
size_t __n
dimension of matrix
 
friend JReader & operator>>(JReader &in, JMatrixND &A)
Read matrix from input.
 
void cswap(size_t c1, size_t c2)
Swap columns.
 
JMatrixND()
Default constructor.
 
friend std::ostream & operator<<(std::ostream &out, const JMatrixND &A)
Print ASCII formatted output.
 
JMatrixND & negate()
Negate matrix.
 
JMatrixND & add(const JMatrixND &A)
Matrix addition.
 
JMatrixND & setIdentity()
Set to identity matrix.
 
JMatrixND & div(const double factor)
Scale matrix.
 
void resize(const size_t size)
Resize matrix.
 
bool equals(const JMatrixND &A, const double eps=std::numeric_limits< double >::min()) const
Equality.
 
bool isIdentity(const double eps=std::numeric_limits< double >::min()) const
Test identity.
 
JMatrixND & reset()
Set matrix to the null matrix.
 
double getDot(const JVectorND &v) const
Get dot product.
 
friend JWriter & operator<<(JWriter &out, const JMatrixND &A)
Write matrix to output.
 
JMatrixND & operator=(JMatrixND &&A)
Move assignment operator.
 
JMatrixND(JMatrixND &&A)
Move constructor.
 
JMatrixND & mul(const JMatrixND &A, const JMatrixND &B)
Matrix multiplication.
 
JMatrixND(const JMatrixND &A)
Copy constructor.
 
JMatrixND & sub(const JMatrixND &A)
Matrix subtraction.
 
bool isSymmetric(const double eps=std::numeric_limits< double >::min()) const
Test symmetry.
 
JMatrixND_t & getInstance()
Get work space.
 
JMatrixND(const size_t size)
Constructor.
 
void rswap(size_t r1, size_t r2)
 
JMatrixND & operator=(const JMatrixND &A)
Assignment operator.
 
JMatrixND & mul(const double factor)
Scale matrix.