I am Charmie

メモとログ

Sympyまとめ (N-dim array)

Sympyのtensor用機能

  • We have two tensors $latex A \in \mathbb{R}^{I_1 \times \ldots \times I_N}$ and $latex B \in \mathbb{R}^{J_1 \times \ldots \times J_N}$.
  • An element is specified by $latex A(i_1, \ldots, i_N)$, where $latex 1 \leq i_k \leq I_k, k = 1, \ldots, N$ and $latex B(j_1, \ldots, j_M)$, where $latex 1 \leq j_k \leq J_k, k = 1, \ldots, M$.

[code lang="python"] from sympy.tensor.array import Array A = Array(...) B = Array(...) [/code]

  1. Tensor product Tensor product combines two tensors. The result tensor C is (N+M)-d array. $latex C = A \otimes B$ $latex C(i_1, \ldots, i_N, j_1, \ldots, j_M) = A(i_1, \ldots, i_N)B(j_1, \ldots, j_M)$ [code lang="python"] from sympy.tensor.array import tensorproduct C = tensorproduct(A, B) [/code]