Contraction
This generic function performs contraction of tensors.
The contraction
method contracts the multi-dimension arrays.
The general syntax is given below:
ans = CONTRACTION(a1, a2)
where,
a1
anda2
can be a Fortran array of rank 1, 2, 3, and 4.
Let's employ the following notation:
r0
rank-0 scalarr1
rank-1 vectorr2
rank-2 matrixr3
rank-3r4
rank-4
Then, the following table explains this operator.
a1 | a2 | ans |
---|---|---|
r1 | r1 | r0 |
r1 | r2 | r1 |
r1 | r3 | r2 |
r1 | r4 | r3 |
r2 | r1 | r1 |
r2 | r2 | r0 |
r2 | r3 | r1 |
r2 | r4 | r2 |
r3 | r1 | r2 |
r3 | r2 | r1 |
r3 | r3 | r0 |
r3 | r4 | r1 |
r4 | r1 | r3 |
r4 | r2 | r2 |
r4 | r3 | r1 |
r4 | r4 | r0 |
Interface 1
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE PURE FUNCTION Contraction(a1, a2) RESULT(ans)
REAL(DFP), INTENT(IN) :: a1(:, :, :, :)
REAL(DFP), INTENT(IN) :: a2(:)
REAL(DFP) :: ans(size(a1, 1), size(a1, 2), size(a1, 3))
END FUNCTION
END INTERFACE
Interface 2
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE PURE FUNCTION Contraction(a1, a2) RESULT(ans)
REAL(DFP), INTENT(IN) :: a1(:, :, :, :)
REAL(DFP), INTENT(IN) :: a2(:,:)
REAL(DFP) :: ans(size(a1, 1), size(a1, 2))
END FUNCTION
END INTERFACE
Interface 3
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE PURE FUNCTION Contraction(a1, a2) RESULT(ans)
REAL(DFP), INTENT(IN) :: a1(:, :, :, :)
REAL(DFP), INTENT(IN) :: a2(:, :, :)
REAL(DFP) :: ans(size(a1, 1))
END FUNCTION
END INTERFACE
Interface 4
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE PURE FUNCTION Contraction(a1, a2) RESULT(ans)
REAL(DFP), INTENT(IN) :: a1(:, :, :, :)
REAL(DFP), INTENT(IN) :: a2(:, :, :, :)
REAL(DFP) :: ans
END FUNCTION
END INTERFACE
Interface 5
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE PURE FUNCTION Contraction(a1, a2) RESULT(ans)
REAL(DFP), INTENT(IN) :: a1(:, :, :)
REAL(DFP), INTENT(IN) :: a2(:)
REAL(DFP) :: ans(size(a1, 1), size(a1, 2))
END FUNCTION
END INTERFACE
Interface 6
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE PURE FUNCTION Contraction(a1, a2) RESULT(ans)
REAL(DFP), INTENT(IN) :: a1(:, :, :)
REAL(DFP), INTENT(IN) :: a2(:, :)
REAL(DFP) :: ans(size(a1, 1))
END FUNCTION
END INTERFACE
Interface 7
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE PURE FUNCTION Contraction(a1, a2) RESULT(ans)
REAL(DFP), INTENT(IN) :: a1(:,:,:)
REAL(DFP), INTENT(IN) :: a2(:, :, :)
REAL(DFP) :: ans
END FUNCTION
END INTERFACE
Interface 8
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE PURE FUNCTION Contraction(a1, a2) RESULT(ans)
REAL(DFP), INTENT(IN) :: a1(:,:,:)
REAL(DFP), INTENT(IN) :: a2(:, :, :, :)
REAL(DFP) :: ans(size(a2,4))
END FUNCTION
END INTERFACE
Interface 9
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE PURE FUNCTION Contraction(a1, a2) RESULT(ans)
REAL(DFP), INTENT(IN) :: a1(:, :)
REAL(DFP), INTENT(IN) :: a2(:)
REAL(DFP) :: ans(size(a1, 1))
END FUNCTION
END INTERFACE
Interface 10
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE PURE FUNCTION Contraction(a1, a2) RESULT(ans)
REAL(DFP), INTENT(IN) :: a1(:, :)
REAL(DFP), INTENT(IN) :: a2(:, :)
REAL(DFP) :: ans
END FUNCTION
END INTERFACE
Interface 11
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE PURE FUNCTION Contraction(a1, a2) RESULT(ans)
REAL(DFP), INTENT(IN) :: a1(:,:)
REAL(DFP), INTENT(IN) :: a2(:, :, :)
REAL(DFP) :: ans(size(a2,3))
END FUNCTION
END INTERFACE
Interface 12
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE PURE FUNCTION Contraction(a1, a2) RESULT(ans)
REAL(DFP), INTENT(IN) :: a1(:,:)
REAL(DFP), INTENT(IN) :: a2(:, :, :, :)
REAL(DFP) :: ans(size(a2,3), size(a2,4))
END FUNCTION
END INTERFACE
Interface 13
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE PURE FUNCTION Contraction(a1, a2) RESULT(ans)
REAL(DFP), INTENT(IN) :: a1(:)
REAL(DFP), INTENT(IN) :: a2(:)
REAL(DFP) :: ans
END FUNCTION
END INTERFACE
Interface 14
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE PURE FUNCTION Contraction(a1, a2) RESULT(ans)
REAL(DFP), INTENT(IN) :: a1(:)
REAL(DFP), INTENT(IN) :: a2(:, :)
REAL(DFP) :: ans(size(a2,2))
END FUNCTION
END INTERFACE
Interface 15
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE PURE FUNCTION Contraction(a1, a2) RESULT(ans)
REAL(DFP), INTENT(IN) :: a1(:)
REAL(DFP), INTENT(IN) :: a2(:, :, :)
REAL(DFP) :: ans(size(a2,2), size(a2,3))
END FUNCTION
END INTERFACE
Interface 16
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE PURE FUNCTION Contraction(a1, a2) RESULT(ans)
REAL(DFP), INTENT(IN) :: a1(:)
REAL(DFP), INTENT(IN) :: a2(:, :, :, :)
REAL(DFP) :: ans(size(a2,2), size(a2,3), size(a2,4))
END FUNCTION
END INTERFACE