-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
MATLAB input
The incorrectly translated MATLAB code. Please include any special steps to reproduce the failed translation, beyond copy/pasting the MATLAB input and clicking "translate."
function [y]=formtensor(y,mid_inv,d,ry,n)
% Merge mid_inv: y:=inv(L)*y*inv(U)
for i=1:d
y{i} = reshape(y{i}, ry(i), n(i)*ry(i+1));
y{i} = mid_inv{i,2}*y{i};
y{i} = reshape(y{i}, ry(i)*n(i), ry(i+1));
y{i} = y{i}*mid_inv{i+1,1};
y{i} = reshape(y{i}, ry(i), n(i), ry(i+1));
end;
y = cell2core(tt_tensor, y);
endExpected Julia output
The correct Julia translation (not what the translator outputs).
function formtensor(y,mid_inv,d,ry,n)
# Merge mid_inv: y:=inv(L)*y*inv(U)
for i=1:d
y[i] = reshape(y[i], ry[i], n[i]*ry[i+1])
y[i] = mid_inv[i,2]*y[i]
y[i] = reshape(y[i], ry[i]*n[i], ry[i+1])
y[i] = y[i]*mid_inv[i+1,1]
y[i] = reshape(y[i], ry[i], n[i], ry[i+1])
end
cell2core(tt_tensor, y)
endComments, suggestions, and other helpful details
Anything else that might be helpful. Thank you!
Incorrect code:
function formtensor(y,mid_inv,d,ry,n)
# Merge mid_inv: y:=inv(L)*y*inv(U)
for i=1:d
y[i] = reshape(y[i], ry[i], n[i]*ry[i+1])
y(i} = mid_inv[i,2)*y{i]
y[i] = reshape(y[i], ry[i]*n[i], ry[i+1])
y(i} = y[i]*mid_inv{i+1,1)
y[i] = reshape(y[i], ry[i], n[i], ry[i+1])
end
y = cell2core(tt_tensor,y]
return [y]
endMetadata
Metadata
Assignees
Labels
No labels