Skip to content

Commit

Permalink
@sym/private/mat_rclist_access.m: Test Array-compatible code.
Browse files Browse the repository at this point in the history
See gnu-octave#1194 for more information.

* inst/@sym/private/mat_rclist_access.m: Test it.
  • Loading branch information
Alex Vong authored and Alex Vong committed Aug 29, 2022
1 parent b618e5f commit 53059ac
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions inst/@sym/private/mat_rclist_access.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
%% Copyright (C) 2014, 2016, 2019, 2022 Colin B. Macdonald
%% Copyright (C) 2022 Alex Vong
%%
%% This file is part of OctSymPy.
%%
Expand Down Expand Up @@ -32,15 +33,12 @@
error('this routine is for a list of rows and cols');
end

cmd = { '(A, rr, cc) = _ins'
'if A is None or not A.is_Matrix:'
' A = sp.Matrix([A])'
'n = len(rr)'
'M = [[0] for i in range(n)]'
'for i in range(0, n):'
' M[i][0] = A[rr[i],cc[i]]'
'M = sp.Matrix(M)'
'return M,' };
cmd = {'dbg_no_array = True'
'(A, rr, cc) = _ins'
'AA = A.tolist() if isinstance(A, (MatrixBase, NDimArray)) else [[A]]'
'MM = [[AA[i][j]] for i, j in zip(rr, cc)]'
'M = make_matrix_or_array(MM)'
'return M,'};

rr = num2cell(int32(r-1));
cc = num2cell(int32(c-1));
Expand Down

0 comments on commit 53059ac

Please sign in to comment.