| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| { | ||
| size_t i, j; | ||
| for (i = 0; i < n-1; ++i) { | ||
| for (j = i+1; j < n; ++j) { | ||
| matrix[j] = numeric_limits<typ>::zero; | ||
| } | ||
| matrix += n; | ||
| } | ||
| } |
There was a problem hiding this comment.
I've got a question: I see that triu_matrix got renamed to tril_matrix. Was it incorrect?
AFAIU triu_matrix zeroes the upper part of the matrix instead of the lower (assuming row-major-order), or is it column-major implementation?
Sorry, something went wrong.
There was a problem hiding this comment.
This is just what git diff does - really what happened here is that I added triu_matrix - `tril_matrix continues to live below!
Sorry, something went wrong.
There was a problem hiding this comment.
Here's an implementation of triu_matrix in the current main branch:
numpy/numpy/linalg/umath_linalg.cpp
Lines 987 to 1001 in 7b42b52
And here's triu_matrix from your branch:
https://github.com/mhvk/numpy/blob/502bfb27968746f70155130b5fa9579e4d9a3a85/numpy/linalg/umath_linalg.cpp#L987-L1000
It looks like the implementation of triu_matrix changed here, right?
Sorry, something went wrong.
There was a problem hiding this comment.
What I mean: tril_matrix is the one that is new and triu_matrix is the existing one, and I wonder why the existing one changed implementation. I might be missing something.
Sorry, something went wrong.
There was a problem hiding this comment.
I think this is a typo in the main branch version. In def cholesky there's assert(uplo == 'L'); but later triu_matrix(params.A, params.N); is called.
So I think the change here is correct (assuming row-major order), but the release note should say that triu_matrix implementation changed and tril_matrix was added.
Sorry, something went wrong.
There was a problem hiding this comment.
Ah, yes, sorry! I did change the implementation, as indeed for a triangular-upper matrix, one should be zeroing the lower part. I now recall puzzling over this too, and changing the comment above to try to make clear what was actually done.
Sorry, something went wrong.
There was a problem hiding this comment.
Ok! I've got one more question: Here triu_matrix is zeroing upper triangular if one assumes the input is row-major order and lower triangular if one assumes the input column-major order, right?
Then maybe we could have just a docstring that explains why:
triu_matrix(typ *matrix, size_t n)
{
size_t i, j;
for (i = 0; i < n-1; ++i) {
for (j = i+1; j < n; ++j) {
matrix[j] = numeric_limits<typ>::zero;
}
matrix += n;
}
}looks like it zeroes upper triangular but the function's name says triu? Just a comment that matrix is column major (I think so).
WDYT?
Sorry, something went wrong.
There was a problem hiding this comment.
Yes, makes sense!
Sorry, something went wrong.
There was a problem hiding this comment.
OK, added the extra comment (really good to have indeed!)
Sorry, something went wrong.
There was a problem hiding this comment.
Apart from the one posted question, LGTM. (I think a release note can be added that says that a new ufunc was added)
Sorry, something went wrong.
|
Do we need a release note even if the ufunc is only used privately? (same for tril_matrix, which is only used inside other code). |
Sorry, something went wrong.
Ah right, I agree there's no need for a note. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
As I was in gufunc-land anyway, thought I might as well do the follow-up of #25388, of using the actual BLAS routine for upper-triangle cholesky decomposition (rather than .mT.conj(), which uses extra memory).
Fixes #25457