-----------------------------------------------------------------------------
-- |
-- Module      :  Math.Tensor.Examples.Gravity.Schwarzschild
-- Copyright   :  (c) 2019 Tobias Reinhart and Nils Alex
-- License     :  MIT
-- Maintainer  :  tobi.reinhart@fau.de, nils.alex@fau.de
--
--
-- This module provides the metric, inverse metric, Christoffel symbol, Ricci tensor and Einstein tensor for the Schwarzschild spacetime as an
-- example for tensor sections and partial derivatives thereof.
--
-----------------------------------------------------------------------------

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}

module Math.Tensor.Examples.Gravity.Schwarzschild (
schwarzschild,
schwarzschild',
christoffel,
ricci,
einstein
)
where

import Math.Tensor

import Numeric.AD.Internal.Forward (Forward(..))

-- | Schwarzschild metric \( g = (1-\frac{r_\text{s}}{r})\,\mathrm dt\otimes\mathrm dt - \frac{1}{1-\frac{r_\text{s}}{r}}\,\mathrm dr\otimes \mathrm dr - r^2\,\mathrm d\theta\otimes \mathrm d\theta - r^2\sin^2\theta\,\mathrm d\phi\otimes \mathrm d\phi \).

schwarzschild :: Floating a => a -> STTens 0 2 (CFun [a] a)
schwarzschild :: a -> STTens 0 2 (CFun [a] a)
schwarzschild a
rs = [(IndTuple2 0 2 Ind3, CFun [a] a)] -> STTens 0 2 (CFun [a] a)
forall k1 v (n1 :: Nat) (n2 :: Nat).
(TIndex k1, TAdd v) =>
[(IndTuple2 n1 n2 k1, v)] -> AbsTensor2 n1 n2 k1 v
fromListT2
    [
      ((IndList 0 Ind3
forall a. IndList 0 a
Empty, Int -> Ind3
Ind3 Int
0 Ind3 -> IndList (2 - 1) Ind3 -> IndList 2 Ind3
forall a (n :: Nat). a -> IndList (n - 1) a -> IndList n a
`Append` Ind3 -> IndList 1 Ind3
forall a. a -> IndList 1 a
singletonInd (Int -> Ind3
Ind3 Int
0)), ([a] -> a) -> CFun [a] a
forall a b. (a -> b) -> CFun a b
CFun (([a] -> a) -> CFun [a] a) -> ([a] -> a) -> CFun [a] a
forall a b. (a -> b) -> a -> b
$ \(a
_:a
r:[a]
_) -> a -> a
r' a
r ),
      ((IndList 0 Ind3
forall a. IndList 0 a
Empty, Int -> Ind3
Ind3 Int
1 Ind3 -> IndList (2 - 1) Ind3 -> IndList 2 Ind3
forall a (n :: Nat). a -> IndList (n - 1) a -> IndList n a
`Append` Ind3 -> IndList 1 Ind3
forall a. a -> IndList 1 a
singletonInd (Int -> Ind3
Ind3 Int
1)), ([a] -> a) -> CFun [a] a
forall a b. (a -> b) -> CFun a b
CFun (([a] -> a) -> CFun [a] a) -> ([a] -> a) -> CFun [a] a
forall a b. (a -> b) -> a -> b
$ \(a
_:a
r:[a]
_) -> -a
1a -> a -> a
forall a. Fractional a => a -> a -> a
/a -> a
r' a
r),
      ((IndList 0 Ind3
forall a. IndList 0 a
Empty, Int -> Ind3
Ind3 Int
2 Ind3 -> IndList (2 - 1) Ind3 -> IndList 2 Ind3
forall a (n :: Nat). a -> IndList (n - 1) a -> IndList n a
`Append` Ind3 -> IndList 1 Ind3
forall a. a -> IndList 1 a
singletonInd (Int -> Ind3
Ind3 Int
2)), ([a] -> a) -> CFun [a] a
forall a b. (a -> b) -> CFun a b
CFun (([a] -> a) -> CFun [a] a) -> ([a] -> a) -> CFun [a] a
forall a b. (a -> b) -> a -> b
$ \(a
_:a
r:[a]
_) -> -(a
ra -> a -> a
forall a. Floating a => a -> a -> a
**a
2)),
      ((IndList 0 Ind3
forall a. IndList 0 a
Empty, Int -> Ind3
Ind3 Int
3 Ind3 -> IndList (2 - 1) Ind3 -> IndList 2 Ind3
forall a (n :: Nat). a -> IndList (n - 1) a -> IndList n a
`Append` Ind3 -> IndList 1 Ind3
forall a. a -> IndList 1 a
singletonInd (Int -> Ind3
Ind3 Int
3)), ([a] -> a) -> CFun [a] a
forall a b. (a -> b) -> CFun a b
CFun (([a] -> a) -> CFun [a] a) -> ([a] -> a) -> CFun [a] a
forall a b. (a -> b) -> a -> b
$ \(a
_:a
r:a
theta:[a]
_) -> -(a
ra -> a -> a
forall a. Num a => a -> a -> a
*a -> a
forall a. Floating a => a -> a
sin a
theta)a -> a -> a
forall a. Floating a => a -> a -> a
**a
2)
    ]
  where
    r' :: a -> a
r' a
r = a
1 a -> a -> a
forall a. Num a => a -> a -> a
- a
rs a -> a -> a
forall a. Fractional a => a -> a -> a
/ a
r


-- | Inverse Schwarzschild metric \( g = \frac{1}{1-\frac{r_\text{s}}{r}}\,\partial_t \otimes \partial_t - (1-\frac{r_\text{s}}{r})\,\partial_r \otimes \partial_r - \frac{1}{r^2}\,\partial_\theta \otimes \partial_\theta - \frac{1}{r^2\sin^2\theta}\,\partial_\phi \otimes \partial_\phi \).

schwarzschild' :: Floating a => a -> STTens 2 0 (CFun [a] a)
schwarzschild' :: a -> STTens 2 0 (CFun [a] a)
schwarzschild' a
rs = [(IndTuple2 2 0 Ind3, CFun [a] a)] -> STTens 2 0 (CFun [a] a)
forall k1 v (n1 :: Nat) (n2 :: Nat).
(TIndex k1, TAdd v) =>
[(IndTuple2 n1 n2 k1, v)] -> AbsTensor2 n1 n2 k1 v
fromListT2
    [
      ((Int -> Ind3
Ind3 Int
0 Ind3 -> IndList (2 - 1) Ind3 -> IndList 2 Ind3
forall a (n :: Nat). a -> IndList (n - 1) a -> IndList n a
`Append` Ind3 -> IndList 1 Ind3
forall a. a -> IndList 1 a
singletonInd (Int -> Ind3
Ind3 Int
0), IndList 0 Ind3
forall a. IndList 0 a
Empty), ([a] -> a) -> CFun [a] a
forall a b. (a -> b) -> CFun a b
CFun (([a] -> a) -> CFun [a] a) -> ([a] -> a) -> CFun [a] a
forall a b. (a -> b) -> a -> b
$ \(a
_:a
r:[a]
_) -> a
1a -> a -> a
forall a. Fractional a => a -> a -> a
/a -> a
r' a
r),
      ((Int -> Ind3
Ind3 Int
1 Ind3 -> IndList (2 - 1) Ind3 -> IndList 2 Ind3
forall a (n :: Nat). a -> IndList (n - 1) a -> IndList n a
`Append` Ind3 -> IndList 1 Ind3
forall a. a -> IndList 1 a
singletonInd (Int -> Ind3
Ind3 Int
1), IndList 0 Ind3
forall a. IndList 0 a
Empty), ([a] -> a) -> CFun [a] a
forall a b. (a -> b) -> CFun a b
CFun (([a] -> a) -> CFun [a] a) -> ([a] -> a) -> CFun [a] a
forall a b. (a -> b) -> a -> b
$ \(a
_:a
r:[a]
_) -> - a -> a
r' a
r),
      ((Int -> Ind3
Ind3 Int
2 Ind3 -> IndList (2 - 1) Ind3 -> IndList 2 Ind3
forall a (n :: Nat). a -> IndList (n - 1) a -> IndList n a
`Append` Ind3 -> IndList 1 Ind3
forall a. a -> IndList 1 a
singletonInd (Int -> Ind3
Ind3 Int
2), IndList 0 Ind3
forall a. IndList 0 a
Empty), ([a] -> a) -> CFun [a] a
forall a b. (a -> b) -> CFun a b
CFun (([a] -> a) -> CFun [a] a) -> ([a] -> a) -> CFun [a] a
forall a b. (a -> b) -> a -> b
$ \(a
_:a
r:[a]
_) -> -a
1a -> a -> a
forall a. Fractional a => a -> a -> a
/(a
ra -> a -> a
forall a. Floating a => a -> a -> a
**a
2)),
      ((Int -> Ind3
Ind3 Int
3 Ind3 -> IndList (2 - 1) Ind3 -> IndList 2 Ind3
forall a (n :: Nat). a -> IndList (n - 1) a -> IndList n a
`Append` Ind3 -> IndList 1 Ind3
forall a. a -> IndList 1 a
singletonInd (Int -> Ind3
Ind3 Int
3), IndList 0 Ind3
forall a. IndList 0 a
Empty), ([a] -> a) -> CFun [a] a
forall a b. (a -> b) -> CFun a b
CFun (([a] -> a) -> CFun [a] a) -> ([a] -> a) -> CFun [a] a
forall a b. (a -> b) -> a -> b
$ \(a
_:a
r:a
theta:[a]
_) -> -a
1a -> a -> a
forall a. Fractional a => a -> a -> a
/(a
ra -> a -> a
forall a. Num a => a -> a -> a
*a -> a
forall a. Floating a => a -> a
sin a
theta)a -> a -> a
forall a. Floating a => a -> a -> a
**a
2)
    ]
  where
    r' :: a -> a
r' a
r = a
1 a -> a -> a
forall a. Num a => a -> a -> a
- a
rs a -> a -> a
forall a. Fractional a => a -> a -> a
/ a
r

half :: Fractional a => SField a
half :: SField a
half = a -> SField a
forall a. a -> SField a
SField (a -> SField a) -> a -> SField a
forall a b. (a -> b) -> a -> b
$ a
1a -> a -> a
forall a. Fractional a => a -> a -> a
/a
2

-- | Christoffel symbol of the Schwarzschild metric.

christoffel :: forall a.Floating a => a -> STTens 1 2 (CFun [a] a)
christoffel :: a -> STTens 1 2 (CFun [a] a)
christoffel a
rs = STTens 1 2 (CFun [a] a)
gamma
    where
        g :: STTens 0 2 (CFun [Forward a] (Forward a))
g = Forward a -> STTens 0 2 (CFun [Forward a] (Forward a))
forall a. Floating a => a -> STTens 0 2 (CFun [a] a)
schwarzschild (a -> Forward a
forall a. a -> Forward a
Lift a
rs)
        g' :: STTens 2 0 (CFun [a] a)
g' = a -> STTens 2 0 (CFun [a] a)
forall a. Floating a => a -> STTens 2 0 (CFun [a] a)
schwarzschild' a
rs :: STTens 2 0 (CFun [a] a)
        del_g :: STTens 0 3 (CFun [a] a)
del_g = STTens 0 2 (CFun [Forward a] (Forward a))
-> STTens 0 (2 + 1) (CFun [a] a)
forall a (n1 :: Nat) (n2 :: Nat).
Num a =>
STTens n1 n2 (CFun [Forward a] (Forward a))
-> STTens n1 (n2 + 1) (CFun [a] a)
partial STTens 0 2 (CFun [Forward a] (Forward a))
g :: STTens 0 3 (CFun [a] a)
        g'_del_g :: TProd (STTens 2 0 (CFun [a] a)) (STTens 0 3 (CFun [a] a))
g'_del_g = STTens 2 0 (CFun [a] a)
g' STTens 2 0 (CFun [a] a)
-> STTens 0 3 (CFun [a] a)
-> TProd (STTens 2 0 (CFun [a] a)) (STTens 0 3 (CFun [a] a))
forall k v v' (n :: Nat) (m :: Nat).
(TIndex k, Prod v v') =>
Tensor n k v
-> Tensor m k v' -> TProd (Tensor n k v) (Tensor m k v')
&* STTens 0 3 (CFun [a] a)
del_g
        t1 :: STTens 1 2 (CFun [a] a)
t1 = (Int, Int)
-> AbsTensor2 (1 + 1) (2 + 1) Ind3 (CFun [a] a)
-> STTens 1 2 (CFun [a] a)
forall k1 v (n1 :: Nat) (n2 :: Nat).
(TIndex k1, TAdd v) =>
(Int, Int)
-> AbsTensor2 (n1 + 1) (n2 + 1) k1 v -> AbsTensor2 n1 n2 k1 v
contrATens1 (Int
0, Int
0) Tensor 2 Ind3 (Tensor 3 Ind3 (CFun [a] a))
AbsTensor2 (1 + 1) (2 + 1) Ind3 (CFun [a] a)
g'_del_g
        t2 :: STTens 1 2 (CFun [a] a)
t2 = (Int, Int)
-> AbsTensor2 (1 + 1) (2 + 1) Ind3 (CFun [a] a)
-> STTens 1 2 (CFun [a] a)
forall k1 v (n1 :: Nat) (n2 :: Nat).
(TIndex k1, TAdd v) =>
(Int, Int)
-> AbsTensor2 (n1 + 1) (n2 + 1) k1 v -> AbsTensor2 n1 n2 k1 v
contrATens1 (Int
0, Int
1) Tensor 2 Ind3 (Tensor 3 Ind3 (CFun [a] a))
AbsTensor2 (1 + 1) (2 + 1) Ind3 (CFun [a] a)
g'_del_g
        t3 :: STTens 1 2 (CFun [a] a)
t3 = (Int, Int) -> STTens 1 2 (CFun [a] a) -> STTens 1 2 (CFun [a] a)
forall k1 v (n1 :: Nat) (n2 :: Nat).
(TIndex k1, TAdd v) =>
(Int, Int) -> AbsTensor2 n1 n2 k1 v -> AbsTensor2 n1 n2 k1 v
tensorTrans2 (Int
0, Int
1) STTens 1 2 (CFun [a] a)
t2
        s :: STTens 1 2 (CFun [a] a)
s = STTens 1 2 (CFun [a] a)
t2 STTens 1 2 (CFun [a] a)
-> STTens 1 2 (CFun [a] a) -> STTens 1 2 (CFun [a] a)
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> Tensor n k v -> Tensor n k v
&+ (STTens 1 2 (CFun [a] a)
t3 STTens 1 2 (CFun [a] a)
-> STTens 1 2 (CFun [a] a) -> STTens 1 2 (CFun [a] a)
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> Tensor n k v -> Tensor n k v
&- STTens 1 2 (CFun [a] a)
t1)
        h :: SField a
h = SField a
forall a. Fractional a => SField a
half :: SField a
        gamma :: Tensor 1 Ind3 (TProd (SField a) (Tensor 2 Ind3 (CFun [a] a)))
gamma = SField a
h SField a
-> STTens 1 2 (CFun [a] a)
-> Tensor 1 Ind3 (TProd (SField a) (Tensor 2 Ind3 (CFun [a] a)))
forall k s v (n :: Nat).
(TIndex k, Prod s v) =>
s -> Tensor n k v -> Tensor n k (TProd s v)
&. STTens 1 2 (CFun [a] a)
s

-- | Ricci tensor of the Schwarzschild metric.

ricci :: forall a.Floating a => a -> STTens 0 2 (CFun [a] a)
ricci :: a -> STTens 0 2 (CFun [a] a)
ricci a
rs = (STTens 0 2 (CFun [a] a)
term1 STTens 0 2 (CFun [a] a)
-> STTens 0 2 (CFun [a] a) -> STTens 0 2 (CFun [a] a)
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> Tensor n k v -> Tensor n k v
&- STTens 0 2 (CFun [a] a)
term2) STTens 0 2 (CFun [a] a)
-> STTens 0 2 (CFun [a] a) -> STTens 0 2 (CFun [a] a)
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> Tensor n k v -> Tensor n k v
&+ (STTens 0 2 (CFun [a] a)
term3 STTens 0 2 (CFun [a] a)
-> STTens 0 2 (CFun [a] a) -> STTens 0 2 (CFun [a] a)
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> Tensor n k v -> Tensor n k v
&- STTens 0 2 (CFun [a] a)
term4)
    where
        gamma1 :: STTens 1 2 (CFun [Forward a] (Forward a))
gamma1 = Forward a -> STTens 1 2 (CFun [Forward a] (Forward a))
forall a. Floating a => a -> STTens 1 2 (CFun [a] a)
christoffel (a -> Forward a
forall a. a -> Forward a
Lift a
rs)
        gamma2 :: STTens 1 2 (CFun [a] a)
gamma2 = a -> STTens 1 2 (CFun [a] a)
forall a. Floating a => a -> STTens 1 2 (CFun [a] a)
christoffel a
rs
        del_gamma :: STTens 1 3 (CFun [a] a)
del_gamma = STTens 1 2 (CFun [Forward a] (Forward a))
-> STTens 1 (2 + 1) (CFun [a] a)
forall a (n1 :: Nat) (n2 :: Nat).
Num a =>
STTens n1 n2 (CFun [Forward a] (Forward a))
-> STTens n1 (n2 + 1) (CFun [a] a)
partial STTens 1 2 (CFun [Forward a] (Forward a))
gamma1 :: STTens 1 3 (CFun [a] a)
        gamma_gamma :: STTens 1 3 (CFun [a] a)
gamma_gamma = (Int, Int)
-> AbsTensor2 (1 + 1) (3 + 1) Ind3 (CFun [a] a)
-> STTens 1 3 (CFun [a] a)
forall k1 v (n1 :: Nat) (n2 :: Nat).
(TIndex k1, TAdd v) =>
(Int, Int)
-> AbsTensor2 (n1 + 1) (n2 + 1) k1 v -> AbsTensor2 n1 n2 k1 v
contrATens1 (Int
1,Int
1) (AbsTensor2 (1 + 1) (3 + 1) Ind3 (CFun [a] a)
 -> STTens 1 3 (CFun [a] a))
-> AbsTensor2 (1 + 1) (3 + 1) Ind3 (CFun [a] a)
-> STTens 1 3 (CFun [a] a)
forall a b. (a -> b) -> a -> b
$ STTens 1 2 (CFun [a] a)
gamma2 STTens 1 2 (CFun [a] a)
-> STTens 1 2 (CFun [a] a)
-> TProd (STTens 1 2 (CFun [a] a)) (STTens 1 2 (CFun [a] a))
forall k v v' (n :: Nat) (m :: Nat).
(TIndex k, Prod v v') =>
Tensor n k v
-> Tensor m k v' -> TProd (Tensor n k v) (Tensor m k v')
&* STTens 1 2 (CFun [a] a)
gamma2 :: STTens 1 3 (CFun [a] a)
        term1 :: STTens 0 2 (CFun [a] a)
term1 = (Int, Int)
-> AbsTensor2 (0 + 1) (2 + 1) Ind3 (CFun [a] a)
-> STTens 0 2 (CFun [a] a)
forall k1 v (n1 :: Nat) (n2 :: Nat).
(TIndex k1, TAdd v) =>
(Int, Int)
-> AbsTensor2 (n1 + 1) (n2 + 1) k1 v -> AbsTensor2 n1 n2 k1 v
contrATens1 (Int
0,Int
0) STTens 1 3 (CFun [a] a)
AbsTensor2 (0 + 1) (2 + 1) Ind3 (CFun [a] a)
del_gamma
        term2 :: STTens 0 2 (CFun [a] a)
term2 = (Int, Int)
-> AbsTensor2 (0 + 1) (2 + 1) Ind3 (CFun [a] a)
-> STTens 0 2 (CFun [a] a)
forall k1 v (n1 :: Nat) (n2 :: Nat).
(TIndex k1, TAdd v) =>
(Int, Int)
-> AbsTensor2 (n1 + 1) (n2 + 1) k1 v -> AbsTensor2 n1 n2 k1 v
contrATens1 (Int
0,Int
1) STTens 1 3 (CFun [a] a)
AbsTensor2 (0 + 1) (2 + 1) Ind3 (CFun [a] a)
del_gamma
        term3 :: STTens 0 2 (CFun [a] a)
term3 = (Int, Int)
-> AbsTensor2 (0 + 1) (2 + 1) Ind3 (CFun [a] a)
-> STTens 0 2 (CFun [a] a)
forall k1 v (n1 :: Nat) (n2 :: Nat).
(TIndex k1, TAdd v) =>
(Int, Int)
-> AbsTensor2 (n1 + 1) (n2 + 1) k1 v -> AbsTensor2 n1 n2 k1 v
contrATens1 (Int
0,Int
0) STTens 1 3 (CFun [a] a)
AbsTensor2 (0 + 1) (2 + 1) Ind3 (CFun [a] a)
gamma_gamma
        term4 :: STTens 0 2 (CFun [a] a)
term4 = (Int, Int)
-> AbsTensor2 (0 + 1) (2 + 1) Ind3 (CFun [a] a)
-> STTens 0 2 (CFun [a] a)
forall k1 v (n1 :: Nat) (n2 :: Nat).
(TIndex k1, TAdd v) =>
(Int, Int)
-> AbsTensor2 (n1 + 1) (n2 + 1) k1 v -> AbsTensor2 n1 n2 k1 v
contrATens1 (Int
0,Int
1) STTens 1 3 (CFun [a] a)
AbsTensor2 (0 + 1) (2 + 1) Ind3 (CFun [a] a)
gamma_gamma

-- | Einstein tensor of the Schwarzschild metric.
--   The component functions evaluate to zero:
--
-- >>> let g = einstein 2
-- >>> g `evalSec` [1.1, 2.4, 1.7, 2.2]
-- ZeroTensor

einstein :: forall a.Floating a => a -> STTens 0 2 (CFun [a] a)
einstein :: a -> STTens 0 2 (CFun [a] a)
einstein a
rs = STTens 0 2 (CFun [a] a)
r_ab STTens 0 2 (CFun [a] a)
-> STTens 0 2 (CFun [a] a) -> STTens 0 2 (CFun [a] a)
forall k v (n :: Nat).
(TIndex k, TAdd v) =>
Tensor n k v -> Tensor n k v -> Tensor n k v
&- (SField a
h SField a
-> Tensor 0 Ind3 (Tensor 0 Ind3 (CFun [a] a))
-> Tensor 0 Ind3 (TProd (SField a) (Tensor 0 Ind3 (CFun [a] a)))
forall k s v (n :: Nat).
(TIndex k, Prod s v) =>
s -> Tensor n k v -> Tensor n k (TProd s v)
&. Tensor 0 Ind3 (Tensor 0 Ind3 (CFun [a] a))
r Tensor 0 Ind3 (Tensor 0 Ind3 (CFun [a] a))
-> STTens 0 2 (CFun [a] a)
-> TProd
     (Tensor 0 Ind3 (Tensor 0 Ind3 (CFun [a] a)))
     (STTens 0 2 (CFun [a] a))
forall k v v' (n :: Nat) (m :: Nat).
(TIndex k, Prod v v') =>
Tensor n k v
-> Tensor m k v' -> TProd (Tensor n k v) (Tensor m k v')
&* STTens 0 2 (CFun [a] a)
g)
    where
        r_ab :: STTens 0 2 (CFun [a] a)
r_ab = a -> STTens 0 2 (CFun [a] a)
forall a. Floating a => a -> STTens 0 2 (CFun [a] a)
ricci a
rs :: STTens 0 2 (CFun [a] a)
        g :: STTens 0 2 (CFun [a] a)
g = a -> STTens 0 2 (CFun [a] a)
forall a. Floating a => a -> STTens 0 2 (CFun [a] a)
schwarzschild a
rs :: STTens 0 2 (CFun [a] a)
        g' :: STTens 2 0 (CFun [a] a)
g' = a -> STTens 2 0 (CFun [a] a)
forall a. Floating a => a -> STTens 2 0 (CFun [a] a)
schwarzschild' a
rs :: STTens 2 0 (CFun [a] a)
        r :: Tensor 0 Ind3 (Tensor 0 Ind3 (CFun [a] a))
r = (Int, Int)
-> AbsTensor2 (0 + 1) (0 + 1) Ind3 (CFun [a] a)
-> Tensor 0 Ind3 (Tensor 0 Ind3 (CFun [a] a))
forall k1 v (n1 :: Nat) (n2 :: Nat).
(TIndex k1, TAdd v) =>
(Int, Int)
-> AbsTensor2 (n1 + 1) (n2 + 1) k1 v -> AbsTensor2 n1 n2 k1 v
contrATens1 (Int
0,Int
0) (AbsTensor2 (0 + 1) (0 + 1) Ind3 (CFun [a] a)
 -> Tensor 0 Ind3 (Tensor 0 Ind3 (CFun [a] a)))
-> AbsTensor2 (0 + 1) (0 + 1) Ind3 (CFun [a] a)
-> Tensor 0 Ind3 (Tensor 0 Ind3 (CFun [a] a))
forall a b. (a -> b) -> a -> b
$ (Int, Int)
-> AbsTensor2 (1 + 1) (1 + 1) Ind3 (CFun [a] a)
-> AbsTensor2 1 1 Ind3 (CFun [a] a)
forall k1 v (n1 :: Nat) (n2 :: Nat).
(TIndex k1, TAdd v) =>
(Int, Int)
-> AbsTensor2 (n1 + 1) (n2 + 1) k1 v -> AbsTensor2 n1 n2 k1 v
contrATens1 (Int
1,Int
1) (AbsTensor2 (1 + 1) (1 + 1) Ind3 (CFun [a] a)
 -> AbsTensor2 1 1 Ind3 (CFun [a] a))
-> AbsTensor2 (1 + 1) (1 + 1) Ind3 (CFun [a] a)
-> AbsTensor2 1 1 Ind3 (CFun [a] a)
forall a b. (a -> b) -> a -> b
$ STTens 2 0 (CFun [a] a)
g' STTens 2 0 (CFun [a] a)
-> STTens 0 2 (CFun [a] a)
-> TProd (STTens 2 0 (CFun [a] a)) (STTens 0 2 (CFun [a] a))
forall k v v' (n :: Nat) (m :: Nat).
(TIndex k, Prod v v') =>
Tensor n k v
-> Tensor m k v' -> TProd (Tensor n k v) (Tensor m k v')
&* STTens 0 2 (CFun [a] a)
r_ab
        h :: SField a
h = SField a
forall a. Fractional a => SField a
half :: SField a