-
Notifications
You must be signed in to change notification settings - Fork 164
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
MatrixObj: basic operations for row/column reduction #3962
Comments
Invertible manipulation of rows/columns corresponds to multiplication with an invertible matrix from the left/right. So I would suggest that
while
The same applies to This will also cover many use-cases for noncommutative rings in a natural way :) |
That's an excellent point, I like the idea very much. (To support Mohamed's point, this way the operations are symmetric under transposition - a natural way to represent a column-major matrix is to store its transpose as a row-major matrix, or vice versa). But I wonder if we still should offer operations that perform "the other" transformation; i.e. have |
@AnnaKDS @wucas @danielrademacher Also see the issue about parametrized tests. We could try to make some for |
Also, I think we can collect the documentation for all these functions in a (new?) section |
A remark regarding performance: operations like Here's some naive benchmarking:
So to counteract this, we could use the same trick as for many other operations: let The only thing is: it's really annoying to have to do this. Which leads me back to the idea proposed in issue #955 by @ChrisJefferson ... hrm |
|
To be able to write all kinds of algorithms that work at least somewhat efficiently with proper MatrixObj implementations, we need to allow people to write code that avoids extracting and manipulating rows. That means adding a bunch of operating facilitating this. Perhaps we already have some of these, but I couldn't find them, and they are not mentioned in chapter 26 of the ref manual... The names are of course tentative, the functionality is what is important
(CC @mohamed-barakat @ThomasBreuer @user141)
MultMatrixRow( mat, row, scalar )
doesmat[row] :=mat[row] * scalar
;MultMatrixColumn( mat, col, scalar )
same for columnsto support non-commutative base domains, also need an operation which does
mat[row] :=scalar * mat[row]
and same for columns; unfortunately we can't just overload the same function, as a positive integer could denote both a scalar and a row/column index. PerhapsMultMarixRowLeft
andMultMarixRowRight
? And then haveMultMatrixRow
be a synonym forMultMatrixRowRight
(@mohamed-barakat suggestions welcome :-)AddMatrixRows(mat, dstrow, srcow, scalar
) doesmat[dstrow] := mat[dstrow] + mat[srcrow] * scalar
same for columns; and for scalars coming from the left (I think we assume that addition is commutative in too many places for it to make sense to allow variants there, too)
SwapMatrixRows(mat, row1, row2)
SwapMatrixColumns(mat, col1, col2)
We might want more (e.g. one could have
PermuteMatrixRows(mat, perm)
), but those listed above are an absolute minimum. If you can think of others, chime up.The text was updated successfully, but these errors were encountered: