From 53059ac82043d4a472a997aab07072a1b34e91f3 Mon Sep 17 00:00:00 2001 From: Alex Vong Date: Mon, 22 Aug 2022 12:23:59 +0000 Subject: [PATCH] @sym/private/mat_rclist_access.m: Test Array-compatible code. See #1194 for more information. * inst/@sym/private/mat_rclist_access.m: Test it. --- inst/@sym/private/mat_rclist_access.m | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/inst/@sym/private/mat_rclist_access.m b/inst/@sym/private/mat_rclist_access.m index 46593030b..460ec99af 100644 --- a/inst/@sym/private/mat_rclist_access.m +++ b/inst/@sym/private/mat_rclist_access.m @@ -1,4 +1,5 @@ %% Copyright (C) 2014, 2016, 2019, 2022 Colin B. Macdonald +%% Copyright (C) 2022 Alex Vong %% %% This file is part of OctSymPy. %% @@ -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));