CONTRACCIÓN SIMPLE Y CONTRACCIÓN DOBLE DE TENSORES

5 次查看(过去 30 天)
Hola, tengo estos datos:
D=[0,1,2]
A=[1 0 2;2 1 2;1 1 0]
A(:,:,2)=[2 1 1;0 1 2;0 1 1]
A(:,:,3)=[3 1 2;0 1 1;0 0 2]
B=[1 1 1]
C=[1 2 1; 1 2 0;0 1 0]
La Operación es D⋅(A⊗B)⋅C
Hice el producto tensorial de A,B, del cual tengo un tensor de 5 dimensiones.
K=tensorprod(A,B)
y Ahora quiero hacer la contracción simple de D.K, para obtener un tensor de 4D,(L)
Al resultado anterior, quiero hacer la Contracción simple L*C, Y obtener un tensor de 3D (F)
Intente con todas las variantes de tensorprod(a,b...) y no logro hacerlo.
De paso si sería molestia, si me podrían indicarme como hago la contracción doble de tensores de difenrte orden. Gracias!
  2 个评论
NAVNEET NAYAN
NAVNEET NAYAN 2023-9-12
Can you please put your question in English? I am not getting anything.
Dyuman Joshi
Dyuman Joshi 2023-9-12
Google translation of the problem description -
Hello, I have this data:
D=[0,1,2]
A=[1 0 2;2 1 2;1 1 0]
A(:,:,2)=[2 1 1;0 1 2;0 1 1]
A(:,:,3)=[3 1 2;0 1 1;0 0 2]
B=[1 1 1]
C=[1 2 1; 1 2 0;0 1 0]
The Operation is D⋅(A⊗B)⋅C
I made the tensor product of A,B, of which I have a 5-dimensional tensor.
K=tensorprod(A,B)
and Now I want to do the simple contraction of D.K, to obtain a 4D tensor,(L)
To the previous result, I want to do the Simple Contraction L*C, and obtain a 3D tensor (F)
I tried all the variants of tensorprod(a,b...) and I can't do it.
By the way, if it would be a bother, if you could tell me how I do the double contraction of tensioners of different orders. Thank you!

请先登录,再进行评论。

回答(1 个)

Vedant
Vedant 2023-9-12
Hi Ronald,
Este mensaje se envía en inglés con el fin de proporcionarle una respuesta de manera más rápida. Si prefiere mantener su correspondencia en español, por favor háganoslo saber y le enviaremos una traducción del mensaje.
To perform the operations you described using tensor contractions in MATLAB, you can use the `tensorprod` function from the Tensor Toolbox. Here's how you can calculate the tensors L and F based on the given data:
% Given data
D = [0, 1, 2];
A = cat(3, [1 0 2; 2 1 2; 1 1 0], [2 1 1; 0 1 2; 0 1 1], [3 1 2; 0 1 1; 0 0 2]);
B = [1 1 1];
C = [1 2 1; 1 2 0; 0 1 0];
% Perform tensor product of A and B
K = tensorprod(A, B);
% Perform contraction of D and K
L = tensorprod(D, K, [1]);
% Perform contraction of L and C
F = tensorprod(L, C, [2]);
% Display the resulting tensor F
disp(F);
In this code, the `cat` function is used to concatenate the three matrices in A along the third dimension, creating a 3D tensor. Then, the `tensorprod` function is used to calculate the tensor product of A and B, resulting in the 5D tensor K.
Next, the `tensorprod` function is used again to perform the contraction of D and K along the first dimension, resulting in the 4D tensor L.
Finally, another `tensorprod` operation is performed to contract L and C along the second dimension, resulting in the 3D tensor F.
To perform a double contraction of tensors of different orders, you can use the `tensorprod` function multiple times, specifying the appropriate dimensions to contract. For example, to perform a double contraction of tensors A and B along dimensions 2 and 3 respectively, you can use:
result = tensorprod(A, B, [2], [3]);
Make sure to adjust the dimensions according to the specific contraction you want to perform.
Note: The Tensor Toolbox is a third-party library for MATLAB that provides various functions for tensor operations. You may need to install and add the Tensor Toolbox to your MATLAB environment before using the `tensorprod` function.

产品


版本

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by