Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
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.
 
const data_typeoperator[] (int row) const
 Get row data.
 
data_typeoperator[] (int row)
 Get row data.
 
JTable2Dnegate ()
 Negate table.
 
JTable2Dadd (const JTable2D &table)
 Add table.
 
JTable2Dsub (const JTable2D &table)
 Subtract table.
 
JTable2Dmul (const double factor)
 Scale table.
 
JTable2Ddiv (const double factor)
 Scale table.
 
JFirst_t & mul (const JSecond_t &object)
 Multiply with object.
 

Static Public Member Functions

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

Protected Attributes

data_type data [NX][NY]
 

Friends

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

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

◆ data_type

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

Definition at line 30 of file JTable2D.hh.

Constructor & Destructor Documentation

◆ JTable2D()

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
int j
Definition JPolint.hh:801
data_type data[NX][NY]
Definition JTable2D.hh:219

Member Function Documentation

◆ getNX()

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 }

◆ getNY()

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 }

◆ operator[]() [1/2]

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 };

◆ operator[]() [2/2]

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 };

◆ negate()

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 }

◆ add()

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 }

◆ sub()

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 }

◆ mul() [1/2]

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 }

◆ div()

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 }

◆ mul() [2/2]

template<class JFirst_t , class JSecond_t >
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 Symbol Documentation

◆ operator>>

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 }

◆ operator<<

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 }

Member Data Documentation

◆ data

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: