16#ifndef dealii_tensor_h
17#define dealii_tensor_h
27#ifdef DEAL_II_WITH_ADOLC
28# include <adolc/adouble.h>
38template <
typename ElementType,
typename MemorySpace>
40template <
int dim,
typename Number>
42template <
int rank_,
int dim,
typename Number =
double>
44template <
typename Number>
46template <
typename number>
87template <
int dim,
typename Number>
91 static_assert(dim >= 0,
92 "Tensors must have a dimension greater than or equal to one.");
107 static constexpr unsigned int rank = 0;
152 template <
typename OtherNumber>
161 template <
typename OtherNumber>
165#ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
187 DEAL_II_DEPRECATED_EARLY
199 DEAL_II_DEPRECATED_EARLY
211 DEAL_II_DEPRECATED_EARLY
224 DEAL_II_DEPRECATED_EARLY
257 template <
typename OtherNumber>
261#if defined(__INTEL_COMPILER) || defined(DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG)
274#ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
288 template <
typename OtherNumber>
295 template <
typename OtherNumber>
302 template <
typename OtherNumber>
311 template <
typename OtherNumber>
320 template <
typename OtherNumber>
329 template <
typename OtherNumber>
338 template <
typename OtherNumber>
389 template <
class Iterator>
391 unroll(
const Iterator begin,
const Iterator end)
const;
398 template <
class Archive>
417 template <
typename Iterator>
422 template <
int,
int,
typename>
501template <
int rank_,
int dim,
typename Number>
505 static_assert(rank_ >= 1,
506 "Tensors must have a rank greater than or equal to one.");
507 static_assert(dim >= 0,
508 "Tensors must have a dimension greater than or equal to zero.");
522 static constexpr unsigned int rank = rank_;
574 template <
typename ElementType,
typename MemorySpace>
585 template <
typename OtherNumber>
592 template <
typename OtherNumber>
599 template <
typename OtherNumber>
603#ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
634 constexpr const Number &
674 template <
typename OtherNumber>
687#ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
704 template <
typename OtherNumber>
711 template <
typename OtherNumber>
720 template <
typename OtherNumber>
729 template <
typename OtherNumber>
739 template <
typename OtherNumber>
748 template <
typename OtherNumber>
806 template <
typename OtherNumber>
807 DEAL_II_DEPRECATED_EARLY
void
820 template <
class Iterator>
822 unroll(
const Iterator begin,
const Iterator end)
const;
828 static constexpr unsigned int
843 static constexpr std::size_t
851 template <
class Archive>
872 template <
typename Iterator>
882 template <
typename ArrayLike, std::size_t... Indices>
884 Tensor(
const ArrayLike &initializer, std::index_sequence<Indices...>);
887 template <
int,
int,
typename>
892 friend class Point<dim, Number>;
903 template <
int rank,
int dim,
typename T,
typename U>
904 struct ProductTypeImpl<
Tensor<rank, dim, T>,
std::complex<U>>
910 template <
int rank,
int dim,
typename T,
typename U>
911 struct ProductTypeImpl<
Tensor<rank, dim,
std::complex<T>>, std::complex<U>>
917 template <
typename T,
int rank,
int dim,
typename U>
918 struct ProductTypeImpl<
std::complex<T>,
Tensor<rank, dim, U>>
924 template <
int rank,
int dim,
typename T,
typename U>
925 struct ProductTypeImpl<
std::complex<T>,
Tensor<rank, dim, std::complex<U>>>
936 template <
int rank,
int dim,
typename T>
937 struct NumberType<
Tensor<rank, dim, T>>
959template <
int dim,
typename Number>
969template <
int dim,
typename Number>
970template <
typename OtherNumber>
978template <
int dim,
typename Number>
979template <
typename OtherNumber>
986# ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
987template <
int dim,
typename Number>
995template <
int dim,
typename Number>
998 :
value{std::move(other.value)}
1003template <
int dim,
typename Number>
1007 return std::addressof(value);
1012template <
int dim,
typename Number>
1013inline const Number *
1016 return std::addressof(value);
1021template <
int dim,
typename Number>
1025 return begin_raw() + n_independent_components;
1030template <
int dim,
typename Number>
1034 return begin_raw() + n_independent_components;
1039template <
int dim,
typename Number>
1044# ifndef __CUDA_ARCH__
1046 ExcMessage(
"Cannot access an object of type Tensor<0,0,Number>"));
1052template <
int dim,
typename Number>
1057# ifndef __CUDA_ARCH__
1059 ExcMessage(
"Cannot access an object of type Tensor<0,0,Number>"));
1066template <
int dim,
typename Number>
1067template <
typename OtherNumber>
1077# if defined(__INTEL_COMPILER) || defined(DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG)
1078template <
int dim,
typename Number>
1088# ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
1089template <
int dim,
typename Number>
1093 value = std::move(other.value);
1100template <
int dim,
typename Number>
1101template <
typename OtherNumber>
1111template <
int dim,
typename Number>
1112template <
typename OtherNumber>
1113constexpr inline bool
1116# ifdef DEAL_II_ADOLC_WITH_ADVANCED_BRANCHING
1117 Assert(!(std::is_same<Number, adouble>::value ||
1118 std::is_same<OtherNumber, adouble>::value),
1120 "The Tensor equality operator for ADOL-C taped numbers has not yet "
1121 "been extended to support advanced branching."));
1128template <
int dim,
typename Number>
1129template <
typename OtherNumber>
1133 return !((*this) == p);
1137template <
int dim,
typename Number>
1138template <
typename OtherNumber>
1148template <
int dim,
typename Number>
1149template <
typename OtherNumber>
1162 namespace ComplexWorkaround
1164 template <
typename Number,
typename OtherNumber>
1166 multiply_assign_scalar(Number &val,
const OtherNumber &s)
1171# ifdef __CUDA_ARCH__
1172 template <
typename Number,
typename OtherNumber>
1174 multiply_assign_scalar(std::complex<Number> &,
const OtherNumber &)
1176 printf(
"This function is not implemented for std::complex<Number>!\n");
1184template <
int dim,
typename Number>
1185template <
typename OtherNumber>
1190 internal::ComplexWorkaround::multiply_assign_scalar(value, s);
1196template <
int dim,
typename Number>
1197template <
typename OtherNumber>
1206template <
int dim,
typename Number>
1214template <
int dim,
typename Number>
1219 ExcMessage(
"Cannot access an object of type Tensor<0,0,Number>"));
1224template <
int dim,
typename Number>
1230# ifndef __CUDA_ARCH__
1232 ExcMessage(
"Cannot access an object of type Tensor<0,0,Number>"));
1239template <
int dim,
typename Number>
1240template <
typename Iterator>
1243 const Iterator end)
const
1247 ExcMessage(
"Cannot unroll an object of type Tensor<0,0,Number>"));
1248 Assert(std::distance(current, end) >= 1,
1249 ExcMessage(
"The provided iterator range must contain at least one "
1252 return std::next(current);
1257template <
int dim,
typename Number>
1258constexpr inline void
1268template <
int dim,
typename Number>
1269template <
class Iterator>
1274 unroll_recursion(begin, end);
1279template <
int dim,
typename Number>
1280template <
class Archive>
1288template <
int dim,
typename Number>
1294template <
int rank_,
int dim,
typename Number>
1295template <
typename ArrayLike, std::size_t... indices>
1298 std::index_sequence<indices...>)
1299 :
values{
Tensor<rank_ - 1, dim, Number>(initializer[indices])...}
1301 static_assert(
sizeof...(indices) == dim,
1302 "dim should match the number of indices");
1307template <
int rank_,
int dim,
typename Number>
1317template <
int rank_,
int dim,
typename Number>
1320 :
Tensor(initializer,
std::make_index_sequence<dim>{})
1325template <
int rank_,
int dim,
typename Number>
1326template <
typename ElementType,
typename MemorySpace>
1333 for (
unsigned int i = 0; i < n_independent_components; ++i)
1334 (*
this)[unrolled_to_component_indices(i)] = initializer[i];
1339template <
int rank_,
int dim,
typename Number>
1340template <
typename OtherNumber>
1344 :
Tensor(initializer,
std::make_index_sequence<dim>{})
1349template <
int rank_,
int dim,
typename Number>
1350template <
typename OtherNumber>
1354 :
Tensor(initializer,
std::make_index_sequence<dim>{})
1359template <
int rank_,
int dim,
typename Number>
1360template <
typename OtherNumber>
1362operator
Tensor<1, dim,
Tensor<rank_ - 1, dim, OtherNumber>>()
const
1368# ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
1369template <
int rank_,
int dim,
typename Number>
1373 for (
unsigned int i = 0; i < dim; ++i)
1374 values[i] = other.
values[i];
1379template <
int rank_,
int dim,
typename Number>
1383 for (
unsigned int i = 0; i < dim; ++i)
1384 values[i] = other.
values[i];
1391 namespace TensorSubscriptor
1393 template <
typename ArrayElementType,
int dim>
1396 subscript(ArrayElementType * values,
1397 const unsigned int i,
1398 std::integral_constant<int, dim>)
1401# ifndef __CUDA_ARCH__
1412 template <
typename ArrayElementType>
1413 struct Uninitialized
1415 static ArrayElementType
value;
1418 template <
typename Type>
1419 Type Uninitialized<Type>::value;
1421 template <
typename ArrayElementType>
1424 subscript(ArrayElementType *,
1426 std::integral_constant<int, 0>)
1429# ifndef __CUDA_ARCH__
1433 "Cannot access elements of an object of type Tensor<rank,0,Number>."));
1435 return Uninitialized<ArrayElementType>::value;
1441template <
int rank_,
int dim,
typename Number>
1446 return ::internal::TensorSubscriptor::subscript(
1447 values, i, std::integral_constant<int, dim>());
1451template <
int rank_,
int dim,
typename Number>
1456# ifndef DEAL_II_COMPILER_CUDA_AWARE
1464template <
int rank_,
int dim,
typename Number>
1468# ifndef DEAL_II_COMPILER_CUDA_AWARE
1470 ExcMessage(
"Cannot access an object of type Tensor<rank_,0,Number>"));
1473 return TensorAccessors::extract<rank_>(*
this, indices);
1478template <
int rank_,
int dim,
typename Number>
1482# ifndef DEAL_II_COMPILER_CUDA_AWARE
1484 ExcMessage(
"Cannot access an object of type Tensor<rank_,0,Number>"));
1487 return TensorAccessors::extract<rank_>(*
this, indices);
1492template <
int rank_,
int dim,
typename Number>
1496 return std::addressof(
1497 this->
operator[](this->unrolled_to_component_indices(0)));
1502template <
int rank_,
int dim,
typename Number>
1503inline const Number *
1506 return std::addressof(
1507 this->
operator[](this->unrolled_to_component_indices(0)));
1512template <
int rank_,
int dim,
typename Number>
1516 return begin_raw() + n_independent_components;
1521template <
int rank_,
int dim,
typename Number>
1522inline const Number *
1525 return begin_raw() + n_independent_components;
1530template <
int rank_,
int dim,
typename Number>
1531template <
typename OtherNumber>
1537 for (
unsigned int i = 0; i < dim; ++i)
1544template <
int rank_,
int dim,
typename Number>
1551 for (
unsigned int i = 0; i < dim; ++i)
1557# ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
1558template <
int rank_,
int dim,
typename Number>
1562 for (
unsigned int i = 0; i < dim; ++i)
1563 values[i] = other.
values[i];
1569template <
int rank_,
int dim,
typename Number>
1574 for (
unsigned int i = 0; i < dim; ++i)
1575 values[i] = other.
values[i];
1581template <
int rank_,
int dim,
typename Number>
1582template <
typename OtherNumber>
1583constexpr inline bool
1587 for (
unsigned int i = 0; i < dim; ++i)
1588 if (values[i] != p.
values[i])
1601constexpr inline bool
1608template <
int rank_,
int dim,
typename Number>
1609template <
typename OtherNumber>
1614 return !((*this) == p);
1618template <
int rank_,
int dim,
typename Number>
1619template <
typename OtherNumber>
1625 for (
unsigned int i = 0; i < dim; ++i)
1626 values[i] += p.
values[i];
1631template <
int rank_,
int dim,
typename Number>
1632template <
typename OtherNumber>
1638 for (
unsigned int i = 0; i < dim; ++i)
1639 values[i] -= p.
values[i];
1644template <
int rank_,
int dim,
typename Number>
1645template <
typename OtherNumber>
1650 for (
unsigned int i = 0; i < dim; ++i)
1658 namespace TensorImplementation
1663 typename OtherNumber,
1664 typename std::enable_if<
1667 !std::is_same<Number, Differentiation::SD::Expression>::value,
1671 const OtherNumber &factor)
1673 const Number inverse_factor = Number(1.) / factor;
1675 for (
unsigned int d = 0;
d < dim; ++
d)
1676 t[d] *= inverse_factor;
1683 typename OtherNumber,
1684 typename std::enable_if<
1687 std::is_same<Number, Differentiation::SD::Expression>::value,
1691 const OtherNumber &factor)
1694 for (
unsigned int d = 0;
d < dim; ++
d)
1701template <
int rank_,
int dim,
typename Number>
1702template <
typename OtherNumber>
1712template <
int rank_,
int dim,
typename Number>
1719 for (
unsigned int i = 0; i < dim; ++i)
1720 tmp.
values[i] = -values[i];
1726template <
int rank_,
int dim,
typename Number>
1734template <
int rank_,
int dim,
typename Number>
1741 for (
unsigned int i = 0; i < dim; ++i)
1742 s += values[i].norm_square();
1749template <
int rank_,
int dim,
typename Number>
1750template <
typename OtherNumber>
1754 unroll(result.
begin(), result.
end());
1759template <
int rank_,
int dim,
typename Number>
1760template <
class Iterator>
1763 const Iterator end)
const
1766 unroll_recursion(begin, end);
1771template <
int rank_,
int dim,
typename Number>
1772template <
typename Iterator>
1775 const Iterator end)
const
1777 auto next = current;
1778 for (
unsigned int i = 0; i < dim; ++i)
1779 next = values[i].unroll_recursion(next, end);
1784template <
int rank_,
int dim,
typename Number>
1785constexpr inline unsigned int
1789 unsigned int index = 0;
1790 for (
int r = 0; r < rank_; ++r)
1791 index = index * dim + indices[r];
1804 inline constexpr unsigned int
1805 mod(
const unsigned int x)
1812 mod<0>(
const unsigned int x)
1819 inline constexpr unsigned int
1820 div(
const unsigned int x)
1827 div<0>(
const unsigned int x)
1837template <
int rank_,
int dim,
typename Number>
1845 unsigned int remainder = i;
1846 for (
int r = rank_ - 1; r >= 0; --r)
1848 indices[r] = internal::mod<dim>(remainder);
1849 remainder = internal::div<dim>(remainder);
1857template <
int rank_,
int dim,
typename Number>
1858constexpr inline void
1861 for (
unsigned int i = 0; i < dim; ++i)
1866template <
int rank_,
int dim,
typename Number>
1867constexpr std::size_t
1874template <
int rank_,
int dim,
typename Number>
1875template <
class Archive>
1883template <
int rank_,
int dim,
typename Number>
1902template <
int rank_,
int dim,
typename Number>
1903inline std::ostream &
1906 for (
unsigned int i = 0; i < dim; ++i)
1923template <
int dim,
typename Number>
1924inline std::ostream &
1927 out << static_cast<const Number &>(p);
1949template <
int dim,
typename Number,
typename Other>
1954 return object *
static_cast<const Number &
>(t);
1969template <
int dim,
typename Number,
typename Other>
1974 return static_cast<const Number &
>(t) *
object;
1989template <
int dim,
typename Number,
typename OtherNumber>
1995 return static_cast<const Number &
>(src1) *
1996 static_cast<const OtherNumber &
>(src2);
2007template <
int dim,
typename Number,
typename OtherNumber>
2015 return static_cast<const Number &
>(t) / factor;
2026template <
int dim,
typename Number,
typename OtherNumber>
2032 return static_cast<const Number &
>(p) +
static_cast<const OtherNumber &
>(q);
2043template <
int dim,
typename Number,
typename OtherNumber>
2049 return static_cast<const Number &
>(p) -
static_cast<const OtherNumber &
>(q);
2065template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2075 for (
unsigned int d = 0; d < dim; ++d)
2076 tt[d] = t[d] * factor;
2093template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2108 namespace TensorImplementation
2113 typename OtherNumber,
2114 typename std::enable_if<
2121 const OtherNumber & factor)
2124 const Number inverse_factor = Number(1.) / factor;
2126 for (
unsigned int d = 0; d < dim; ++d)
2127 tt[d] = t[d] * inverse_factor;
2135 typename OtherNumber,
2136 typename std::enable_if<
2143 const OtherNumber & factor)
2147 for (
unsigned int d = 0; d < dim; ++d)
2148 tt[d] = t[d] / factor;
2164template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2185template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2193 for (
unsigned int i = 0; i < dim; ++i)
2209template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2217 for (
unsigned int i = 0; i < dim; ++i)
2229template <
int dim,
typename Number,
typename OtherNumber>
2258template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2266 for (
unsigned int i = 0; i < dim; ++i)
2316template <
int rank_1,
2320 typename OtherNumber,
2321 typename =
typename std::enable_if<rank_1 >= 1 && rank_2 >= 1>::type>
2323 typename Tensor<rank_1 + rank_2 - 2,
2329 typename Tensor<rank_1 + rank_2 - 2,
2334 TensorAccessors::internal::
2335 ReorderedIndexView<0, rank_2, const Tensor<rank_2, dim, OtherNumber>>
2336 reordered = TensorAccessors::reordered_index_view<0, rank_2>(src2);
2337 TensorAccessors::contract<1, rank_1, rank_2, dim>(result, src1, reordered);
2371template <
int index_1,
2377 typename OtherNumber>
2379 typename Tensor<rank_1 + rank_2 - 2,
2385 Assert(0 <= index_1 && index_1 < rank_1,
2387 "The specified index_1 must lie within the range [0,rank_1)"));
2388 Assert(0 <= index_2 && index_2 < rank_2,
2390 "The specified index_2 must lie within the range [0,rank_2)"));
2397 reord_01 = reordered_index_view<index_1, rank_1>(src1);
2403 reord_02 = reordered_index_view<index_2, rank_2>(src2);
2405 typename Tensor<rank_1 + rank_2 - 2,
2409 TensorAccessors::contract<1, rank_1, rank_2, dim>(result, reord_01, reord_02);
2444template <
int index_1,
2452 typename OtherNumber>
2454 typename Tensor<rank_1 + rank_2 - 4,
2460 Assert(0 <= index_1 && index_1 < rank_1,
2462 "The specified index_1 must lie within the range [0,rank_1)"));
2463 Assert(0 <= index_3 && index_3 < rank_1,
2465 "The specified index_3 must lie within the range [0,rank_1)"));
2466 Assert(index_1 != index_3,
2467 ExcMessage(
"index_1 and index_3 must not be the same"));
2468 Assert(0 <= index_2 && index_2 < rank_2,
2470 "The specified index_2 must lie within the range [0,rank_2)"));
2471 Assert(0 <= index_4 && index_4 < rank_2,
2473 "The specified index_4 must lie within the range [0,rank_2)"));
2474 Assert(index_2 != index_4,
2475 ExcMessage(
"index_2 and index_4 must not be the same"));
2482 reord_1 = TensorAccessors::reordered_index_view<index_1, rank_1>(src1);
2486 reord_2 = TensorAccessors::reordered_index_view<index_2, rank_2>(src2);
2492 (index_3 < index_1 ? index_3 : index_3 - 1),
2504 (index_4 < index_2 ? index_4 : index_4 - 1),
2512 typename Tensor<rank_1 + rank_2 - 4,
2516 TensorAccessors::contract<2, rank_1, rank_2, dim>(result, reord_3, reord_4);
2533template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2540 TensorAccessors::contract<rank, rank, rank, dim>(result, left, right);
2562template <
template <
int,
int,
typename>
class TensorT1,
2563 template <
int,
int,
typename>
2565 template <
int,
int,
typename>
2576 const TensorT2<rank_1 + rank_2, dim, T2> &middle,
2577 const TensorT3<rank_2, dim, T3> & right)
2581 return TensorAccessors::contract3<rank_1, rank_2, dim, return_type>(left,
2597template <
int rank_1,
2601 typename OtherNumber>
2607 typename Tensor<rank_1 + rank_2,
2611 TensorAccessors::contract<0, rank_1, rank_2, dim>(result, src1, src2);
2633template <
int dim,
typename Number>
2642 result[1] = -src[0];
2657template <
int dim,
typename Number1,
typename Number2>
2668 constexpr int s0 = 0 % dim;
2669 constexpr int s1 = 1 % dim;
2670 constexpr int s2 = 2 % dim;
2672 result[s0] = src1[s1] * src2[s2] - src1[s2] * src2[s1];
2673 result[s1] = src1[s2] * src2[s0] - src1[s0] * src2[s2];
2674 result[s2] = src1[s0] * src2[s1] - src1[s1] * src2[s0];
2692template <
int dim,
typename Number>
2700 for (
unsigned int k = 0; k < dim; ++k)
2702 Tensor<2, dim - 1, Number> minor;
2703 for (
unsigned int i = 0; i < dim - 1; ++i)
2704 for (
unsigned int j = 0; j < dim - 1; ++j)
2705 minor[i][j] = t[i][j < k ? j : j + 1];
2712 return ((dim % 2 == 0) ? 1. : -1.) * det;
2720template <
typename Number>
2732template <
typename Number>
2737 return t[0][0] * t[1][1] - t[1][0] * t[0][1];
2745template <
typename Number>
2756 return t[0][0] * C0 + t[0][1] * C1 + t[0][2] * C2;
2766template <
int dim,
typename Number>
2771 for (
unsigned int i = 1; i < dim; ++i)
2785template <
int dim,
typename Number>
2789 Number return_tensor[dim][dim];
2802template <
typename Number>
2810 return return_tensor;
2814template <
typename Number>
2821 1.0 / (t[0][0] * t[1][1] - t[1][0] * t[0][1]));
2822 return_tensor[0][0] = t[1][1];
2823 return_tensor[0][1] = -t[0][1];
2824 return_tensor[1][0] = -t[1][0];
2825 return_tensor[1][1] = t[0][0];
2826 return_tensor *= inv_det_t;
2828 return return_tensor;
2832template <
typename Number>
2857 1.0 / (t[0][0] * return_tensor[0][0] + t[0][1] * return_tensor[1][0] +
2858 t[0][2] * return_tensor[2][0]));
2859 return_tensor *= inv_det_t;
2861 return return_tensor;
2872template <
int dim,
typename Number>
2877 for (
unsigned int i = 0; i < dim; ++i)
2880 for (
unsigned int j = i + 1; j < dim; ++j)
2903template <
int dim,
typename Number>
2924template <
int dim,
typename Number>
2995template <
int dim,
typename Number>
3007template <
int dim,
typename Number>
3012 for (
unsigned int j = 0; j < dim; ++j)
3015 for (
unsigned int i = 0; i < dim; ++i)
3016 sum += std::fabs(t[i][j]);
3033template <
int dim,
typename Number>
3038 for (
unsigned int i = 0; i < dim; ++i)
3041 for (
unsigned int j = 0; j < dim; ++j)
3042 sum += std::fabs(t[i][j]);
3057# ifdef DEAL_II_ADOLC_WITH_ADVANCED_BRANCHING
3066 for (
unsigned int j = 0; j < dim; ++j)
3069 for (
unsigned int i = 0; i < dim; ++i)
3070 sum += std::fabs(t[i][j]);
3072 condassign(max, (sum > max), sum, max);
3084 for (
unsigned int i = 0; i < dim; ++i)
3087 for (
unsigned int j = 0; j < dim; ++j)
3088 sum += std::fabs(t[i][j]);
3090 condassign(max, (sum > max), sum, max);
constexpr Tensor & operator*=(const OtherNumber &factor)
void serialize(Archive &ar, const unsigned int version)
constexpr Tensor & operator/=(const OtherNumber &factor)
const Number * end_raw() const
constexpr Tensor & operator-=(const Tensor< 0, dim, OtherNumber > &rhs)
constexpr Tensor(const Tensor< 0, dim, OtherNumber > &initializer)
constexpr Tensor(const OtherNumber &initializer)
Iterator unroll_recursion(const Iterator current, const Iterator end) const
constexpr Tensor & operator=(const OtherNumber &d)
constexpr real_type norm_square() const
constexpr bool operator!=(const Tensor< 0, dim, OtherNumber > &rhs) const
constexpr Tensor & operator=(const Tensor< 0, dim, OtherNumber > &rhs)
const Number * begin_raw() const
constexpr Tensor & operator+=(const Tensor< 0, dim, OtherNumber > &rhs)
void unroll(const Iterator begin, const Iterator end) const
constexpr bool operator==(const Tensor< 0, dim, OtherNumber > &rhs) const
typename numbers::NumberTraits< Number >::real_type real_type
constexpr Tensor operator-() const
constexpr Tensor & operator/=(const OtherNumber &factor)
constexpr Tensor(const ArrayView< ElementType, MemorySpace > &initializer)
constexpr Tensor< 2, dim, Number > cofactor(const Tensor< 2, dim, Number > &t)
constexpr bool operator==(const Tensor< rank_, dim, OtherNumber > &) const
constexpr Tensor< rank, dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator/(const Tensor< rank, dim, Number > &t, const OtherNumber &factor)
constexpr Tensor(const Tensor< 1, dim, Tensor< rank_ - 1, dim, OtherNumber > > &initializer)
constexpr Tensor< rank_1+rank_2, dim, typename ProductType< Number, OtherNumber >::type > outer_product(const Tensor< rank_1, dim, Number > &src1, const Tensor< rank_2, dim, OtherNumber > &src2)
constexpr Tensor< 2, dim, Number > adjugate(const Tensor< 2, dim, Number > &t)
typename Tensor< rank_ - 1, dim, Number >::array_type[(dim !=0) ? dim :1] array_type
constexpr const Number & operator[](const TableIndices< rank_ > &indices) const
constexpr ProductType< T1, typenameProductType< T2, T3 >::type >::type contract3(const TensorT1< rank_1, dim, T1 > &left, const TensorT2< rank_1+rank_2, dim, T2 > &middle, const TensorT3< rank_2, dim, T3 > &right)
constexpr Tensor< 2, dim, Number > transpose(const Tensor< 2, dim, Number > &t)
constexpr Tensor< 0, dim, typename ProductType< Number, OtherNumber >::type > operator-(const Tensor< 0, dim, Number > &p, const Tensor< 0, dim, OtherNumber > &q)
constexpr Tensor< 0, dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator/(const Tensor< 0, dim, Number > &t, const OtherNumber &factor)
static constexpr unsigned int rank
constexpr Number determinant(const Tensor< 2, dim, Number > &t)
constexpr Tensor(const Tensor< rank_, dim, OtherNumber > &initializer)
numbers::NumberTraits< Number >::real_type norm() const
constexpr Tensor & operator-=(const Tensor< rank_, dim, OtherNumber > &)
void unroll(const Iterator begin, const Iterator end) const
void unroll(Vector< OtherNumber > &result) const
Iterator unroll_recursion(const Iterator current, const Iterator end) const
static constexpr unsigned int component_to_unrolled_index(const TableIndices< rank_ > &indices)
constexpr ProductType< Number, OtherNumber >::type operator*(const Tensor< 0, dim, Number > &src1, const Tensor< 0, dim, OtherNumber > &src2)
const Number * begin_raw() const
constexpr bool operator!=(const Tensor< rank_, dim, OtherNumber > &) const
constexpr ProductType< Number, OtherNumber >::type scalar_product(const Tensor< rank, dim, Number > &left, const Tensor< rank, dim, OtherNumber > &right)
constexpr Tensor< 0, dim, typename ProductType< Number, OtherNumber >::type > schur_product(const Tensor< 0, dim, Number > &src1, const Tensor< 0, dim, OtherNumber > &src2)
constexpr value_type & operator[](const unsigned int i)
typename Tensor< rank_ - 1, dim, Number >::tensor_type value_type
constexpr Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > operator+(const Tensor< rank, dim, Number > &p, const Tensor< rank, dim, OtherNumber > &q)
Number linfty_norm(const Tensor< 2, dim, Number > &t)
constexpr ProductType< Other, Number >::type operator*(const Other &object, const Tensor< 0, dim, Number > &t)
constexpr Tensor< rank_1+rank_2-4, dim, typenameProductType< Number, OtherNumber >::type >::tensor_type double_contract(const Tensor< rank_1, dim, Number > &src1, const Tensor< rank_2, dim, OtherNumber > &src2)
Tensor< 2, dim, Number > project_onto_orthogonal_tensors(const Tensor< 2, dim, Number > &A)
Number l1_norm(const Tensor< 2, dim, Number > &t)
constexpr Number trace(const Tensor< 2, dim, Number > &d)
static constexpr unsigned int dimension
static constexpr TableIndices< rank_ > unrolled_to_component_indices(const unsigned int i)
constexpr Tensor< 1, dim, Number > cross_product_2d(const Tensor< 1, dim, Number > &src)
constexpr Tensor< rank, dim, typename ProductType< typename EnableIfScalar< Number >::type, OtherNumber >::type > operator*(const Number &factor, const Tensor< rank, dim, OtherNumber > &t)
static constexpr std::size_t memory_consumption()
constexpr Tensor & operator=(const Number &d)
OtherNumber::type::tensor_type operator*(const Tensor< rank_1, dim, Number > &src1, const Tensor< rank_2, dim, OtherNumber > &src2)
constexpr Number determinant(const Tensor< 2, 1, Number > &t)
constexpr Tensor< 0, dim, typename ProductType< Number, OtherNumber >::type > operator+(const Tensor< 0, dim, Number > &p, const Tensor< 0, dim, OtherNumber > &q)
constexpr Tensor & operator+=(const Tensor< rank_, dim, OtherNumber > &)
const Number * end_raw() const
constexpr Number & operator[](const TableIndices< rank_ > &indices)
constexpr Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > schur_product(const Tensor< rank, dim, Number > &src1, const Tensor< rank, dim, OtherNumber > &src2)
constexpr numbers::NumberTraits< Number >::real_type norm_square() const
constexpr Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > operator-(const Tensor< rank, dim, Number > &p, const Tensor< rank, dim, OtherNumber > &q)
Tensor< rank_, dim, Number > tensor_type
constexpr ProductType< Number, Other >::type operator*(const Tensor< 0, dim, Number > &t, const Other &object)
constexpr Tensor(const ArrayLike &initializer, std::index_sequence< Indices... >)
constexpr Number determinant(const Tensor< 2, 2, Number > &t)
constexpr Tensor< rank_1+rank_2-2, dim, typenameProductType< Number, OtherNumber >::type >::tensor_type contract(const Tensor< rank_1, dim, Number > &src1, const Tensor< rank_2, dim, OtherNumber > &src2)
constexpr Tensor< rank, dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator*(const Tensor< rank, dim, Number > &t, const OtherNumber &factor)
constexpr Tensor< 2, dim, Number > invert(const Tensor< 2, dim, Number > &)
void serialize(Archive &ar, const unsigned int version)
constexpr Tensor & operator*=(const OtherNumber &factor)
constexpr const value_type & operator[](const unsigned int i) const
constexpr Number determinant(const Tensor< 2, 3, Number > &t)
constexpr Tensor(const array_type &initializer)
static constexpr unsigned int n_independent_components
constexpr Tensor operator-() const
Tensor< rank_ - 1, dim, Number > values[(dim !=0) ? dim :1]
constexpr Tensor< 1, dim, typename ProductType< Number1, Number2 >::type > cross_product_3d(const Tensor< 1, dim, Number1 > &src1, const Tensor< 1, dim, Number2 > &src2)
constexpr Tensor & operator=(const Tensor< rank_, dim, OtherNumber > &rhs)
#define DEAL_II_ALWAYS_INLINE
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNotImplemented()
static ::ExceptionBase & ExcScalarAssignmentOnlyForZeroValue()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
constexpr internal::ReorderedIndexView< index, rank, T > reordered_index_view(T &t)
T sum(const T &t, const MPI_Comm &mpi_communicator)
constexpr Tensor< rank, dim, typename ProductType< Number, OtherNumber >::type > division_operator(const Tensor< rank, dim, Number > &t, const OtherNumber &factor)
constexpr bool value_is_zero(const Number &value)
constexpr bool values_are_equal(const Number1 &value_1, const Number2 &value_2)
::VectorizedArray< Number, width > sqrt(const ::VectorizedArray< Number, width > &)
#define DEAL_II_CUDA_HOST_DEV
typename internal::ProductTypeImpl< typename std::decay< T >::type, typename std::decay< U >::type >::type type
static constexpr const T & value(const T &t)
decltype(std::declval< T >() *std::declval< U >()) type
static constexpr std::enable_if< std::is_same< Dummy, number >::value &&is_cuda_compatible< Dummy >::value, real_type >::type abs_square(const number &x)
static real_type abs(const number &x)
constexpr Tensor< 2, dim, Number > cofactor(const Tensor< 2, dim, Number > &t)
constexpr Tensor< 2, dim, Number > adjugate(const Tensor< 2, dim, Number > &t)
std::ostream & operator<<(std::ostream &out, const Tensor< rank_, dim, Number > &p)
constexpr Tensor< 2, dim, Number > transpose(const Tensor< 2, dim, Number > &t)
constexpr Number determinant(const Tensor< 2, dim, Number > &t)
constexpr Tensor< 0, dim, typename ProductType< Number, OtherNumber >::type > schur_product(const Tensor< 0, dim, Number > &src1, const Tensor< 0, dim, OtherNumber > &src2)
Number linfty_norm(const Tensor< 2, dim, Number > &t)
Number l1_norm(const Tensor< 2, dim, Number > &t)
constexpr Tensor< 2, dim, Number > invert(const Tensor< 2, dim, Number > &)