Jpp  19.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
JTOOLS::JTable2D< NX, NY, JData_t > Struct Template Reference

2D table with arithmetic capabilities. More...

#include <JTable2D.hh>

Inheritance diagram for JTOOLS::JTable2D< NX, NY, JData_t >:
JMATH::JMath< JFirst_t, JSecond_t >

Public Types

typedef JData_t data_type
 

Public Member Functions

 JTable2D ()
 Default constructor. More...
 
const data_typeoperator[] (int row) const
 Get row data. More...
 
data_typeoperator[] (int row)
 Get row data. More...
 
JTable2Dnegate ()
 Negate table. More...
 
JTable2Dadd (const JTable2D &table)
 Add table. More...
 
JTable2Dsub (const JTable2D &table)
 Subtract table. More...
 
JTable2Dmul (const double factor)
 Scale table. More...
 
JTable2Ddiv (const double factor)
 Scale table. More...
 
JFirst_t & mul (const JSecond_t &object)
 Multiply with object. More...
 

Static Public Member Functions

static int getNX ()
 Get number of rows. More...
 
static int getNY ()
 Get number of columns. More...
 

Protected Attributes

data_type data [NX][NY]
 

Friends

JReaderoperator>> (JReader &in, JTable2D &table)
 Read table from input. More...
 
JWriteroperator<< (JWriter &out, const JTable2D &table)
 Write table to output. More...
 

Detailed Description

template<unsigned int NX, unsigned int NY, class JData_t = double>
struct JTOOLS::JTable2D< NX, NY, JData_t >

2D table with arithmetic capabilities.

Definition at line 27 of file JTable2D.hh.

Member Typedef Documentation

template<unsigned int NX, unsigned int NY, class JData_t = double>
typedef JData_t JTOOLS::JTable2D< NX, NY, JData_t >::data_type

Definition at line 30 of file JTable2D.hh.

Constructor & Destructor Documentation

template<unsigned int NX, unsigned int NY, class JData_t = double>
JTOOLS::JTable2D< NX, NY, JData_t >::JTable2D ( )
inline

Default constructor.

Definition at line 35 of file JTable2D.hh.

36  {
37  for (int i = 0; i != NX; ++i) {
38  for (int j = 0; j != NY; ++j) {
39  data[i][j] = JMATH::zero;
40  }
41  }
42  }
static const JZero zero
Function object to assign zero value.
Definition: JZero.hh:105
data_type data[NX][NY]
Definition: JTable2D.hh:219
int j
Definition: JPolint.hh:792

Member Function Documentation

template<unsigned int NX, unsigned int NY, class JData_t = double>
static int JTOOLS::JTable2D< NX, NY, JData_t >::getNX ( )
inlinestatic

Get number of rows.

Returns
number of rows

Definition at line 50 of file JTable2D.hh.

51  {
52  return NX;
53  }
template<unsigned int NX, unsigned int NY, class JData_t = double>
static int JTOOLS::JTable2D< NX, NY, JData_t >::getNY ( )
inlinestatic

Get number of columns.

Returns
number of columns

Definition at line 61 of file JTable2D.hh.

62  {
63  return NY;
64  }
template<unsigned int NX, unsigned int NY, class JData_t = double>
const data_type* JTOOLS::JTable2D< NX, NY, JData_t >::operator[] ( int  row) const
inline

Get row data.

Parameters
rowrow number
Returns
row data

Definition at line 73 of file JTable2D.hh.

74  {
75  return data[row];
76  };
data_type data[NX][NY]
Definition: JTable2D.hh:219
template<unsigned int NX, unsigned int NY, class JData_t = double>
data_type* JTOOLS::JTable2D< NX, NY, JData_t >::operator[] ( int  row)
inline

Get row data.

Parameters
rowrow number
Returns
row data

Definition at line 85 of file JTable2D.hh.

86  {
87  return data[row];
88  };
data_type data[NX][NY]
Definition: JTable2D.hh:219
template<unsigned int NX, unsigned int NY, class JData_t = double>
JTable2D& JTOOLS::JTable2D< NX, NY, JData_t >::negate ( )
inline

Negate table.

Returns
this table

Definition at line 96 of file JTable2D.hh.

97  {
98  for (int i = 0; i != NX; ++i) {
99  for (int j = 0; j != NY; ++j) {
100  data[i][j] = -data[i][j];
101  }
102  }
103 
104  return *this;
105  }
data_type data[NX][NY]
Definition: JTable2D.hh:219
int j
Definition: JPolint.hh:792
template<unsigned int NX, unsigned int NY, class JData_t = double>
JTable2D& JTOOLS::JTable2D< NX, NY, JData_t >::add ( const JTable2D< NX, NY, JData_t > &  table)
inline

Add table.

Parameters
tabletable
Returns
this table

Definition at line 114 of file JTable2D.hh.

115  {
116  for (int i = 0; i != NX; ++i) {
117  for (int j = 0; j != NY; ++j) {
118  data[i][j] += table.data[i][j];
119  }
120  }
121 
122  return *this;
123  }
data_type data[NX][NY]
Definition: JTable2D.hh:219
int j
Definition: JPolint.hh:792
template<unsigned int NX, unsigned int NY, class JData_t = double>
JTable2D& JTOOLS::JTable2D< NX, NY, JData_t >::sub ( const JTable2D< NX, NY, JData_t > &  table)
inline

Subtract table.

Parameters
tabletable
Returns
this table

Definition at line 132 of file JTable2D.hh.

133  {
134  for (int i = 0; i != NX; ++i) {
135  for (int j = 0; j != NY; ++j) {
136  data[i][j] -= table.data[i][j];
137  }
138  }
139 
140  return *this;
141  }
data_type data[NX][NY]
Definition: JTable2D.hh:219
int j
Definition: JPolint.hh:792
template<unsigned int NX, unsigned int NY, class JData_t = double>
JTable2D& JTOOLS::JTable2D< NX, NY, JData_t >::mul ( const double  factor)
inline

Scale table.

Parameters
factormultiplication factor
Returns
this table

Definition at line 150 of file JTable2D.hh.

151  {
152  for (int i = 0; i != NX; ++i) {
153  for (int j = 0; j != NY; ++j) {
154  data[i][j] *= factor;
155  }
156  }
157 
158  return *this;
159  }
data_type data[NX][NY]
Definition: JTable2D.hh:219
int j
Definition: JPolint.hh:792
template<unsigned int NX, unsigned int NY, class JData_t = double>
JTable2D& JTOOLS::JTable2D< NX, NY, JData_t >::div ( const double  factor)
inline

Scale table.

Parameters
factordivision factor
Returns
this table

Definition at line 168 of file JTable2D.hh.

169  {
170  for (int i = 0; i != NX; ++i) {
171  for (int j = 0; j != NY; ++j) {
172  data[i][j] /= factor;
173  }
174  }
175 
176  return *this;
177  }
data_type data[NX][NY]
Definition: JTable2D.hh:219
int j
Definition: JPolint.hh:792
template<class JFirst_t, class JSecond_t = JNullType>
JFirst_t& JMATH::JMath< JFirst_t, JSecond_t >::mul ( const JSecond_t &  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

template<unsigned int NX, unsigned int NY, class JData_t = double>
JReader& operator>> ( JReader in,
JTable2D< NX, NY, JData_t > &  table 
)
friend

Read table from input.

Parameters
inreader
tabletable
Returns
reader

Definition at line 187 of file JTable2D.hh.

188  {
189  for (int i = 0; i != NX; ++i) {
190  for (int j = 0; j != NY; ++j) {
191  in >> table.data[i][j];
192  }
193  }
194 
195  return in;
196  }
data_type data[NX][NY]
Definition: JTable2D.hh:219
then fatal The output file must have the wildcard in the e g root fi 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:48
int j
Definition: JPolint.hh:792
template<unsigned int NX, unsigned int NY, class JData_t = double>
JWriter& operator<< ( JWriter out,
const JTable2D< NX, NY, JData_t > &  table 
)
friend

Write table to output.

Parameters
outwriter
tabletable
Returns
writer

Definition at line 206 of file JTable2D.hh.

207  {
208  for (int i = 0; i != NX; ++i) {
209  for (int j = 0; j != NY; ++j) {
210  out << table.data[i][j];
211  }
212  }
213 
214  return out;
215  }
data_type data[NX][NY]
Definition: JTable2D.hh:219
int j
Definition: JPolint.hh:792

Member Data Documentation

template<unsigned int NX, unsigned int NY, class JData_t = double>
data_type JTOOLS::JTable2D< NX, NY, JData_t >::data[NX][NY]
protected

Definition at line 219 of file JTable2D.hh.


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