Skip to content

Commit

Permalink
Port helpers from list-of-lists to flat+shape
Browse files Browse the repository at this point in the history
Related to #1236.  I don't see a problem with the list-of-lists
approach, but these are the only routine using it so we can delete some
code if we port them to flat + shape.
  • Loading branch information
cbm755 committed Nov 12, 2024
1 parent 90af895 commit c9252ee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions inst/@sym/private/mat_rclist_access.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@

cmd = {'(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_2d_sym(MM)'
'return M,'};
'M = [AA[i][j] for i, j in zip(rr, cc)]'
'return _make_2d_sym(M, shape=(len(rr), 1)),'
};

rr = num2cell(int32(r-1));
cc = num2cell(int32(c-1));
Expand Down
2 changes: 1 addition & 1 deletion inst/@sym/private/mat_rclist_asgn.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
% Easy trick to copy A into larger matrix AA:
% AA = sp.Matrix.zeros(n, m)
% AA[0, 0] = A
% Also usefil: .copyin_matrix
% Also useful: .copyin_matrix

cmd = {'(A, rr, cc, b) = _ins'
'assert A == [] or not isinstance(A, list), "unexpectedly non-empty list: report bug!"'
Expand Down

0 comments on commit c9252ee

Please sign in to comment.