t3toolbox.backend.contractions.dMio_dNo_to_dMNi#

t3toolbox.backend.contractions.dMio_dNo_to_dMNi(dMio: t3toolbox.backend.common.NDArray, dNo: t3toolbox.backend.common.NDArray, use_jax: bool = False) t3toolbox.backend.common.NDArray#

Computes contraction dMio,dNo->dMNi.

N and M may be individual indices, groups of indices, or nonexistent.

Examples

Vectorize over both N and M:

>>> import numpy as np
>>> from t3toolbox.utils.contractions import dMio_dNo_to_dMNi
>>> dMio = np.random.randn(8, 5,6, 10,13)
>>> dNo = np.random.randn(8, 2,3,4, 13)
>>> result = dMio_dNo_to_dMNi(dMio, dNo)
>>> result2 = np.einsum('duvio,dxyzo->duvxyzi', dMio, dNo)
>>> print(result.shape == result2.shape)
True
>>> print(np.linalg.norm(result - result2))
0.0

Vectorize over N only

>>> import numpy as np
>>> from t3toolbox.utils.contractions import dMio_dNo_to_dMNi
>>> dMio = np.random.randn(8, 10,13)
>>> dNo = np.random.randn(8, 2,3,4, 13)
>>> result = dMio_dNo_to_dMNi(dMio, dNo)
>>> result2 = np.einsum('dio,dxyzo->dxyzi', dMio, dNo)
>>> print(result.shape == result2.shape)
True
>>> print(np.linalg.norm(result - result2))
0.0

Vectorize over both M only:

>>> import numpy as np
>>> from t3toolbox.utils.contractions import dMio_dNo_to_dMNi
>>> dMio = np.random.randn(8, 5,6, 10,13)
>>> dNo = np.random.randn(8, 13)
>>> result = dMio_dNo_to_dMNi(dMio, dNo)
>>> result2 = np.einsum('duvio,do->duvi', dMio, dNo)
>>> print(result.shape == result2.shape)
True
>>> print(np.linalg.norm(result - result2))
0.0

No vectorization:

>>> import numpy as np
>>> from t3toolbox.utils.contractions import dMio_dNo_to_dMNi
>>> dMio = np.random.randn(8, 10,13)
>>> dNo = np.random.randn(8, 13)
>>> result = dMio_dNo_to_dMNi(dMio, dNo)
>>> result2 = np.einsum('dio,do->di', dMio, dNo)
>>> print(result.shape == result2.shape)
True
>>> print(np.linalg.norm(result - result2))
0.0