16#ifndef dealii_tensor_h
17#define dealii_tensor_h
28#ifdef DEAL_II_WITH_ADOLC
29# include <adolc/adouble.h>
39template <
typename ElementType,
typename MemorySpace>
42template <
int dim,
typename Number>
46template <
int rank_,
int dim, typename Number =
double>
48template <typename Number>
50template <typename number>
91template <
int dim,
typename Number>
95 static_assert(dim >= 0,
96 "Tensors must have a dimension greater than or equal to one.");
111 static constexpr unsigned int rank = 0;
156 template <
typename OtherNumber>
165 template <
typename OtherNumber>
169#ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
261 template <
typename OtherNumber>
265#if defined(__INTEL_COMPILER) || defined(DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG)
278#ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
292 template <
typename OtherNumber>
301 template <
typename OtherNumber>
308 template <
typename OtherNumber>
315 template <
typename OtherNumber>
324 template <
typename OtherNumber>
333 template <
typename OtherNumber>
342 template <
typename OtherNumber>
351 template <
typename OtherNumber>
402 template <
class Iterator>
404 unroll(
const Iterator begin,
const Iterator end)
const;
411 template <
class Archive>
430 template <
typename Iterator>
435 template <
int,
int,
typename>
514template <
int rank_,
int dim,
typename Number>
518 static_assert(rank_ >= 1,
519 "Tensors must have a rank greater than or equal to one.");
520 static_assert(dim >= 0,
521 "Tensors must have a dimension greater than or equal to zero.");
535 static constexpr unsigned int rank = rank_;
585 template <
typename ElementType,
typename MemorySpace>
596 template <
typename OtherNumber>
603 template <
typename OtherNumber>
610 template <
typename OtherNumber>
614#ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
645 constexpr const Number &
685 template <
typename OtherNumber>
706#ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
723 template <
typename OtherNumber>
730 template <
typename OtherNumber>
739 template <
typename OtherNumber>
748 template <
typename OtherNumber>
758 template <
typename OtherNumber>
767 template <
typename OtherNumber>
825 template <
typename OtherNumber>
839 template <
class Iterator>
841 unroll(
const Iterator begin,
const Iterator end)
const;
862 static constexpr std::size_t
870 template <
class Archive>
891 template <
typename Iterator>
901 template <
typename ArrayLike, std::size_t... Indices>
903 Tensor(
const ArrayLike &initializer, std::index_sequence<Indices...>);
906 template <
int,
int,
typename>
911 friend class Point<dim, Number>;
922 template <
int rank,
int dim,
typename T,
typename U>
923 struct ProductTypeImpl<
Tensor<rank, dim, T>,
std::complex<U>>
929 template <
int rank,
int dim,
typename T,
typename U>
930 struct ProductTypeImpl<
Tensor<rank, dim,
std::complex<T>>, std::complex<U>>
936 template <
typename T,
int rank,
int dim,
typename U>
937 struct ProductTypeImpl<
std::complex<T>,
Tensor<rank, dim, U>>
943 template <
int rank,
int dim,
typename T,
typename U>
944 struct ProductTypeImpl<
std::complex<T>,
Tensor<rank, dim, std::complex<U>>>
955 template <
int rank,
int dim,
typename T>
956 struct NumberType<
Tensor<rank, dim, T>>
979template <
int dim,
typename Number>
989template <
int dim,
typename Number>
990template <
typename OtherNumber>
998template <
int dim,
typename Number>
999template <
typename OtherNumber>
1006# ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
1007template <
int dim,
typename Number>
1015template <
int dim,
typename Number>
1018 :
value{std::move(other.value)}
1023template <
int dim,
typename Number>
1027 return std::addressof(value);
1032template <
int dim,
typename Number>
1033inline const Number *
1036 return std::addressof(value);
1041template <
int dim,
typename Number>
1045 return begin_raw() + n_independent_components;
1050template <
int dim,
typename Number>
1054 return begin_raw() + n_independent_components;
1059template <
int dim,
typename Number>
1064 ExcMessage(
"Cannot access an object of type Tensor<0,0,Number>"));
1069template <
int dim,
typename Number>
1074 ExcMessage(
"Cannot access an object of type Tensor<0,0,Number>"));
1080template <
int dim,
typename Number>
1081template <
typename OtherNumber>
1090# if defined(__INTEL_COMPILER) || defined(DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG)
1091template <
int dim,
typename Number>
1100# ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
1101template <
int dim,
typename Number>
1105 value = std::move(other.value);
1112template <
int dim,
typename Number>
1113template <
typename OtherNumber>
1122template <
int dim,
typename Number>
1123template <
typename OtherNumber>
1124constexpr inline bool
1127# ifdef DEAL_II_ADOLC_WITH_ADVANCED_BRANCHING
1128 Assert(!(std::is_same<Number, adouble>::value ||
1129 std::is_same<OtherNumber, adouble>::value),
1131 "The Tensor equality operator for ADOL-C taped numbers has not yet "
1132 "been extended to support advanced branching."));
1139template <
int dim,
typename Number>
1140template <
typename OtherNumber>
1144 return !((*this) == p);
1148template <
int dim,
typename Number>
1149template <
typename OtherNumber>
1158template <
int dim,
typename Number>
1159template <
typename OtherNumber>
1171 namespace ComplexWorkaround
1173 template <
typename Number,
typename OtherNumber>
1175 multiply_assign_scalar(Number &val,
const OtherNumber &s)
1180 template <
typename Number,
typename OtherNumber>
1182 multiply_assign_scalar(std::complex<Number> &val,
const OtherNumber &s)
1184# if KOKKOS_VERSION >= 30600
1185 KOKKOS_IF_ON_HOST((val *= s;))
1186 KOKKOS_IF_ON_DEVICE(({
1190 "This function is not implemented for std::complex<Number>!\n");
1193# ifdef KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST
1199 "This function is not implemented for std::complex<Number>!\n");
1207template <
int dim,
typename Number>
1208template <
typename OtherNumber>
1212 internal::ComplexWorkaround::multiply_assign_scalar(value, s);
1218template <
int dim,
typename Number>
1219template <
typename OtherNumber>
1228template <
int dim,
typename Number>
1236template <
int dim,
typename Number>
1241 ExcMessage(
"Cannot access an object of type Tensor<0,0,Number>"));
1246template <
int dim,
typename Number>
1252 ExcMessage(
"Cannot access an object of type Tensor<0,0,Number>"));
1258template <
int dim,
typename Number>
1259template <
typename Iterator>
1262 const Iterator end)
const
1266 ExcMessage(
"Cannot unroll an object of type Tensor<0,0,Number>"));
1267 Assert(std::distance(current, end) >= 1,
1268 ExcMessage(
"The provided iterator range must contain at least one "
1271 return std::next(current);
1276template <
int dim,
typename Number>
1277constexpr inline void
1287template <
int dim,
typename Number>
1288template <
class Iterator>
1293 unroll_recursion(begin, end);
1298template <
int dim,
typename Number>
1299template <
class Archive>
1307template <
int dim,
typename Number>
1313template <
int rank_,
int dim,
typename Number>
1314template <
typename ArrayLike, std::size_t... indices>
1317 std::index_sequence<indices...>)
1318 :
values{
Tensor<rank_ - 1, dim, Number>(initializer[indices])...}
1320 static_assert(
sizeof...(indices) == dim,
1321 "dim should match the number of indices");
1326template <
int rank_,
int dim,
typename Number>
1336template <
int rank_,
int dim,
typename Number>
1339 :
Tensor(initializer,
std::make_index_sequence<dim>{})
1344template <
int rank_,
int dim,
typename Number>
1345template <
typename ElementType,
typename MemorySpace>
1351 const int my_n_independent_components = n_independent_components;
1354 for (
unsigned int i = 0; i < my_n_independent_components; ++i)
1355 (*
this)[unrolled_to_component_indices(i)] = initializer[i];
1360template <
int rank_,
int dim,
typename Number>
1361template <
typename OtherNumber>
1365 :
Tensor(initializer,
std::make_index_sequence<dim>{})
1370template <
int rank_,
int dim,
typename Number>
1371template <
typename OtherNumber>
1375 :
Tensor(initializer,
std::make_index_sequence<dim>{})
1380template <
int rank_,
int dim,
typename Number>
1381template <
typename OtherNumber>
1383operator
Tensor<1, dim,
Tensor<rank_ - 1, dim, OtherNumber>>()
const
1389# ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
1390template <
int rank_,
int dim,
typename Number>
1394 for (
unsigned int i = 0; i < dim; ++i)
1395 values[i] = other.
values[i];
1400template <
int rank_,
int dim,
typename Number>
1404 for (
unsigned int i = 0; i < dim; ++i)
1405 values[i] = other.values[i];
1411 namespace TensorSubscriptor
1413 template <
typename ArrayElementType,
int dim>
1415 subscript(ArrayElementType * values,
1416 const unsigned int i,
1417 std::integral_constant<int, dim>)
1423 template <
typename ArrayElementType>
1425 subscript(ArrayElementType *dummy,
1427 std::integral_constant<int, 0>)
1432 "Cannot access elements of an object of type Tensor<rank,0,Number>."));
1439template <
int rank_,
int dim,
typename Number>
1444 return ::internal::TensorSubscriptor::subscript(
1445 values, i, std::integral_constant<int, dim>());
1449template <
int rank_,
int dim,
typename Number>
1454# if KOKKOS_VERSION < 30700
1455# ifdef KOKKOS_ACTIVE_MEMORY_SPACE_HOST
1466template <
int rank_,
int dim,
typename Number>
1470# if KOKKOS_VERSION < 30700
1471# ifdef KOKKOS_ACTIVE_MEMORY_SPACE_HOST
1473 ExcMessage(
"Cannot access an object of type Tensor<rank_,0,Number>"));
1479 "Cannot access an object of type Tensor<rank_,0,Number>"));))
1482 return TensorAccessors::extract<rank_>(*
this, indices);
1487template <
int rank_,
int dim,
typename Number>
1491# if KOKKOS_VERSION < 30700
1492# ifdef KOKKOS_ACTIVE_MEMORY_SPACE_HOST
1494 ExcMessage(
"Cannot access an object of type Tensor<rank_,0,Number>"));
1500 "Cannot access an object of type Tensor<rank_,0,Number>"));))
1503 return TensorAccessors::extract<rank_>(*
this, indices);
1508template <
int rank_,
int dim,
typename Number>
1512 return std::addressof(
1513 this->
operator[](this->unrolled_to_component_indices(0)));
1518template <
int rank_,
int dim,
typename Number>
1519inline const Number *
1522 return std::addressof(
1523 this->
operator[](this->unrolled_to_component_indices(0)));
1528template <
int rank_,
int dim,
typename Number>
1532 return begin_raw() + n_independent_components;
1537template <
int rank_,
int dim,
typename Number>
1538inline const Number *
1541 return begin_raw() + n_independent_components;
1546template <
int rank_,
int dim,
typename Number>
1547template <
typename OtherNumber>
1553 for (
unsigned int i = 0; i < dim; ++i)
1560template <
int rank_,
int dim,
typename Number>
1568 for (
unsigned int i = 0; i < dim; ++i)
1574# ifdef DEAL_II_DELETED_MOVE_CONSTRUCTOR_BUG
1575template <
int rank_,
int dim,
typename Number>
1579 for (
unsigned int i = 0; i < dim; ++i)
1580 values[i] = other.
values[i];
1586template <
int rank_,
int dim,
typename Number>
1591 for (
unsigned int i = 0; i < dim; ++i)
1592 values[i] = other.
values[i];
1598template <
int rank_,
int dim,
typename Number>
1599template <
typename OtherNumber>
1600constexpr inline bool
1604 for (
unsigned int i = 0; i < dim; ++i)
1605 if (values[i] != p.
values[i])
1618constexpr inline bool
1625template <
int rank_,
int dim,
typename Number>
1626template <
typename OtherNumber>
1631 return !((*this) == p);
1635template <
int rank_,
int dim,
typename Number>
1636template <
typename OtherNumber>
1642 for (
unsigned int i = 0; i < dim; ++i)
1643 values[i] += p.
values[i];
1648template <
int rank_,
int dim,
typename Number>
1649template <
typename OtherNumber>
1655 for (
unsigned int i = 0; i < dim; ++i)
1656 values[i] -= p.
values[i];
1661template <
int rank_,
int dim,
typename Number>
1662template <
typename OtherNumber>
1667 for (
unsigned int i = 0; i < dim; ++i)
1675 namespace TensorImplementation
1680 typename OtherNumber,
1684 !std::is_same<Number, Differentiation::SD::Expression>::value,
1688 const OtherNumber &factor)
1690 const Number inverse_factor = Number(1.) / factor;
1692 for (
unsigned int d = 0;
d < dim; ++
d)
1693 t[d] *= inverse_factor;
1700 typename OtherNumber,
1704 std::is_same<Number, Differentiation::SD::Expression>::value,
1708 const OtherNumber &factor)
1711 for (
unsigned int d = 0;
d < dim; ++
d)
1718template <
int rank_,
int dim,
typename Number>
1719template <
typename OtherNumber>
1729template <
int rank_,
int dim,
typename Number>
1736 for (
unsigned int i = 0; i < dim; ++i)
1737 tmp.
values[i] = -values[i];
1743template <
int rank_,
int dim,
typename Number>
1749 return sqrt(norm_square());
1753template <
int rank_,
int dim,
typename Number>
1760 for (
unsigned int i = 0; i < dim; ++i)
1761 s += values[i].norm_square();
1768template <
int rank_,
int dim,
typename Number>
1769template <
typename OtherNumber>
1773 unroll(result.
begin(), result.
end());
1778template <
int rank_,
int dim,
typename Number>
1779template <
class Iterator>
1782 const Iterator end)
const
1785 unroll_recursion(begin, end);
1790template <
int rank_,
int dim,
typename Number>
1791template <
typename Iterator>
1794 const Iterator end)
const
1796 auto next = current;
1797 for (
unsigned int i = 0; i < dim; ++i)
1798 next = values[i].unroll_recursion(next, end);
1803template <
int rank_,
int dim,
typename Number>
1804constexpr inline unsigned int
1808 unsigned int index = 0;
1809 for (
int r = 0; r < rank_; ++r)
1810 index = index * dim + indices[r];
1824 mod(
const unsigned int x)
1831 mod<0>(
const unsigned int x)
1839 div(
const unsigned int x)
1846 div<0>(
const unsigned int x)
1856template <
int rank_,
int dim,
typename Number>
1861 unsigned int dummy = n_independent_components;
1867 unsigned int remainder = i;
1868 for (
int r = rank_ - 1; r >= 0; --r)
1870 indices[r] = internal::mod<dim>(remainder);
1871 remainder = internal::div<dim>(remainder);
1879template <
int rank_,
int dim,
typename Number>
1880constexpr inline void
1883 for (
unsigned int i = 0; i < dim; ++i)
1888template <
int rank_,
int dim,
typename Number>
1889constexpr std::size_t
1896template <
int rank_,
int dim,
typename Number>
1897template <
class Archive>
1905template <
int rank_,
int dim,
typename Number>
1924template <
int rank_,
int dim,
typename Number>
1925inline std::ostream &
1928 for (
unsigned int i = 0; i < dim; ++i)
1945template <
int dim,
typename Number>
1946inline std::ostream &
1949 out << static_cast<const Number &>(p);
1972template <
int dim,
typename Number,
typename Other>
1977 return object *
static_cast<const Number &
>(t);
1992template <
int dim,
typename Number,
typename Other>
1997 return static_cast<const Number &
>(t) *
object;
2012template <
int dim,
typename Number,
typename OtherNumber>
2018 return static_cast<const Number &
>(src1) *
2019 static_cast<const OtherNumber &
>(src2);
2030template <
int dim,
typename Number,
typename OtherNumber>
2038 return static_cast<const Number &
>(t) / factor;
2049template <
int dim,
typename Number,
typename OtherNumber>
2055 return static_cast<const Number &
>(p) +
static_cast<const OtherNumber &
>(q);
2066template <
int dim,
typename Number,
typename OtherNumber>
2072 return static_cast<const Number &
>(p) -
static_cast<const OtherNumber &
>(q);
2088template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2098 for (
unsigned int d = 0; d < dim; ++d)
2099 tt[d] = t[d] * factor;
2116template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2131 namespace TensorImplementation
2136 typename OtherNumber,
2144 const OtherNumber & factor)
2147 const Number inverse_factor = Number(1.) / factor;
2149 for (
unsigned int d = 0; d < dim; ++d)
2150 tt[d] = t[d] * inverse_factor;
2158 typename OtherNumber,
2166 const OtherNumber & factor)
2170 for (
unsigned int d = 0; d < dim; ++d)
2171 tt[d] = t[d] / factor;
2187template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2208template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2216 for (
unsigned int i = 0; i < dim; ++i)
2232template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2240 for (
unsigned int i = 0; i < dim; ++i)
2252template <
int dim,
typename Number,
typename OtherNumber>
2281template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2289 for (
unsigned int i = 0; i < dim; ++i)
2340template <
int rank_1,
2344 typename OtherNumber,
2345 typename = std::enable_if_t<rank_1 >= 1 && rank_2 >= 1>>
2347 typename Tensor<rank_1 + rank_2 - 2,
2353 typename Tensor<rank_1 + rank_2 - 2,
2358 TensorAccessors::internal::
2359 ReorderedIndexView<0, rank_2, const Tensor<rank_2, dim, OtherNumber>>
2360 reordered = TensorAccessors::reordered_index_view<0, rank_2>(src2);
2361 TensorAccessors::contract<1, rank_1, rank_2, dim>(result, src1, reordered);
2395template <
int index_1,
2401 typename OtherNumber>
2403 typename Tensor<rank_1 + rank_2 - 2,
2409 Assert(0 <= index_1 && index_1 < rank_1,
2411 "The specified index_1 must lie within the range [0,rank_1)"));
2412 Assert(0 <= index_2 && index_2 < rank_2,
2414 "The specified index_2 must lie within the range [0,rank_2)"));
2421 reord_01 = reordered_index_view<index_1, rank_1>(src1);
2427 reord_02 = reordered_index_view<index_2, rank_2>(src2);
2429 typename Tensor<rank_1 + rank_2 - 2,
2433 TensorAccessors::contract<1, rank_1, rank_2, dim>(result, reord_01, reord_02);
2468template <
int index_1,
2476 typename OtherNumber>
2478 typename Tensor<rank_1 + rank_2 - 4,
2484 Assert(0 <= index_1 && index_1 < rank_1,
2486 "The specified index_1 must lie within the range [0,rank_1)"));
2487 Assert(0 <= index_3 && index_3 < rank_1,
2489 "The specified index_3 must lie within the range [0,rank_1)"));
2490 Assert(index_1 != index_3,
2491 ExcMessage(
"index_1 and index_3 must not be the same"));
2492 Assert(0 <= index_2 && index_2 < rank_2,
2494 "The specified index_2 must lie within the range [0,rank_2)"));
2495 Assert(0 <= index_4 && index_4 < rank_2,
2497 "The specified index_4 must lie within the range [0,rank_2)"));
2498 Assert(index_2 != index_4,
2499 ExcMessage(
"index_2 and index_4 must not be the same"));
2506 reord_1 = TensorAccessors::reordered_index_view<index_1, rank_1>(src1);
2510 reord_2 = TensorAccessors::reordered_index_view<index_2, rank_2>(src2);
2516 (index_3 < index_1 ? index_3 : index_3 - 1),
2528 (index_4 < index_2 ? index_4 : index_4 - 1),
2536 typename Tensor<rank_1 + rank_2 - 4,
2540 TensorAccessors::contract<2, rank_1, rank_2, dim>(result, reord_3, reord_4);
2557template <
int rank,
int dim,
typename Number,
typename OtherNumber>
2564 TensorAccessors::contract<rank, rank, rank, dim>(result, left, right);
2586template <
template <
int,
int,
typename>
class TensorT1,
2587 template <
int,
int,
typename>
2589 template <
int,
int,
typename>
2599 contract3(
const TensorT1<rank_1, dim, T1> & left,
2600 const TensorT2<rank_1 + rank_2, dim, T2> &middle,
2601 const TensorT3<rank_2, dim, T3> & right)
2605 return TensorAccessors::contract3<rank_1, rank_2, dim, return_type>(left,
2621template <
int rank_1,
2625 typename OtherNumber>
2631 typename Tensor<rank_1 + rank_2,
2635 TensorAccessors::contract<0, rank_1, rank_2, dim>(result, src1, src2);
2658template <
int dim,
typename Number>
2667 result[1] = -src[0];
2682template <
int dim,
typename Number1,
typename Number2>
2693 constexpr int s0 = 0 % dim;
2694 constexpr int s1 = 1 % dim;
2695 constexpr int s2 = 2 % dim;
2697 result[s0] = src1[s1] * src2[s2] - src1[s2] * src2[s1];
2698 result[s1] = src1[s2] * src2[s0] - src1[s0] * src2[s2];
2699 result[s2] = src1[s0] * src2[s1] - src1[s1] * src2[s0];
2718template <
int dim,
typename Number>
2726 for (
unsigned int k = 0; k < dim; ++k)
2728 Tensor<2, dim - 1, Number> minor;
2729 for (
unsigned int i = 0; i < dim - 1; ++i)
2730 for (
unsigned int j = 0; j < dim - 1; ++j)
2731 minor[i][j] = t[i][j < k ? j : j + 1];
2733 const Number cofactor = ((k % 2 == 0) ? -1. : 1.) *
determinant(minor);
2735 det += t[dim - 1][k] * cofactor;
2738 return ((dim % 2 == 0) ? 1. : -1.) * det;
2746template <
typename Number>
2758template <
typename Number>
2763 return t[0][0] * t[1][1] - t[1][0] * t[0][1];
2771template <
typename Number>
2782 return t[0][0] * C0 + t[0][1] * C1 + t[0][2] * C2;
2792template <
int dim,
typename Number>
2797 for (
unsigned int i = 1; i < dim; ++i)
2811template <
int dim,
typename Number>
2815 Number return_tensor[dim][dim];
2828template <
typename Number>
2836 return return_tensor;
2840template <
typename Number>
2847 1.0 / (t[0][0] * t[1][1] - t[1][0] * t[0][1]));
2848 return_tensor[0][0] = t[1][1];
2849 return_tensor[0][1] = -t[0][1];
2850 return_tensor[1][0] = -t[1][0];
2851 return_tensor[1][1] = t[0][0];
2852 return_tensor *= inv_det_t;
2854 return return_tensor;
2858template <
typename Number>
2883 1.0 / (t[0][0] * return_tensor[0][0] + t[0][1] * return_tensor[1][0] +
2884 t[0][2] * return_tensor[2][0]));
2885 return_tensor *= inv_det_t;
2887 return return_tensor;
2898template <
int dim,
typename Number>
2903 for (
unsigned int i = 0; i < dim; ++i)
2906 for (
unsigned int j = i + 1; j < dim; ++j)
2929template <
int dim,
typename Number>
2950template <
int dim,
typename Number>
3021template <
int dim,
typename Number>
3033template <
int dim,
typename Number>
3038 for (
unsigned int j = 0; j < dim; ++j)
3041 for (
unsigned int i = 0; i < dim; ++i)
3059template <
int dim,
typename Number>
3064 for (
unsigned int i = 0; i < dim; ++i)
3067 for (
unsigned int j = 0; j < dim; ++j)
3085# ifdef DEAL_II_ADOLC_WITH_ADVANCED_BRANCHING
3094 for (
unsigned int j = 0; j < dim; ++j)
3097 for (
unsigned int i = 0; i < dim; ++i)
3098 sum += fabs(t[i][j]);
3100 condassign(max, (sum > max), sum, max);
3112 for (
unsigned int i = 0; i < dim; ++i)
3115 for (
unsigned int j = 0; j < dim; ++j)
3116 sum +=
fabs(t[i][j]);
3118 condassign(max, (sum > max), sum, max);
constexpr Tensor & operator*=(const OtherNumber &factor)
constexpr Tensor & operator=(const OtherNumber &d) &&=delete
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 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 OtherNumber &d) &
constexpr Tensor operator-() const
constexpr Tensor & operator/=(const OtherNumber &factor)
constexpr Tensor(const ArrayView< ElementType, MemorySpace > &initializer)
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)
typename Tensor< rank_ - 1, dim, Number >::array_type[(dim !=0) ? dim :1] array_type
constexpr const Number & operator[](const TableIndices< rank_ > &indices) const
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 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 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)
constexpr DEAL_II_HOST_DEVICE_ALWAYS_INLINE Tensor< 0, dim, typename ProductType< Number, OtherNumber >::type > operator-(const Tensor< 0, dim, Number > &p, const Tensor< 0, dim, OtherNumber > &q)
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 DEAL_II_HOST_DEVICE_ALWAYS_INLINE Tensor()
Number l1_norm(const Tensor< 2, dim, Number > &t)
static constexpr unsigned int dimension
static constexpr TableIndices< rank_ > unrolled_to_component_indices(const unsigned int i)
constexpr Tensor & operator=(const Number &d) &&=delete
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) &
constexpr Tensor & operator+=(const Tensor< rank_, dim, OtherNumber > &)
constexpr DEAL_II_HOST_DEVICE_ALWAYS_INLINE Tensor< 0, dim, typename ProductType< Number, OtherNumber >::type > operator+(const Tensor< 0, dim, Number > &p, const Tensor< 0, dim, OtherNumber > &q)
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 Tensor< rank, dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator*(const Tensor< rank, dim, Number > &t, const OtherNumber &factor)
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 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 & operator=(const Tensor< rank_, dim, OtherNumber > &rhs)
#define DEAL_II_ALWAYS_INLINE
#define DEAL_II_DEPRECATED
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_CXX20_REQUIRES(condition)
#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)
Expression fabs(const Expression &x)
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)
constexpr void contract(T1 &result, const T2 &left, const T3 &right)
constexpr T1 contract3(const T2 &left, const T3 &middle, const T4 &right)
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_HOST_DEVICE
#define DEAL_II_HOST_DEVICE_ALWAYS_INLINE
typename internal::ProductTypeImpl< typename std::decay< T >::type, typename std::decay< U >::type >::type type
static constexpr DEAL_II_HOST_DEVICE_ALWAYS_INLINE const T & value(const T &t)
decltype(std::declval< T >() *std::declval< U >()) type
static real_type abs(const number &x)
static constexpr real_type abs_square(const number &x)
DEAL_II_HOST constexpr Number determinant(const SymmetricTensor< 2, dim, Number > &)
DEAL_II_HOST constexpr SymmetricTensor< 2, dim, Number > invert(const SymmetricTensor< 2, dim, Number > &)
DEAL_II_HOST constexpr SymmetricTensor< 4, dim, Number > outer_product(const SymmetricTensor< 2, dim, Number > &t1, const SymmetricTensor< 2, dim, Number > &t2)
DEAL_II_HOST constexpr Number trace(const SymmetricTensor< 2, dim2, Number > &)
Tensor< 2, dim, Number > project_onto_orthogonal_tensors(const Tensor< 2, dim, Number > &A)
std::ostream & operator<<(std::ostream &out, const Tensor< rank_, dim, Number > &p)
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)
constexpr ProductType< Other, Number >::type operator*(const Other &object, const Tensor< 0, dim, Number > &t)
Number l1_norm(const Tensor< 2, dim, Number > &t)