Jpp 20.0.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JTOOLS::JTable1D< NX, JData_t > Struct Template Reference

1D table with arithmetic capabilities. More...

#include <JTable1D.hh>

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

Public Types

typedef JData_t data_type
 

Public Member Functions

 JTable1D ()
 Default constructor.
 
const data_typeoperator[] (int entry) const
 Get entry data.
 
data_typeoperator[] (int entry)
 Get entry data.
 
JTable1Dnegate ()
 Negate table.
 
JTable1Dadd (const JTable1D &table)
 Add table.
 
JTable1Dsub (const JTable1D &table)
 Subtract table.
 
JTable1Dmul (const double factor)
 Scale table.
 
JTable1Ddiv (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 entries.
 

Protected Attributes

data_type data [NX]
 

Friends

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

Detailed Description

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

1D table with arithmetic capabilities.

Definition at line 27 of file JTable1D.hh.

Member Typedef Documentation

◆ data_type

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

Definition at line 30 of file JTable1D.hh.

Constructor & Destructor Documentation

◆ JTable1D()

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

Default constructor.

Definition at line 35 of file JTable1D.hh.

36 {
37 for (int i = 0; i != NX; ++i) {
38 data[i] = JMATH::zero;
39 }
40 }
static const JZero zero
Function object to assign zero value.
Definition JZero.hh:105
data_type data[NX]
Definition JTable1D.hh:191

Member Function Documentation

◆ getNX()

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

Get number of entries.

Returns
number of entries

Definition at line 48 of file JTable1D.hh.

49 {
50 return NX;
51 }

◆ operator[]() [1/2]

template<unsigned int NX, class JData_t = double>
const data_type & JTOOLS::JTable1D< NX, JData_t >::operator[] ( int entry) const
inline

Get entry data.

Parameters
entryentry number
Returns
entry data

Definition at line 60 of file JTable1D.hh.

61 {
62 return data[entry];
63 };

◆ operator[]() [2/2]

template<unsigned int NX, class JData_t = double>
data_type & JTOOLS::JTable1D< NX, JData_t >::operator[] ( int entry)
inline

Get entry data.

Parameters
entryentry number
Returns
entry data

Definition at line 72 of file JTable1D.hh.

73 {
74 return data[entry];
75 };

◆ negate()

template<unsigned int NX, class JData_t = double>
JTable1D & JTOOLS::JTable1D< NX, JData_t >::negate ( )
inline

Negate table.

Returns
this table

Definition at line 83 of file JTable1D.hh.

84 {
85 for (int i = 0; i != NX; ++i) {
86 data[i] = -data[i];
87 }
88
89 return *this;
90 }

◆ add()

template<unsigned int NX, class JData_t = double>
JTable1D & JTOOLS::JTable1D< NX, JData_t >::add ( const JTable1D< NX, JData_t > & table)
inline

Add table.

Parameters
tabletable
Returns
this table

Definition at line 99 of file JTable1D.hh.

100 {
101 for (int i = 0; i != NX; ++i) {
102 data[i] += table.data[i];
103 }
104
105 return *this;
106 }

◆ sub()

template<unsigned int NX, class JData_t = double>
JTable1D & JTOOLS::JTable1D< NX, JData_t >::sub ( const JTable1D< NX, JData_t > & table)
inline

Subtract table.

Parameters
tabletable
Returns
this table

Definition at line 115 of file JTable1D.hh.

116 {
117 for (int i = 0; i != NX; ++i) {
118 data[i] -= table.data[i];
119 }
120
121 return *this;
122 }

◆ mul() [1/2]

template<unsigned int NX, class JData_t = double>
JTable1D & JTOOLS::JTable1D< NX, JData_t >::mul ( const double factor)
inline

Scale table.

Parameters
factormultiplication factor
Returns
this table

Definition at line 130 of file JTable1D.hh.

131 {
132 for (int i = 0; i != NX; ++i) {
133 data[i] *= factor;
134 }
135
136 return *this;
137 }

◆ div()

template<unsigned int NX, class JData_t = double>
JTable1D & JTOOLS::JTable1D< NX, JData_t >::div ( const double factor)
inline

Scale table.

Parameters
factordivision factor
Returns
this table

Definition at line 146 of file JTable1D.hh.

147 {
148 for (int i = 0; i != NX; ++i) {
149 data[i] /= factor;
150 }
151
152 return *this;
153 }

◆ 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, class JData_t = double>
JReader & operator>> ( JReader & in,
JTable1D< NX, JData_t > & table )
friend

Read table from input.

Parameters
inreader
tabletable
Returns
reader

Definition at line 163 of file JTable1D.hh.

164 {
165 for (int i = 0; i != NX; ++i) {
166 in >> table.data[i];
167 }
168
169 return in;
170 }

◆ operator<<

template<unsigned int NX, class JData_t = double>
JWriter & operator<< ( JWriter & out,
const JTable1D< NX, JData_t > & table )
friend

Write table to output.

Parameters
outwriter
tabletable
Returns
writer

Definition at line 180 of file JTable1D.hh.

181 {
182 for (int i = 0; i != NX; ++i) {
183 out << table.data[i];
184 }
185
186 return out;
187 }

Member Data Documentation

◆ data

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

Definition at line 191 of file JTable1D.hh.


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