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

[WIP] Add 2D sym functions and use them. #1235

Open
wants to merge 43 commits into
base: Array_not_Matrix
Choose a base branch
from

Conversation

alexvong243f
Copy link
Collaborator

@alexvong243f alexvong243f commented Sep 7, 2022

We add 2D sym functions to abstract over the idea of 2D sym so that we
can choose to represent non-Matrix 2D sym to be something other than
an Array in the future. For example, we could use TableForm.

This is incomplete. More functions need to use these 2D sym
functions. Not sure if this is needed anymore as TableForm was shown
to be lacking various features such as indexing and taking
transpose. No other candidates are being considered at the moment.

This PR is introduced to avoid these changes to be forgotten. We can
close it later if this is definitely not needed or it bit rots.

cbm755 and others added 30 commits August 29, 2022 05:43
It has mostly the same semantics as Matrix but can contain more general
things.  There might be some issues about different shapes of empties
though...  WIP on a fix for gnu-octave#1052.
Fixes gnu-octave#1211.

* inst/private/python_header.py: Add it.
* inst/private/python_ipc_native.m: Add it.
See gnu-octave#1194 for more information.

* inst/@sym/private/mat_rclist_access.m: Test it.
See gnu-octave#1194 for more information.

* inst/@sym/private/mat_rclist_asgn.m: Test it.
* inst/@sym/{horzcat,vertcat}.m: Fix them.
* inst/@sym/vertcat.m: Implement it.
This is a prerequisite for making @sym/horzcat Array-compatible.

Partially fixes <gnu-octave#1215>.

* inst/@sym/transpose.m: Implement it.
* inst/@sym/private/mat_rclist_{access,asgn}.m: Remove them.
The function is now compatible with non-Matrix 2D sym (e.g. Array,
TableForm). Also, it now outputs empty matrices in the same way as
upstream Octave (fixes gnu-octave#1218).

* inst/@sym/repmat.m: Re-implement it and add tests accordingly.
Array linear indexing is not the same as Matrix linear indexing.
Fixes gnu-octave#1222.
This routine is supposed to return a logical Octave array.  Do linear
indexing on the flattened tolist output which will work on both Array
and Matrix.  Fixes gnu-octave#1221.
In fact it is failing elsewhere but the point of *this* test is to
change the orientation of a vector.
...with 'inst/private/python_header.py'.

Follow-up to 56bd719.

* inst/private/python_ipc_native.m: Disable it.
uniop_bool_helper and friends: Array support
This was broken with syntax errors since 2016...  Apply fix for Array
but leave a comment that this is unused and untested.  It is referred to
in isprime but commented out.
Alex Vong and others added 9 commits September 6, 2022 20:49
Follow-up to d3b1547.

* inst/@sym/vertcat.m: Use it.
* inst/@sym/private/mat_rclist_asgn.m: Use it.
Follow-up to 136184d.

* inst/@sym/transpose.m: Use it.
We did not run into issues in the past because many sympy functions
return a mutable matrix. However, 'transpose' used in
c9f6f0f returns an immutable
matrix. This change should avoid similar problems in the future.

Follow-up to c9f6f0f.

* inst/@sym/private/mat_replace.m: Make it mutable.
* inst/private/{python_header.py,python_ipc_native.m}: Generalise
function 'make_matrix_or_array', use sympy function 'flatten' in
'make_matrix_or_array'.
Instead of doing it ourselves, prepare a list of lists and call the
centralized helper function.
@cbm755
Copy link
Collaborator

cbm755 commented Sep 13, 2022

I force-pushed this onto top of the latest Array_not_Matrix

Alex Vong added 2 commits September 12, 2022 22:13
Generalises 'make_matrix_or_array' so that we can choose to represent
non-Matrix 2D sym to be something other than an Array in the
future. For example, we could use TableForm.

* inst/private/{python_header.py,python_ipc_native.m}: Rename function
'make_matrix_or_array' -> 'make_2d_sym', variable 'dbg_no_array' ->
'dbg_matrix_only' and adjust accordingly.
* inst/@sym/private/mat_rclist_{access,asgn}.m: Adjust accordingly.
* inst/@sym/vertcat.m: Adjust accordingly.
Add more 2D sym functions to abstract over the idea of 2D sym so that
we can choose to represent non-Matrix 2D sym to be something other
than an Array in the future. For example, we could use TableForm.

WIP: This is incomplete. More functions need to use these 2D sym
functions. Not sure if this is needed anymore as TableForm was shown
to be lacking various features such as indexing and taking
transpose. No other candidates are being considered at the moment.

* inst/private/{python_header.py,python_ipc_native.m}: Add new 2D sym
functions 'is_2d_sym', 'is_matrix', 'is_non_matrix_2d_sym',
'list_from_2d_sym' and 'shape_of_2d_sym'.
* inst/@sym/private/mat_rclist_{access,asgn}.m: Use them.
* inst/@sym/{transpose.m,vertcat.m}: Use them.
@cbm755
Copy link
Collaborator

cbm755 commented Sep 13, 2022

I cherry-picked a one of the commits out of here into #1194.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants