Loading...
Searching...
No Matches
tensor4.h
Go to the documentation of this file.
# ifndef _RHEOLEF_TENSOR4_H
# define _RHEOLEF_TENSOR4_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_tensor4_basic]
template<class T>
class tensor4_basic {
public:
typedef size_t size_type;
typedef T element_type;
typedef T float_type;
// allocators:
tensor4_basic ();
explicit tensor4_basic (const T& init_val);
tensor4_basic (const tensor4_basic<T>& a);
static tensor4_basic<T> eye (size_type d = 3);
tensor4_basic (const std::initializer_list<std::initializer_list<
std::initializer_list<std::initializer_list<T> > > >& il);
// affectation:
tensor4_basic<T>& operator= (const tensor4_basic<T>& a);
tensor4_basic<T>& operator= (const T& val);
// accessors:
T& operator()(size_type i, size_type j, size_type k, size_type l);
const T& operator()(size_type i, size_type j, size_type k, size_type l) const;
tensor_basic<T>& operator()(size_type i, size_type j);
const tensor_basic<T>& operator()(size_type i, size_type j) const;
// algebra:
tensor4_basic<T> operator* (const T& k) const;
tensor4_basic<T> operator/ (const T& k) const;
tensor4_basic<T> operator+ (const tensor4_basic<T>& b) const;
tensor4_basic<T> operator- (const tensor4_basic<T>& b) const;
tensor4_basic<T>& operator+= (const tensor4_basic<T>&);
tensor4_basic<T>& operator-= (const tensor4_basic<T>&);
tensor4_basic<T>& operator*= (const T& k);
tensor4_basic<T>& operator/= (const T& k) { return operator*= (1./k); }
// io:
std::ostream& put (std::ostream& out, size_type d=3) const;
// [verbatim_tensor4_basic]
// data:
protected:
tensor_basic<tensor_basic<T> > _x;
// [verbatim_tensor4_basic_cont]
};
// [verbatim_tensor4_basic_cont]
// [verbatim_tensor4]
typedef tensor4_basic<Float> tensor4;
// [verbatim_tensor4]
// [verbatim_tensor4_basic_cont2]
template <class T>
T norm (const tensor4_basic<T>& a) { return sqrt(norm2(a)); }
template <class T>
T norm2 (const tensor4_basic<T>&);
template <class T>
tensor_basic<T> ddot (const tensor4_basic<T>&, const tensor_basic<T>&);
template <class T>
tensor_basic<T> ddot (const tensor_basic<T>&, const tensor4_basic<T>&);
template <class T>
tensor4_basic<T> dexp (const tensor_basic<T>& a, size_t d = 3);
// [verbatim_tensor4_basic_cont2]
// -----------------------------------------------------------------------
// inlined
// -----------------------------------------------------------------------
template<class T> struct float_traits<tensor4_basic<T> > { typedef typename float_traits<T>::type type; };
template<class T> struct scalar_traits<tensor4_basic<T> > { typedef T type; };
template<class T>
inline
tensor4_basic<T>::tensor4_basic()
: _x (tensor_basic<T>(T()))
{
}
template<class T>
inline
tensor4_basic<T>::tensor4_basic(const T& init_val)
: _x (tensor_basic<T>(init_val))
{
}
template<class T>
inline
tensor4_basic<T>::tensor4_basic (const tensor4_basic<T>& a)
: _x (tensor_basic<T>(T()))
{
operator= (a);
}
template<class T>
inline
tensor_basic<T>&
tensor4_basic<T>::operator() (size_type i, size_type j)
{
return _x(i,j);
}
template<class T>
inline
const tensor_basic<T>&
tensor4_basic<T>::operator() (size_type i, size_type j) const
{
return _x(i,j);
}
template<class T>
inline
T&
tensor4_basic<T>::operator() (size_type i, size_type j, size_type k, size_type l)
{
return _x(i,j)(k,l);
}
template<class T>
inline
const T&
tensor4_basic<T>::operator() (size_type i, size_type j, size_type k, size_type l) const
{
return _x(i,j)(k,l);
}
template <class T>
inline
tensor4_basic<T>
tensor4_basic<T>::operator* (const T& k) const
{
tensor4_basic<T> b = *this;
b *= k;
return b;
}
template <class T, class U>
inline
typename
std::enable_if<
details::is_rheolef_arithmetic<U>::value
,tensor4_basic<T>
>::type
operator* (const U& k, const tensor4_basic<T>& a)
{
return a*k;
}
template <class T>
inline
tensor4_basic<T>
tensor4_basic<T>::operator/ (const T& k) const
{
return operator* (1./k);
}
// inputs/outputs:
#ifdef TODO
template<class T>
inline
std::istream& operator>> (std::istream& in, tensor4_basic<T>& a)
{
return a.get (in);
}
#endif // TODO
template<class T>
inline
std::ostream& operator<< (std::ostream& out, const tensor4_basic<T>& a)
{
return a.put (out);
}
}// namespace rheolef
# endif /* _RHEOLEF_TENSOR4_H */
rheolef::tensor4_basic
Definition tensor4.h:80
rheolef::tensor4_basic::put
std::ostream & put(std::ostream &out, size_type d=3) const
Definition tensor4.cc:198
rheolef::tensor4_basic::operator()
tensor_basic< T > & operator()(size_type i, size_type j)
Definition tensor4.h:180
rheolef::tensor4_basic::tensor4_basic
tensor4_basic(const tensor4_basic< T > &a)
Definition tensor4.h:172
rheolef::tensor4_basic::operator+
tensor4_basic< T > operator+(const tensor4_basic< T > &b) const
Definition tensor4.cc:125
rheolef::tensor4_basic::tensor4_basic
tensor4_basic(const std::initializer_list< std::initializer_list< std::initializer_list< std::initializer_list< T > > > > &il)
Definition tensor4.cc:64
rheolef::tensor4_basic::operator-
tensor4_basic< T > operator-(const tensor4_basic< T > &b) const
Definition tensor4.cc:138
rheolef::tensor4_basic::operator()
const tensor_basic< T > & operator()(size_type i, size_type j) const
Definition tensor4.h:187
rheolef::tensor4_basic::size_type
size_t size_type
Definition tensor4.h:83
rheolef::tensor4_basic< S >::_x
tensor_basic< tensor_basic< S > > _x
Definition tensor4.h:127
rheolef::tensor4_basic::operator-=
tensor4_basic< T > & operator-=(const tensor4_basic< T > &)
Definition tensor4.cc:162
rheolef::tensor4_basic::tensor4_basic
tensor4_basic()
Definition tensor4.h:160
rheolef::tensor4_basic::operator/=
tensor4_basic< T > & operator/=(const T &k)
Definition tensor4.h:119
rheolef::tensor4_basic::tensor4_basic
tensor4_basic(const T &init_val)
Definition tensor4.h:166
rheolef::tensor4_basic::operator+=
tensor4_basic< T > & operator+=(const tensor4_basic< T > &)
Definition tensor4.cc:151
rheolef::tensor4_basic::operator*
tensor4_basic< T > operator*(const T &k) const
Definition tensor4.h:208
rheolef::tensor4_basic::operator*=
tensor4_basic< T > & operator*=(const T &k)
Definition tensor4.cc:173
rheolef::tensor4_basic::operator=
tensor4_basic< T > & operator=(const tensor4_basic< T > &a)
Definition tensor4.cc:114
rheolef::tensor4_basic::operator()
const T & operator()(size_type i, size_type j, size_type k, size_type l) const
Definition tensor4.h:201
rheolef::tensor4_basic::eye
static tensor4_basic< T > eye(size_type d=3)
Definition tensor4.cc:29
rheolef::tensor4_basic::element_type
T element_type
Definition tensor4.h:84
rheolef::tensor4_basic::float_type
T float_type
Definition tensor4.h:85
rheolef::tensor4_basic::operator/
tensor4_basic< T > operator/(const T &k) const
Definition tensor4.h:228
rheolef::tensor4_basic::operator()
T & operator()(size_type i, size_type j, size_type k, size_type l)
Definition tensor4.h:194
rheolef::tensor_basic
Definition tensor.h:90
rheolef::type
rheolef::std::enable_if< details::is_field_expr_v2_nonlinear_arg< Expr1 >::value &&! details::is_field_expr_v2_constant< Expr1 >::value &&details::is_field_expr_v2_nonlinear_arg< Expr2 >::value &&! details::is_field_expr_v2_constant< Expr2 >::value, details::field_expr_v2_nonlinear_node_binary< details::function_traits< Function >::functor_type, details::field_expr_v2_nonlinear_terminal_wrapper_traits< Expr1 >::type, details::field_expr_v2_nonlinear_terminal_wrapper_traits< Expr2 >::type > > type
tensor4
see the tensor4 page for the full documentation
T
Expr1::float_type T
Definition field_expr.h:230
rheolef
This file is part of Rheolef.
Definition compiler_eigen.h:39
rheolef::ddot
T ddot(const tensor_basic< T > &a, const tensor_basic< T > &b)
ddot(x,y): see the expression page for the full documentation
Definition tensor.cc:278
rheolef::operator<<
std::ostream & operator<<(std::ostream &os, const catchmark &m)
Definition catchmark.h:99
rheolef::norm2
T norm2(const vec< T, M > &x)
norm2(x): see the expression page for the full documentation
Definition vec.h:379
rheolef::dexp
tensor4_basic< T > dexp(const tensor_basic< T > &chi, size_t dim)
Definition tensor4-dexp.cc:37
rheolef::operator>>
std::istream & operator>>(std::istream &is, const catchmark &m)
Definition catchmark.h:88
rheolef::operator*
csr< T, sequential > operator*(const T &lambda, const csr< T, sequential > &a)
Definition csr.h:437
rheolef::norm
T norm(const vec< T, M > &x)
norm(x): see the expression page for the full documentation
Definition vec.h:387
d
size_t d
Definition neumann-laplace-lambda.cc:28
rheolef::float_traits< tensor4_basic< T > >::type
float_traits< T >::type type
Definition tensor4.h:155
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< tensor4_basic< T > >::type
T type
Definition tensor4.h:156
rheolef::scalar_traits
helper for point_basic<T> & tensor_basic<T>: get basic T type
Definition point.h:323