tensor3.h
Go to the documentation of this file.
# ifndef _RHEOLEF_TENSOR3_H
# define _RHEOLEF_TENSOR3_H
//
// This file is part of Rheolef.
//
// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
//
// Rheolef is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Rheolef is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Rheolef; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// =========================================================================
namespace rheolef {
} // namespace rheolef
#include "rheolef/point.h"
#include "rheolef/tensor.h"
namespace rheolef {
// [verbatim_tensor3_basic]
template<class T>
class tensor3_basic {
public:
typedef size_t size_type;
typedef T element_type;
typedef T float_type;
// allocators:
tensor3_basic (const T& init_val = 0);
tensor3_basic (const tensor3_basic<T>& a);
// affectation:
tensor3_basic<T>& operator= (const tensor3_basic<T>& a);
tensor3_basic<T>& operator= (const T& val);
// accessors:
T& operator()(size_type i, size_type j, size_type k);
const T& operator()(size_type i, size_type j, size_type k) const;
// algebra
tensor3_basic<T> operator* (const T& k) const;
tensor3_basic<T> operator/ (const T& k) const;
tensor_basic<T> operator* (const point_basic<T>& v) const;
tensor3_basic<T> operator* (const tensor_basic<T>& b) const;
tensor3_basic<T> operator+ (const tensor3_basic<T>& b) const;
tensor3_basic<T> operator- (const tensor3_basic<T>& b) const;
tensor3_basic<T>& operator+= (const tensor3_basic<T>&);
tensor3_basic<T>& operator-= (const tensor3_basic<T>&);
tensor3_basic<T>& operator*= (const T& k);
tensor3_basic<T>& operator/= (const T& k) { return operator*= (1./k); }
// inputs/outputs:
std::ostream& put (std::ostream& s, size_type d = 3) const;
std::istream& get (std::istream&);
// [verbatim_tensor3_basic]
// data:
protected:
T _x [3][3][3];
// [verbatim_tensor3_basic_cont]
};
// [verbatim_tensor3_basic_cont]
// [verbatim_tensor3]
typedef tensor3_basic<Float> tensor3;
// [verbatim_tensor3]
// -----------------------------------------------------------------------
// inlined
// -----------------------------------------------------------------------
template<class T> struct float_traits<tensor3_basic<T> > { typedef typename float_traits<T>::type type; };
template<class T> struct scalar_traits<tensor3_basic<T> > { typedef T type; };
template<class T>
inline
tensor3_basic<T>::tensor3_basic (const T& init_val)
{
operator= (init_val);
}
template<class T>
inline
tensor3_basic<T>::tensor3_basic (const tensor3_basic<T>& a)
{
operator= (a);
}
template<class T>
inline
T&
tensor3_basic<T>::operator() (size_type i, size_type j, size_type k)
{
return _x[i%3][j%3][k%3];
}
template<class T>
inline
const T&
tensor3_basic<T>::operator() (size_type i, size_type j, size_type k) const
{
return _x[i%3][j%3][k%3];
}
template <class T>
inline
tensor3_basic<T>
tensor3_basic<T>::operator* (const T& k) const
{
tensor3_basic<T> b = *this;
b *= k;
return b;
}
template <class T, class U>
inline
typename
std::enable_if<
details::is_rheolef_arithmetic<U>::value
,tensor3_basic<T>
>::type
operator* (const U& k, const tensor3_basic<T>& a)
{
return a*k;
}
template <class T>
inline
tensor3_basic<T>
tensor3_basic<T>::operator/ (const T& k) const
{
return operator* (1./k);
}
template <class U>
U dddot (const tensor3_basic<U>&, const tensor3_basic<U>&);
template <class T>
inline
T
norm2 (const tensor3_basic<T>& a)
{
return dddot(a,a);
}
template <class T>
inline
T
dist2 (const tensor3_basic<T>& a, const tensor3_basic<T>& b)
{
return norm2(a-b);
}
template <class U>
inline
U
norm (const tensor3_basic<U>& a)
{
return sqrt(norm2(a));
}
template <class U>
inline
U
dist (const tensor3_basic<U>& a, const tensor3_basic<U>& b)
{
return norm(a-b);
}
// inputs/outputs:
template<class T>
inline
std::istream& operator>> (std::istream& in, tensor3_basic<T>& a)
{
return a.get (in);
}
template<class T>
inline
std::ostream& operator<< (std::ostream& out, const tensor3_basic<T>& a)
{
return a.put (out);
}
}// namespace rheolef
# endif /* _RHEOLEF_TENSOR3_H */
size_type
field::size_type size_type
Definition: branch.cc:425
rheolef::point_basic
Definition: point.h:87
rheolef::tensor3_basic
Definition: tensor3.h:73
rheolef::tensor3_basic::operator-
tensor3_basic< T > operator-(const tensor3_basic< T > &b) const
Definition: tensor3.cc:83
rheolef::tensor3_basic::put
std::ostream & put(std::ostream &s, size_type d=3) const
Definition: tensor3.cc:140
rheolef::tensor3_basic::operator/=
tensor3_basic< T > & operator/=(const T &k)
Definition: tensor3.h:105
rheolef::tensor3_basic::_x
T _x[3][3][3]
Definition: tensor3.h:115
rheolef::tensor3_basic::operator-=
tensor3_basic< T > & operator-=(const tensor3_basic< T > &)
Definition: tensor3.cc:116
rheolef::tensor3_basic::operator*=
tensor3_basic< T > & operator*=(const T &k)
Definition: tensor3.cc:126
rheolef::tensor3_basic::operator=
tensor3_basic< T > & operator=(const tensor3_basic< T > &a)
Definition: tensor3.cc:38
rheolef::tensor3_basic::size_type
size_t size_type
Definition: tensor3.h:76
rheolef::tensor3_basic::get
std::istream & get(std::istream &)
rheolef::tensor3_basic::operator*
tensor3_basic< T > operator*(const T &k) const
Definition: tensor3.h:159
rheolef::tensor3_basic::operator()
T & operator()(size_type i, size_type j, size_type k)
Definition: tensor3.h:145
rheolef::tensor3_basic::operator+=
tensor3_basic< T > & operator+=(const tensor3_basic< T > &)
Definition: tensor3.cc:106
rheolef::tensor3_basic::operator+
tensor3_basic< T > operator+(const tensor3_basic< T > &b) const
Definition: tensor3.cc:72
rheolef::tensor3_basic::tensor3_basic
tensor3_basic(const T &init_val=0)
Definition: tensor3.h:132
rheolef::tensor3_basic::operator/
tensor3_basic< T > operator/(const T &k) const
Definition: tensor3.h:179
rheolef::tensor3_basic::element_type
T element_type
Definition: tensor3.h:77
rheolef::tensor3_basic::float_type
T float_type
Definition: tensor3.h:78
rheolef::tensor_basic
Definition: tensor.h:90
rheolef::tensor3_basic< T >
tensor_basic< T > tensor3_basic< T >
Definition: piola_fem.h:137
rheolef::type
rheolef::std type
rheolef::tensor3
tensor3_basic< Float > tensor3
Definition: tensor3.h:121
T
Expr1::float_type T
Definition: field_expr.h:261
mkgeo_ball.b
int b
Definition: mkgeo_ball.sh:152
mkgeo_ball.d
int d
Definition: mkgeo_ball.sh:154
rheolef::io::out
@ out
Definition: rheostream.h:167
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::dist
T dist(const point_basic< T > &x, const point_basic< T > &y)
Definition: point.h:299
rheolef::operator>>
std::istream & operator>>(std::istream &is, const catchmark &m)
Definition: catchmark.h:88
rheolef::dddot
T dddot(const tensor3_basic< T > &a, const tensor3_basic< T > &b)
Definition: tensor3.cc:94
rheolef::norm
T norm(const vec< T, M > &x)
norm(x): see the expression page for the full documentation
Definition: vec.h:387
rheolef::dist2
T dist2(const point_basic< T > &x, const point_basic< T > &y)
Definition: point.h:293
rheolef::operator*
csr< T, sequential > operator*(const T &lambda, const csr< T, sequential > &a)
Definition: csr.h:437
rheolef::norm2
T norm2(const vec< T, M > &x)
norm2(x): see the expression page for the full documentation
Definition: vec.h:379
rheolef::operator<<
std::ostream & operator<<(std::ostream &os, const catchmark &m)
Definition: catchmark.h:99
a
Definition: diffusion_isotropic.h:25
rheolef::float_traits< tensor3_basic< T > >::type
float_traits< T >::type type
Definition: tensor3.h:127
rheolef::float_traits
helper for std::complex<T>: get basic T type
Definition: Float.h:93
rheolef::float_traits::type
T type
Definition: Float.h:94
rheolef::scalar_traits< tensor3_basic< T > >::type
T type
Definition: tensor3.h:128
rheolef::scalar_traits
helper for point_basic<T> & tensor_basic<T>: get basic T type
Definition: point.h:324