-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Added an 'elementary' function. #4573
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
Conversation
---------- | ||
N : int | ||
The size of the NxN array to be returned. Elementary matrices | ||
are be square. |
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.
"are square by definition", perhaps?
Im not sure whether this function should be added, but it will definitely need test cases as well if it is. |
|
||
""" | ||
m=eye(N, dtype=dtype) | ||
if j==None and t==None: |
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.
PEP8 wants spaces around operators. Also checking for None
should be done with is
.
Tests are still forthcoming. |
I haven't looked at this in detail, but yes, please don't use np.matrix in For now the best way to write matrix multiplication is just as a call to
|
So, I've added test coverage, switched to using np.dot instead of np.matrix, dropped the string formatting, and reworded the documentation. What do numpy devs think of this patch? Any other thoughts? |
hm elementary matrices may be useful for mathematical notation, but why would you want to use them computations? |
You might want to compose several linear transformations by multiplying their corresponding matrices together. |
hm it would still be very inefficient. But its probably useful for code clarity on operations where performance does not matter and could become more useful for other cases when numpy gains a smart matrix-dot chaining function. |
Other cases I can imagine it might be useful:
|
is the last 1 on the diagonal correct here? it isn't a multiplier anymore in this case. |
Needs rebase. |
performed. | ||
multiplier : scalar | ||
If set, the factor by which a given row will be multiplied. | ||
|
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.
Any reason not to document the dtype arg?
I was looking for a numpy |
@argriffing: Perhaps |
Is someone willing to champion this and shepherd it through the review process? If not perhaps we should close it. |
@mttpgn this seems to still requires some work or decision. Unless you comment/wish to continue, I would probably:
in a few weeks. Of course the PR can be reactivated at any time. (tag:PR-possibly-close) Otherwise, it probably mostly needs the decision that we actually want this in, including a ping to the mailing list. |
The new function creates an identity array that's had a single row operation performed on it. Quite useful when doing matrix multiplication. https://en.wikipedia.org/wiki/Elementary_matrix