nmatrix icon indicating copy to clipboard operation
nmatrix copied to clipboard

#positive_definite?, #positive_semidefinite?, #rank_deficient?

Open translunar opened this issue 9 years ago • 10 comments

These methods, among others, would be useful for users wanting to check matrix properties.

translunar avatar Nov 30 '15 14:11 translunar

Hi! I'd like to take a shot at this. I think I can have something to show within a week or two.

johnmarinelli avatar Dec 04 '15 08:12 johnmarinelli

Wonderful! Thanks so much for getting involved. =D

translunar avatar Dec 04 '15 15:12 translunar

@mohawkjohn Hey! I'm afraid I don't understand what the second parameter of NMatrix::rank is supposed to do, but if I can use that function to calculate the rank of the matrix then rank_deficient? would be really easy to implement.

johnmarinelli avatar Dec 07 '15 19:12 johnmarinelli

#rank basically allows you to iterate along either rows or columns or through the depth of the tensor if it's more than 2-dimensional. So the first argument is row, column, or depth; and the second argument is which one of those. If you do rank(0,1), it gives you row 1. If you do rank(1,5), it gives you column 5. If you do rank(2,1), you get layer 1. Make sense?

translunar avatar Dec 07 '15 19:12 translunar

@mohawkjohn yep, perfect sense! I ended up using the gesvd to calculate rank. Since this needs the nmatrix/lapacke gem, I have a couple of questions -

  1. Is that okay? Or did you want it to be implemented without the lapacke dependency?
  2. How can I test the nmatrix functions that require lapacke? The tests that are already in place catch a NotImplementedException, even though I have the nmatrix-lapacke gem installed.

johnmarinelli avatar Dec 07 '15 21:12 johnmarinelli

You can run the tests with rake spec nmatrix_plugins=lapacke which will require the nmatrix/lapacke gem On Dec 7, 2015 4:16 PM, "John Marinelli" [email protected] wrote:

@mohawkjohn https://github.com/mohawkjohn yep, perfect sense! I ended up using the gesvd to calculate rank. Since this needs the nmatrix/lapacke gem, I have a couple of questions -

  1. Is that okay? Or did you want it to be implemented without the lapacke dependency?
  2. How can I test the nmatrix functions that require lapacke? The tests that are already in place give me a NotImplementedException, even though I have the nmatrix-lapacke gem installed.

— Reply to this email directly or view it on GitHub https://github.com/SciRuby/nmatrix/issues/411#issuecomment-162666139.

wlevine avatar Dec 07 '15 21:12 wlevine

Is using gesvd the most economical way to calculate rank?

translunar avatar Dec 07 '15 23:12 translunar

@mohawkjohn , well, I know there are a variety of ways to calculate whether or not a matrix is full rank or not; but I thought that SVD was the only way to calculate rank?

johnmarinelli avatar Dec 10 '15 02:12 johnmarinelli

Yup, you're right. Had to check my reference. =) Yes, lapacke sounds good.

translunar avatar Dec 10 '15 17:12 translunar

@mohawkjohn sounds good; i will continue to push on :) @wlevine thanks!

johnmarinelli avatar Dec 10 '15 17:12 johnmarinelli