1 #ifndef __JMATH__JMATRIXND__ 
    2 #define __JMATH__JMATRIXND__ 
   21 namespace JPP { 
using namespace JMATH; }
 
  104       if (size != this->
__n) {
 
  106         if (size > this->
__m) {
 
  116             THROW(
JNewException, 
"JMatrixND::resize(" << size << 
"): Memory allocation failure.");
 
  132       double* p0 = this->
data();
 
  133       double* 
p1 = this->
data();
 
  135       for (
size_t i = this->
size(); 
i != 0; --
i, ++
p1) {
 
  139       for (
size_t i = this->
size(); 
i != 1; --
i, p1 += this->
size()) {
 
  140         memcpy(p1, p0, this->
size() * 
sizeof(
double));
 
  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));
 
  282       return *(
__p + row*
__n + col);
 
  295       return *(
__p + row*
__n + col);
 
  306     double at(
size_t row, 
size_t col)
 const 
  308       if (row >= this->
size() ||
 
  309           col >= this->
size()) {
 
  313       return (*
this)(row, col);
 
  324     double& 
at(
size_t row, 
size_t col)
 
  326       if (row >= this->
size() ||
 
  327           col >= this->
size()) {
 
  331       return (*
this)(row, col);
 
  347     public JMath  <JMatrixND>,
 
  477       for (
size_t i = 0; 
i != this->
size(); ++
i) {
 
  492       double* p = this->
data();
 
  494       for (
size_t i = this->
size()*this->
size(); 
i != 0; --
i, ++p) {
 
  512         double*       p = this->
data();
 
  513         const double* q = A.
data();
 
  515         for (
size_t i = this->
size()*this->
size(); 
i != 0; --
i, ++p, ++q) {
 
  537         double*       p = this->
data();
 
  538         const double* q = A.
data();
 
  540         for (
size_t i = this->
size()*this->
size(); 
i != 0; --
i, ++p, ++q) {
 
  560       double* p = this->
data();
 
  562       for (
size_t i = this->
size()*this->
size(); 
i != 0; --
i, ++p) {
 
  578       double* p = this->
data();
 
  580       for (
size_t i = this->
size()*this->
size(); 
i != 0; --
i, ++p) {
 
  602         if (!this->
empty()) {
 
  611           for (row = 0; row + 4 <= this->
size(); row += 4) {              
 
  613             double* p0 = (*this)[row + 0];
 
  614             double* 
p1 = (*this)[row + 1];
 
  615             double* 
p2 = (*this)[row + 2];
 
  616             double* 
p3 = (*this)[row + 3];
 
  618             for (
size_t col = 0; col != this->
size(); ++col, ++p0, ++
p1, ++
p2, ++
p3) {
 
  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];
 
  630               const double* c0 =  C[col];
 
  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];
 
  639               for ( ; i != this->
size(); ++
i, ++a0, ++a1, ++a2, ++a3, ++c0) {
 
  653           for ( ; row != this->
size(); ++row) {                  
 
  655             double* p0 = (*this)[row + 0];
 
  657             for (
size_t col = 0; col != this->
size(); ++col, ++p0) {
 
  661               const double* a0 =  A[row + 0];
 
  662               const double* c0 =  C[col];
 
  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];
 
  668               for ( ; i != this->
size(); ++
i, ++a0, ++c0) {
 
  693                 const double     eps = std::numeric_limits<double>::min())
 const 
  697         for (
size_t row = 0; row != this->
size(); ++row) {
 
  699           const double* p = (*this)[row];
 
  700           const double* q = A      [row];
 
  702           for (
size_t i = this->
size(); 
i != 0; --
i, ++p, ++q) {
 
  703             if (fabs(*p - *q) > eps) {
 
  723     bool isIdentity(
const double eps = std::numeric_limits<double>::min())
 const 
  725       for (
size_t i = 0; 
i != this->
size(); ++
i) {
 
  727         if (fabs(1.0 - (*
this)(
i,
i)) > eps) {
 
  731         for (
size_t j = 0; 
j != 
i; ++
j) {
 
  732           if (fabs((*
this)(
i,
j)) > eps || fabs((*
this)(
j,
i)) > eps) {
 
  748     bool isSymmetric(
const double eps = std::numeric_limits<double>::min())
 const 
  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) {
 
  774       for (
size_t i = 0; 
i != v.size(); ++
i) {
 
  776         const double* p = (*this)[
i];
 
  780         for (JVectorND::const_iterator 
y = v.begin(); 
y != v.end(); ++
y, ++p) {
 
  808       for (
double* p = A.
data(); n != 0; --
n, ++p) {
 
  829       for (
const double* p = A.
data(); n != 0; --
n, ++p) {
 
  848       const JFormat format(out, getFormat<JMatrixND>(
JFormat_t(10, 3, std::ios::fixed | std::ios::showpos)));
 
  850       for (
size_t row = 0; row != A.
size(); ++row) {
 
  852         for (
size_t col = 0; col != A.
size(); ++col) {
 
  853           out << format << 
A(row,col) << 
' ';
 
  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));
 
  893       double* 
p2 = this->
data() + c2;
 
  895       for (
size_t i = this->
size(); 
i != 0; --
i, p1 += this->
size(), p2 += this->
size()) {
 
JMatrixND(const JMatrixND &A)
Copy constructor. 
 
Exception for failure of memory allocation. 
 
Interface for binary output. 
 
Auxiliary base class for aritmetic operations of derived class types. 
 
JMatrixND_t(const JMatrixND_t &A)
Copy constructor. 
 
JMatrixND & sub(const JMatrixND &A)
Matrix subtraction. 
 
double at(size_t row, size_t col) const 
Get matrix element. 
 
void clear()
Clear memory. 
 
JMatrixND & mul(const double factor)
Scale matrix. 
 
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message. 
 
JMatrixND & reset()
Set matrix to the null matrix. 
 
void resize(const size_t size)
Resize matrix. 
 
const double * operator[](size_t row) const 
Get row data. 
 
JMatrixND_t & getInstance()
Get work space. 
 
JMatrixND & operator=(const JMatrixND &A)
Assignment operator. 
 
~JMatrixND_t()
Destructor. 
 
double operator()(const size_t row, const size_t col) const 
Get matrix element. 
 
JMatrixND(const size_t size)
Constructor. 
 
friend JWriter & operator<<(JWriter &out, const JMatrixND &A)
Write matrix to output. 
 
static const double C
Physics constants. 
 
void set(const JMatrixND_t &A)
Set matrix. 
 
JMatrixND_t()
Default constructor. 
 
bool isIdentity(const double eps=std::numeric_limits< double >::min()) const 
Test identity. 
 
Template definition of auxiliary base class for comparison of data structures. 
 
double * data()
Get pointer to data. 
 
JMatrixND & add(const JMatrixND &A)
Matrix addition. 
 
Interface for binary input. 
 
bool equals(const JMatrixND &A, const double eps=std::numeric_limits< double >::min()) const 
Equality. 
 
void rswap(size_t r1, size_t r2)
 
friend JReader & operator>>(JReader &in, JMatrixND &A)
Read matrix from input. 
 
size_t size() const 
Get dimension of matrix. 
 
TCanvas * c1
Global variables to handle mouse events. 
 
JMatrixND & negate()
Negate matrix. 
 
double & at(size_t row, size_t col)
Get matrix element. 
 
size_t __n
dimension of matrix 
 
JMatrixND & operator=(JMatrixND &&A)
Move assignment operator. 
 
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
 
JMatrixND_t(JMatrixND_t &&A)
Move constructor. 
 
double * __p
pointer to data 
 
bool isSymmetric(const double eps=std::numeric_limits< double >::min()) const 
Test symmetry. 
 
void resize(const size_t size)
Resize matrix. 
 
JMatrixND_t & reset()
Set matrix to the null matrix. 
 
JMatrixND_t & transpose()
Transpose. 
 
Base class for data structures with artithmetic capabilities. 
 
void cswap(size_t c1, size_t c2)
Swap columns. 
 
size_t capacity() const 
Get capacity of dimension. 
 
JMatrixND()
Default constructor. 
 
void swap(JMatrixND_t &A)
Swap matrices. 
 
JMatrixND(JMatrixND &&A)
Move constructor. 
 
Exception for accessing an index in a collection that is outside of its range. 
 
source $JPP_DIR setenv csh $JPP_DIR &dev null eval JShellParser o a A
 
double getDot(const JVectorND &v) const 
Get dot product. 
 
const double * data() const 
Get pointer to data. 
 
bool empty() const 
Check emptyness. 
 
double & operator()(const size_t row, const size_t col)
Get matrix element. 
 
size_t __m
capacity of matrix 
 
JMatrixND & setIdentity()
Set to identity matrix. 
 
double * operator[](size_t row)
Get row data. 
 
JMatrixND & div(const double factor)
Scale matrix. 
 
friend std::ostream & operator<<(std::ostream &out, const JMatrixND &A)
Print ASCII formatted output. 
 
JMatrixND & mul(const JMatrixND &A, const JMatrixND &B)
Matrix multiplication.