Sympyまとめ (N-dim array)

Sympyのtensor用機能

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

1. Tensor product
Tensor product combines two tensors. The result tensor C is (N+M)-d array.
C = A \otimes B
C(i_1, \ldots, i_N, j_1, \ldots, j_M) = A(i_1, \ldots, i_N)B(j_1, \ldots, j_M)

from sympy.tensor.array import tensorproduct
C = tensorproduct(A, B)
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s