v0.8.23
dTensor0.hpp
Go to the documentation of this file.
1 /* Takes a derivative of a Tensor0<T*> yielding a Tensor1. */
2 
3 #pragma once
4 
5 namespace FTensor
6 {
7  template <class T, int Dim, char i> class dTensor0
8  {
9  const Tensor0<T *> &a;
12 
13  public:
14  typename promote<T, double>::V operator()(const int N) const
15  {
16  return (*(&a + d_ijk(N)) - *(&a - d_ijk(N))) * d_xyz(N) * 0.5;
17  }
18  dTensor0(const Tensor0<T *> &A, const Tensor1<int, Dim> &D_ijk,
19  const Tensor1<double, Dim> &D_xyz)
20  : a(A), d_ijk(D_ijk), d_xyz(D_xyz)
21  {}
22  };
23 
24  template <class T, int Dim, char i>
26  Dim, i>
27  d(const Tensor0<T *> &a, const Index<i, Dim> index,
28  const Tensor1<int, Dim> &d_ijk, const Tensor1<double, Dim> &d_xyz)
29  {
30  using Tensor_Expr = dTensor0<T, Dim, i>;
32  Tensor_Expr(a, d_ijk, d_xyz));
33  }
34 }
dTensor0(const Tensor0< T * > &A, const Tensor1< int, Dim > &D_ijk, const Tensor1< double, Dim > &D_xyz)
Definition: dTensor0.hpp:18
const Tensor1< int, Dim > & d_ijk
Definition: dTensor0.hpp:10
const Tensor0< T * > & a
Definition: dTensor0.hpp:9
Fully Antisymmetric Levi-Civita Tensor.
promote< T, double >::V operator()(const int N) const
Definition: dTensor0.hpp:14
const Tensor1_Expr< const dTensor0< T, Dim, i >, typename promote< T, double >::V, Dim, i > d(const Tensor0< T * > &a, const Index< i, Dim > index, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition: dTensor0.hpp:27
const Tensor1< double, Dim > & d_xyz
Definition: dTensor0.hpp:11
const int N
Definition: speed_test.cpp:3