20 #ifndef LIBMESH_TYPE_N_TENSOR_H 21 #define LIBMESH_TYPE_N_TENSOR_H 24 #include "libmesh/libmesh_common.h" 25 #include "libmesh/type_vector.h" 26 #include "libmesh/tuple_of.h" 47 template <
unsigned int N,
typename T>
68 operator TypeVector<T> ()
const { libmesh_not_implemented();
return 0; }
71 operator TypeTensor<T> ()
const { libmesh_not_implemented();
return 0; }
84 libmesh_not_implemented();
93 libmesh_not_implemented();
97 template <
typename Scalar>
102 { libmesh_assert_equal_to (p, Scalar(0)); this->
zero();
return *
this; }
107 template<
typename T2>
111 libmesh_not_implemented();
118 template<
typename T2>
121 libmesh_not_implemented();
128 template<
typename T2>
132 libmesh_not_implemented();
139 template<
typename T2>
142 libmesh_not_implemented();
151 libmesh_not_implemented();
158 template <
typename Scalar>
164 libmesh_not_implemented();
171 template <
typename Scalar>
174 libmesh_not_implemented();
181 template <
typename Scalar>
187 libmesh_not_implemented();
196 libmesh_not_implemented();
209 template <
typename T2>
213 libmesh_not_implemented();
223 libmesh_not_implemented();
233 libmesh_not_implemented();
240 void zero() { libmesh_not_implemented(); }
247 libmesh_not_implemented();
256 bool operator < (const TypeNTensor<N,T> & )
const 258 libmesh_not_implemented();
267 libmesh_not_implemented();
275 void print(std::ostream & )
const {}
293 template<
typename T2>
304 return (e == 0) ? 1 : b *
int_pow(b, e - 1);
309 template<
unsigned int N,
typename T>
310 template<
typename T2>
314 unsigned int size = int_pow(LIBMESH_DIM, N);
315 for (
unsigned int i = 0; i < size ; i++)
316 _coords[i] += factor*p._coords[i];
319 template <
unsigned int N,
typename T,
typename Scalar>
325 libmesh_not_implemented();
329 template <
unsigned int N,
typename T,
typename Scalar>
330 typename boostcopy::enable_if_c<
332 TypeNTensor<N,typename CompareTypes<Scalar, T>::supertype>>::type
335 libmesh_not_implemented();
343 #endif // LIBMESH_TYPE_N_TENSOR_H
static constexpr int int_pow(int b, int e)
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeNTensor< N, typename CompareTypes< Scalar, T >::supertype > >::type operator/(const Scalar &, const TypeNTensor< N, T > &)
TypeNTensor & operator=(const TypeNTensor< N, T > &)
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeNTensor< N, typename CompareTypes< T, Scalar >::supertype > >::type operator/(const Scalar) const
Divide every entry of a tensor by a number.
void print(std::ostream &) const
Do a formatted print of this tensor to a stream which defaults to libMesh::out.
TypeNTensor< N, T > operator-() const
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeNTensor< N, typename CompareTypes< T, Scalar >::supertype > >::type operator*(const Scalar) const
Multiply every entry of a tensor by a number.
void add_scaled(const TypeNTensor< N, T2 > &, const T &)
Add a scaled type N tensor to this type N tensor without creating a temporary.
TypeNTensor(const TypeNTensor< N, T > &)
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
The libMesh namespace provides an interface to certain functionality in the library.
const TypeNTensor< N, T > & operator+=(const TypeNTensor< N, T2 > &)
Add to this tensor.
const TypeNTensor< N, T > & operator-=(const TypeNTensor< N, T2 > &)
Subtract from this tensor.
const TypeNTensor< N-1, T > slice(const unsigned int) const
This class defines a tensor in LIBMESH_DIM dimensional space of type T.
TypeNTensor(const TypeTensor< T > &)
auto norm_sq() const -> decltype(std::norm(T()))
typename tuple_n< Index, T >::template type<> tuple_of
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeNTensor< N, typename CompareTypes< Scalar, T >::supertype > >::type operator*(const Scalar &, const TypeNTensor< N, T > &)
const TypeNTensor< N, T > & operator/=(const T)
Divide every entry of this tensor by a number.
bool operator==(const TypeNTensor< N, T > &) const
auto norm() const -> decltype(std::norm(T()))
This class defines a vector in LIBMESH_DIM dimensional space of type T.
tuple_of< N, unsigned int > index_type
Helper typedef for generic index programming.
const TypeNTensor< N, T > & operator*=(const Scalar)
Multiply every entry of this tensor by a number.
std::vector< T > _coords
The coordinates of the TypeNTensor.
This class will eventually define a rank-N tensor in LIBMESH_DIM dimensional space of type T...
TypeNTensor< N, typename CompareTypes< T, T2 >::supertype > operator+(const TypeNTensor< N, T2 > &) const
Add two tensors.
~TypeNTensor()=default
Destructor.
friend std::ostream & operator<<(std::ostream &os, const TypeNTensor< N, T > &t)
Does a formatted print (as above) but supports the syntax:
TypeNTensor< N-1, T > slice(const unsigned int)
void zero()
Set all entries of the tensor to 0.
bool operator>(const TypeNTensor< N, T > &) const
TypeNTensor(const TypeVector< T > &)
This class defines a tensor in LIBMESH_DIM dimensional Real or Complex space.
CompareTypes< T, T2 >::supertype contract(const TypeNTensor< N, T2 > &) const
Multiply 2 tensors together to return a scalar, i.e.