Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Braces, Square Brakets and Parenthesis are Mixed Up #16

Open
AlexanderNenninger opened this issue Jul 24, 2023 · 0 comments
Open

Braces, Square Brakets and Parenthesis are Mixed Up #16

AlexanderNenninger opened this issue Jul 24, 2023 · 0 comments

Comments

@AlexanderNenninger
Copy link

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);
end

Expected 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)
end

Comments, 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]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant