-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
ENH: Add wrapper for ?gejsv #11354
Comments
Here's the branch that I started with the tests for this routine. @mdhaber, you commented
Is this in respect to point number 4?
I assumed that reasonable behavior for malformed input matrix would be non zero info pointing towards the A parameter, and that non valid Additionally, I could only find the NAG page for the real version of this function. I didn't see the page / any examples for the complex version, so there is only one NAG test. |
No, those were separate ideas. I write this because according to the documentation:
What I meant by the first comment was
The second comment is different. I mean to try the routine with matrices:
(The rank of the matrix is |
Here's a little code that generates a random matrix, performs SVD, zeros some of the singular values in the SVD, creates a new matrix from the modified SVD, and checks that the rank of the new matrix is what we want it to be. It's just a way of creating a random matrix with a certain rank. There are simpler ways (e.g. zeroing some of the rows or setting rows to linear combinations of other rows) but in some sense the resulting matrices are not as "random" as this way.
|
I'm confused. Is that a separate question? Could you rephrase / expand? |
No problem. |
Sorry, let me clarify. It was a separate point.
In the past I was not completely sure what value Similarly, when testing for invalid job inputs, will info be the index of the invalid input argument? So, if joba="k" is the third argument, info would then be 3? For now I have left this as asserting that |
I would assume it would be -1 and -3 in those cases, respectively. For whatever reason, it does appear that it will report negative values for bad inputs. |
@mdhaber
To follow the model of the other tests, I think that I'll break up the ironically titled 'specific' tests into actual specific tests for each thing. In broad terms, what are your thoughts on the parametrization? This one's lambdas are more pretty since they line up nicer than the other ones, I think. |
I think the parametrization looks great. Breaking up the specific tests sounds good. I think I mistyped above when I wrote:
I meant "test with jobu='N' or jobv ='N'".
And let's add the tests for the eigenvalues all the time. Not:
I think you need to multiply by the ratio of the
Actually, don't make
Consequently, I suggest you define
and then for the tests:
If this looks confusing, I can explain when I see you. |
@Kai-Striega can you start a branch for this so @swallan can submit a PR? |
The stuff I wrote about |
See NumFOCUS Small Development Grant Proposal 2019 Round 3 proposal for background.
Add wrapper for ?gejsv.
Suggested signature:
Test idea:
A
.?gejsv
A
againstu @ SIGMA @ v.T
whereSIGMA
isnp.diag(work[1]/work[0]*sva[:N])
(I think - see second thought below)u.T @ u
against identity, e.g.np.testing.assert_allclose(u.T @ u, np.eye(u.shape[1]))
, with appropriate tolerancesv @ v.T
against identity.info==0
.iwork[0]==min(m,n)
iwork[1]==min(m,n)
Thoughts:
lwork
routines -DGEQP3
,DGEQRF
,DPOCON
,DGELQF
,DGEQRF
,DORMLQ
- in order to write an?dgejsv_lwork
. That is outside the scope of what I intended for this project, and I think that can be left to future work. For now, using the default value shown above is sufficient for any set of options.SVA
is confusing. In the description ofSVA
: "The singular values of A are (WORK(1)/WORK(2)) * SVA(1:N)". In the description ofWORK
: "SCALE = WORK(2) / WORK(1) is the scaling factor such that SCALE*SVA(1:N) are the computed singular values of A." These seem contradictory.iwork[0]
andiwork[1]
will now be the rank of the matrix. One way to generate such a matrix is to compute the SVD of a random matrix, zerok
of the singular values, and multiply the factors back together.job?
options. I don't think we need to test every combination. I suggest we just vary one thing at a time from the defaults.joba
, I don't think we need to verify that the different options are doing what they say they will; we should just check that the basic test above passes with every option.jobu
, I think we can test optionsU
andF
with the basic test above. I'll describe tests with optionsW
andN
below.jobv
, we can test optionV
with the basic test above. I don't want to dig into what optionJ
means; maybe just test that the code runs without error. I'll describe tests with optionsW
andN
below.jobr
, test with both optionsN
andR
normally.jobt
, test with optionN
. I'll describe a test with optionT
below.jobp
, test with optionsP
andN
normally.job?
option and confirming that the returnedinfo
indicates which argument is invalid.Test with
jobu='N'
andjobv ='N'
: since only the singular values are generated, we can't reproduce the original matrix from the factors or testu
orv
for orthogonality. Just check that the singular values are correct.Test with
jobt='T'
,jobu='W'
,jobv='V'
, andm==n
: do we need a special test for this? Originally I thought we might need to do something special, now I think we might be able to throw these options in with the regular tests above.We could get fancy and design special tests with numerically non-full-(column/row) rank matrices to confirm that this routine is doing the things it claims, but I don't think that's necessary.
Maybe make sure there is reasonable behavior when:
A
is not 2D?A
is 1 x 1A
is emptylwork
is zeroAlso: implement all examples from the NAG manual as additional tests.
The text was updated successfully, but these errors were encountered: