v0.14.0
Tensor2_and_Tensor1.hpp
Go to the documentation of this file.
1 /* Multiply a Tensor1 and a Tensor2 together but don't contract, yielding a
2  Tensor2. */
3 
4 /* A(i,j) & B(i) -> Tensor2 */
5 
6 #pragma once
7 
8 namespace FTensor
9 {
10  // Base Template
11  template <class A, class B, class T, class U, int Dim0_0, int Dim1_0,
12  int Dim0_1, char i0, char j0, char i1>
14  {};
15 
16  /* A(i,j) & B(i) -> Tensor2 */
17 
18  template <class A, class B, class T, class U, int Dim0, int Dim1, char i,
19  char j>
20  class Tensor2_and_Tensor1<A, B, T, U, Dim0, Dim1, Dim0, i, j, i>
21  {
24 
25  public:
26  typename promote<T, U>::V operator()(const int N1, const int N2) const
27  {
28  return iterA(N1, N2) * iterB(N1);
29  }
30 
33  : iterA(a), iterB(b)
34  {}
35  };
36 
37  /* A(i,j) & B(j) -> Tensor2 */
38 
39  template <class A, class B, class T, class U, int Dim0, int Dim1, char i,
40  char j>
41  class Tensor2_and_Tensor1<A, B, T, U, Dim0, Dim1, Dim1, i, j, j>
42  {
45 
46  public:
47  typename promote<T, U>::V operator()(const int N1, const int N2) const
48  {
49  return iterA(N1, N2) * iterB(N2);
50  }
51 
54  : iterA(a), iterB(b)
55  {}
56  };
57 
58  /* A(i,j) & B(i/j) -> Tensor2 */
59 
60  template <class A, class B, class T, class U, int Dim0_0, int Dim1_0,
61  int Dim0_1, char i0, char j0, char i1>
64  {
65  using TensorExpr
67  static_assert(
68  !std::is_empty<TensorExpr>::value,
69  "Indexes or Dimensions are not compatible with the & operator");
71  i0, j0>(TensorExpr(a, b));
72  }
73 
74  /* B(i/j) & A(i,j) -> Tensor2 */
75 
76  // TODO=> We are not respecting operation order, in the really odd case
77  // someone uses this operation with non
78  // TODO=> commutable T or U. Any ideas on how should we handel this.
79 
80  template <class A, class B, class T, class U, int Dim0_0, int Dim1_0,
81  int Dim0_1, char i0, char j0, char i1>
84  {
85  using TensorExpr
88  i0, j0>(TensorExpr(a, b));
89  }
90 }
FTensor
JSON compatible output.
Definition: Christof_constructor.hpp:6
FTensor::Tensor2_and_Tensor1< A, B, T, U, Dim0, Dim1, Dim0, i, j, i >::iterB
const Tensor1_Expr< B, U, Dim0, i > iterB
Definition: Tensor2_and_Tensor1.hpp:23
FTensor::Tensor2_and_Tensor1< A, B, T, U, Dim0, Dim1, Dim0, i, j, i >::iterA
const Tensor2_Expr< A, T, Dim0, Dim1, i, j > iterA
Definition: Tensor2_and_Tensor1.hpp:22
FTensor::Tensor2_Expr
Definition: Tensor2_Expr.hpp:26
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
FTensor::Tensor2_and_Tensor1< A, B, T, U, Dim0, Dim1, Dim1, i, j, j >::iterA
const Tensor2_Expr< A, T, Dim0, Dim1, i, j > iterA
Definition: Tensor2_and_Tensor1.hpp:43
FTensor::Tensor1_Expr< B, U, Dim0, i >
a
constexpr double a
Definition: approx_sphere.cpp:30
FTensor::operator&
Ddg_Expr< Ddg_and_Tensor2_symmetric< A, B, T, U, Dim01_0, Dim23_0, Dim_1, i0, j0, k0, l0, i1, j1 >, typename promote< T, U >::V, Dim01_0, Dim23_0, i0, j0, k0, l0 > operator&(const Ddg_Expr< A, T, Dim01_0, Dim23_0, i0, j0, k0, l0 > &a, const Tensor2_symmetric_Expr< B, U, Dim_1, i1, j1 > &b)
Definition: Ddg_and_Tensor2_symmetric.hpp:69
FTensor::promote::V
T1 V
Definition: promote.hpp:17
FTensor::Tensor2_and_Tensor1
Definition: Tensor2_and_Tensor1.hpp:13
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Tensor2_and_Tensor1< A, B, T, U, Dim0, Dim1, Dim0, i, j, i >::operator()
promote< T, U >::V operator()(const int N1, const int N2) const
Definition: Tensor2_and_Tensor1.hpp:26
FTensor::Tensor2_and_Tensor1< A, B, T, U, Dim0, Dim1, Dim1, i, j, j >::Tensor2_and_Tensor1
Tensor2_and_Tensor1(const Tensor2_Expr< A, T, Dim0, Dim1, i, j > &a, const Tensor1_Expr< B, U, Dim1, j > &b)
Definition: Tensor2_and_Tensor1.hpp:52
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
FTensor::Tensor2_and_Tensor1< A, B, T, U, Dim0, Dim1, Dim1, i, j, j >::operator()
promote< T, U >::V operator()(const int N1, const int N2) const
Definition: Tensor2_and_Tensor1.hpp:47
EshelbianPlasticity::U
@ U
Definition: EshelbianContact.cpp:197
FTensor::Tensor2_and_Tensor1< A, B, T, U, Dim0, Dim1, Dim1, i, j, j >::iterB
const Tensor1_Expr< B, U, Dim1, j > iterB
Definition: Tensor2_and_Tensor1.hpp:44
FTensor::Tensor2_and_Tensor1< A, B, T, U, Dim0, Dim1, Dim0, i, j, i >::Tensor2_and_Tensor1
Tensor2_and_Tensor1(const Tensor2_Expr< A, T, Dim0, Dim1, i, j > &a, const Tensor1_Expr< B, U, Dim0, i > &b)
Definition: Tensor2_and_Tensor1.hpp:31