29 #include <type_traits> 58 template<
int Num,
class T>
76 TFad() : val_( T(0.
f)) {memset(((
void *)dx_),0,Num*
sizeof(T));}
77 TFad(
const T & x) : val_(x) {memset((
void *)dx_,0,Num*
sizeof(T));}
79 TFad(
const T & x,
const int i) : val_(x)
80 {memset((
void *)dx_,0,Num*
sizeof(T));dx_[i]=1.;}
85 void diff(
const int ith,
const int n);
89 const T&
val()
const {
return val_;}
90 T&
val() {
return val_;}
96 const T&
d(
int i)
const {
return dx_[i];}
98 const T
dx(
int i)
const {
return dx_[i];}
99 T
dx(
int i) {
return dx_[i];}
101 int size()
const {
return Num;}
125 int ClassId()
const override;
127 template <
typename TEMP=
void>
128 typename std::enable_if<is_arithmetic_pz<T>::value, TEMP>::type
134 template <
typename TEMP=
void>
135 typename std::enable_if<is_arithmetic_pz<T>::value, TEMP>::type
141 template <
typename TEMP=
void>
142 typename std::enable_if<!is_arithmetic_pz<T>::value, TEMP>::type
144 val_.Read(buf, context);
145 for (
unsigned int i = 0; i < Num; ++i) {
146 dx_[i].Read(buf, context);
150 template <
typename TEMP=
void>
151 typename std::enable_if<!is_arithmetic_pz<T>::value, TEMP>::type
153 val_.Write(buf,withclassid);
154 for (
unsigned int i = 0; i < Num; ++i) {
155 dx_[i].Write(buf,withclassid);
159 friend ostream& operator<< (ostream& stream, const TFad<Num,T>& x)
161 return stream << x.
val();
166 return stream >> x.
val();
175 for (
int i=0; i<Num; ++i)
185 template <
int Num,
class T>
template <
class ExprT>
inline 187 : val_(fadexpr.
val())
190 for(
int i=0; i<Num; ++i)
191 dx_[i] = fadexpr.
dx(i);
199 for(
int i=0; i<Num; ++i)
209 for(
int i=0; i<Num; ++i)
217 if (
this != &rhs )
copy(rhs);
224 for(
int i=0; i<Num; ++i)
225 dx_[i] = fadexpr.
dx(i);
263 for (
int i=0; i<Num;++i)
273 for (
int i=0; i<Num;++i)
282 for (
int i=0; i<Num; ++i)
292 for (
int i=0; i<Num; ++i)
302 for (
int i=0; i<Num; ++i)
312 for (
int i=0; i<Num; ++i)
324 for (
int i=0; i<Num; ++i)
334 for (
int i=0; i<Num; ++i)
345 for (
int i=0; i<Num; ++i)
357 for (
int i=0; i<Num; ++i)
369 template <
int Num,
class T>
inline ostream& operator << (ostream& os, const TFad<Num,T>& a)
371 os.setf(ios::fixed,ios::floatfield);
373 os << a.val() <<
" [";
376 for (
int i=0; i< Num; i++) {
386 template <
class T >
class TFadExpr {
396 explicit TFadExpr(
const T& fadexpr) : fadexpr_(fadexpr) {;}
398 value_type
val()
const {
return fadexpr_.val();}
399 value_type
dx(
int i)
const {
return fadexpr_.dx(i);}
400 int size()
const {
return fadexpr_.size();}
403 value_type
fastAccessDx(
int i)
const {
return fadexpr_.fastAccessDx(i);}
407 template <
class T >
class TFadCst {
417 explicit TFadCst(
const T& value) : constant_(value) {;}
419 const value_type&
val()
const {
return constant_;}
440 const value_type
val()
const {
return expr_.val();}
441 const value_type
dx(
int i)
const {
return expr_.dx(i);}
442 int size()
const {
return expr_.size();}
461 const value_type
val()
const {
return - expr_.val();}
462 const value_type
dx(
int i)
const {
return - expr_.dx(i);}
463 int size()
const {
return expr_.size();}
466 value_type
fastAccessDx(
int i)
const {
return - expr_.fastAccessDx(i);}
469 template <
class T>
inline 478 template <
class T>
inline 487 template <
int Num,
typename T>
489 return Hash(
"TFad") ^ Num<<1 ^ (ClassIdOrHash<T>()<<2);
bool hasFastAccess() const
Contains declaration of the TPZSavable class which defines the interface to save and restore objects ...
TFadExpr< TFadUnaryMin< TFadExpr< T > > > operator-(const TFadExpr< T > &expr)
TFad< Num, T > & operator*=(const T &x)
TFad< Num, T > & operator-=(const T &x)
GetArithmeticType< T >::type arithmetic_type
int ClassId() const override
Define the class id associated with the class.
TPZVec< T > & operator-=(TPZVec< T > &a, const TPZVec< T > &b)
substracts two vectors
TFadExpr< TFadUnaryMin< TFad< Num, T > > > operator-() const
TFad(const T &x, const int i)
TFadExpr< TFadUnaryPlus< TFadExpr< T > > > operator+(const TFadExpr< T > &expr)
REAL val(STATE &number)
Returns value of the variable.
std::istream & operator>>(std::istream &out, TPZFlopCounter &val)
Implements to read (input) only the floating point value.
value_type fastAccessDx(int i) const
TFadExpr(const T &fadexpr)
bool hasFastAccess() const
const T & fastAccessDx(int i) const
std::enable_if<!is_arithmetic_pz< T >::value, TEMP >::type Read(TPZStream &buf, void *context)
read objects from the stream
value_type dx(int i) const
const value_type dx(int i) const
bool hasFastAccess() const
const value_type & val() const
TFadExpr< TFadUnaryPlus< TFad< Num, T > > > operator+() const
virtual void Write(const bool val)
TFad< Num, T > & operator+=(const T &x)
std::enable_if< is_arithmetic_pz< T >::value, TEMP >::type Write(TPZStream &buf, int withclassid) const
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
void copy(const TFad< Num, T > &rhs)
bool hasFastAccess() const
int32_t Hash(std::string str)
GetArithmeticType< T >::type type
void diff(const int ith, const int n)
value_type fastAccessDx(int i) const
const value_type val() const
const value_type dx(int i) const
std::enable_if<!is_arithmetic_pz< T >::value, TEMP >::type Write(TPZStream &buf, int withclassid) const
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
const value_type val() const
TFadUnaryMin(const T &value)
TFad< Num, T > & operator/=(const T &x)
value_type & fastAccessDx(int i) const
TFad< Num, T > & operator=(const T &val)
std::enable_if< is_arithmetic_pz< T >::value, TEMP >::type Read(TPZStream &buf, void *context)
read objects from the stream
Contains declaration of the abstract TPZStream class. TPZStream defines the interface for saving and ...
Defines the interface for saving and reading data. Persistency.
TFadUnaryPlus(const T &value)
This class defines the interface to save and restore objects from TPZStream objects. Persistency.
value_type fastAccessDx(int i) const
const value_type dx(int i) const
bool hasFastAccess() const
virtual void Read(bool &val)