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"
45 template <
unsigned int N,
typename T>
73 operator TypeVector<T> ()
const { libmesh_not_implemented();
return 0; }
77 operator TypeTensor<T> ()
const { libmesh_not_implemented();
return 0; }
88 libmesh_not_implemented();
97 libmesh_not_implemented();
102 template <
typename Scalar>
103 typename boostcopy::enable_if_c<
104 ScalarTraits<Scalar>::value,
107 { libmesh_assert_equal_to (p, Scalar(0)); this->
zero();
return *
this; }
110 template<
typename T2>
114 libmesh_not_implemented();
119 template<
typename T2>
122 libmesh_not_implemented();
127 template<
typename T2>
131 libmesh_not_implemented();
136 template<
typename T2>
139 libmesh_not_implemented();
146 libmesh_not_implemented();
151 template <
typename Scalar>
152 typename boostcopy::enable_if_c<
153 ScalarTraits<Scalar>::value,
157 libmesh_not_implemented();
162 template <
typename Scalar>
165 libmesh_not_implemented();
170 template <
typename Scalar>
171 typename boostcopy::enable_if_c<
172 ScalarTraits<Scalar>::value,
176 libmesh_not_implemented();
183 libmesh_not_implemented();
195 template <
typename T2>
196 typename CompareTypes<T,T2>::supertype
199 libmesh_not_implemented();
208 libmesh_not_implemented();
215 void zero() { libmesh_not_implemented(); }
222 libmesh_not_implemented();
231 bool operator < (const TypeNTensor<N,T> & )
const
233 libmesh_not_implemented();
242 libmesh_not_implemented();
249 void print(std::ostream & )
const {}
267 template<
typename T2>
278 return (e == 0) ? 1 : b *
int_pow(b, e - 1);
283 template<
unsigned int N,
typename T>
284 template<
typename T2>
288 unsigned int size = int_pow(LIBMESH_DIM, N);
289 for (
unsigned int i = 0; i < size ; i++)
290 _coords[i] += factor*p._coords[i];
293 template <
unsigned int N,
typename T,
typename Scalar>
294 typename boostcopy::enable_if_c<
295 ScalarTraits<Scalar>::value,
299 libmesh_not_implemented();
303 template <
unsigned int N,
typename T,
typename Scalar>
304 typename boostcopy::enable_if_c<
305 ScalarTraits<Scalar>::value,
306 TypeNTensor<N,typename CompareTypes<Scalar, T>::supertype>>::type
309 libmesh_not_implemented();
317 #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 > &)
void add_scaled(const TypeNTensor< N, T2 > &, const T &)
将一个经过缩放的类型N张量添加到该类型N张量中,而不创建临时张量。
TypeNTensor(const TypeNTensor< N, T > &)
此类定义了LIBMESH_DIM维的实数或复数空间中的向量。
const TypeNTensor< N, T > & operator+=(const TypeNTensor< N, T2 > &)
CompareTypes< T, T2 >::supertype contract(const TypeNTensor< N, T2 > &) const
将两个张量相乘,返回一个标量,即 张量可能包含不同的数值类型。 也被称为张量的“双内积”或“双点积”。
const TypeNTensor< N, T > & operator-=(const TypeNTensor< N, T2 > &)
This class defines a tensor in LIBMESH_DIM dimensional space of type T.
bool operator==(const TypeNTensor< N, T > &) const
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeNTensor< N, typename CompareTypes< T, Scalar >::supertype > >::type operator*(const Scalar) const
boostcopy::enable_if_c< ScalarTraits< Scalar >::value, TypeNTensor< N, typename CompareTypes< T, Scalar >::supertype > >::type operator/(const Scalar) const
TypeNTensor(const TypeTensor< T > &)
TypeNTensor< N, T > operator-() const
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)
该类定义了一个在 LIBMESH_DIM 维度空间中类型为 T 的向量。
tuple_of< N, unsigned int > index_type
用于通用索引编程的辅助typedef
const TypeNTensor< N, T > & operator*=(const Scalar)
std::vector< T > _coords
TypeNTensor的坐标
bool operator>(const TypeNTensor< N, T > &) const
void print(std::ostream &) const
将该张量格式化打印到流中,默认为libMesh::out。
该类最终将定义一个在类型为T的LIBMESH_DIM维空间中的N阶张量。
friend std::ostream & operator<<(std::ostream &os, const TypeNTensor< N, T > &t)
执行格式化打印(如上所述),但支持以下语法:
TypeNTensor< N-1, T > slice(const unsigned int)
ADRealEigenVector< T, D, asd > norm(const ADRealEigenVector< T, D, asd > &)
计算自动微分实数向量的范数。
TypeNTensor(const TypeVector< T > &)
TypeNTensor< N, typename CompareTypes< T, T2 >::supertype > operator+(const TypeNTensor< N, T2 > &) const
const TypeNTensor< N-1, T > slice(const unsigned int) const
此类定义了LIBMESH_DIM维度的实数或复数空间中的张量。typedef RealTensorValue总是定义为实数值的张量, 而NumberTensorValue则根据库的配置定义为实数或复数值...