-
-
Notifications
You must be signed in to change notification settings - Fork 77
transpose degree n matrices #1217
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
base: develop
Are you sure you want to change the base?
Conversation
Looks good, but we should bring the test suite in soon. There was one in my branch that probably works for a lot of this, but should be update. Although I'm guessing you have a number of problems that you've been testing with, it's more efficient to have the test suite. I can get it working with this branch and put in a PR to this if you'd like. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tested this at all yet, but I see some code changes that are needed. Some things that perlcritic pointed out.
86611b1
to
0702d52
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this generally looks good aside from the comments I made.
lib/Value/Matrix.pm
Outdated
Produce the degree (n-1) Matrix defined by a given index and value for that index. If n is 1, | ||
this produces a Real/Complex/Fraction. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could use some clarification as to what this really means. What do index
and value
mean in this context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to do better here. I will push and you can see. Imagine a 5x7x9 matrix. Entry positions are defined by three indices i,j,k. The first index, second index, and third index. So "index" here would be 1, 2, or 3. Say it is 3. Then a value for that index can be 1, 2, ..., or 9. Take a look and see if what I changed to is OK or can be improved upon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what you changed it to is better. What you said here really is what really worked for me though. Perhaps adding an example like that to the POD would better. Terminology with these "tensor" things can get confusing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I put something like that in the POD.
Take the transpose of a matrix. | ||
Apply this to a degree n Matrix, passing (m, k), and produce the degree (n-1) Matrix defined by | ||
taking all entries whose position has mth index with value k. For example if C<$M> is a 4x5x6 | ||
Matrix, then m can be 1, 2, or 3. If m is 2, then k can be 1, 2, 3, 4, or 5. C<$M-<gt>slice(2,3)> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code at the end of this can be made with C<<$M->slice(2,3)>>, a bit easier than the notation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That actually needs to be C<< $M->slice(2, 3) >>
. There must be spaces after <<
and before >>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point.
This builds on #1216 (which builds on #1215). If #1216 is updated following feedback, I will update here too. Once #1216 is merged, this diff should be more manageable.
In addition to changes from #1216, this has:
slice
method for a Matrix object. This produces a degree (n-1) Matrix from a degree n Matrix. You specify an index and a value for that index, and it produces the degree (n-1) Matrix that is thereby defined. This is currently only used as a helper for the update totranspose
. It is similar torow
andcolumn
methods, but more general. And always produces something of the next lower degree.This is the last of the updates I wanted to do before adding new methods for setting elements, removing columns and rows and a submatrix that @pstaabp has in #1076. We should make sure new tools work with degree n Matrix objects as we add them. Unless it is for sure only appropriate for degree 2 matrices.