Skip to content
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

cholesky accessor #81

Merged
merged 4 commits into from Aug 8, 2019
Merged

Conversation

rofinn
Copy link
Member

@rofinn rofinn commented Jul 10, 2018

Adds support for a cholesky accessor method where appropriate. Related to JuliaStats/Distributions.jl#731.

NOTE: Tests currently fail locally because of JuliaLinearAlgebra/Arpack.jl#12

src/testutils.jl Outdated Show resolved Hide resolved
@rofinn
Copy link
Member Author

rofinn commented Jul 16, 2018

Alright, the tests pass locally for me, but the PDSparseMat test is kinda gross now.

@rofinn rofinn changed the title WIP: cholesky accessor cholesky accessor Jul 17, 2018
src/pdmat.jl Outdated Show resolved Hide resolved
@nickrobinson251
Copy link

How do you feel about adding a method for PDiagMat to this PR too? :)

@oxinabox
Copy link
Contributor

oxinabox commented Jun 5, 2019

bump?

@rofinn
Copy link
Member Author

rofinn commented Jun 20, 2019

NOTE: I've added support for PDiagMat, but that technically isn't an accessor anymore.

@davidanthoff
Copy link

And another bump, this would be really nice to have.

@davidanthoff
Copy link

Actually, maybe also add it for ScalMat?

@rofinn
Copy link
Member Author

rofinn commented Aug 8, 2019

@davidanthoff Should that return the cholesky of a Diagonal from the ScalMat?

@davidanthoff
Copy link

davidanthoff commented Aug 8, 2019

I would think so? But @andreasnoack probably knows better.

Now that I looked a bit more carefully at the package, I'm actually slightly confused. Why isn't AbstractPDMat a subtype of AbstractMatrix? EDIT: But I think that question shouldn't stop this PR from being merged. I see that we already have an issue for this question: #40.

src/pdsparsemat.jl Outdated Show resolved Hide resolved
Co-Authored-By: Andreas Noack <andreas@noack.dk>
@andreasnoack andreasnoack merged commit 20897e8 into JuliaStats:master Aug 8, 2019
@rofinn
Copy link
Member Author

rofinn commented Aug 8, 2019

Thanks @andreasnoack and @davidanthoff!

@davidanthoff
Copy link

Thank you!

@davidanthoff
Copy link

Oh, and one more thing: @andreasnoack could you also tag a new release? Thanks :)

@johnczito
Copy link
Member

johnczito commented Aug 10, 2019

Should we say in the README that cholesky should be one of the necessary methods for customized subtypes? If not, are folks open to a generic fallback like this?

cholesky(A::AbstractPDMat) = cholesky(Matrix(A))

@davidanthoff
Copy link

The more I think about this, the more I think AbstractPDMat should just derive from AbstractMatrix, in which case I would assume everything would just work automatically. Accessor methods like the one in this PR here then would be performance improvements, but I would assume that the functionality would just be there (saying all of this under the assumption that there is a cholesky that works for any AbstractMatrix, which I haven't actually checked).

@andreasnoack
Copy link
Member

andreasnoack commented Aug 23, 2019

So, unfortunetely, this broke support for Julia builds with USE_GPL_LIBS=0 since PDSparseMat is only defined when SuiteSparse is available and is now used unconditionally on

const HAVE_CHOLMOD = isdefined(SuiteSparse, :CHOLMOD)
. @rofinn Would you be able to submit a fix? Eventually, it would also be good to test this with CI but it probably requires that we build Julia from source which I don't think is feasible.

@rofinn
Copy link
Member Author

rofinn commented Aug 24, 2019

I'm not sure I follow. How is it being used unconditionally now? Oh, is this because testutils is in src/ rather than test/?

@andreasnoack
Copy link
Member

The problem is that the struct PDSparseMat isn't defined when USE_GPL_LIBS=0 but it is referenced in

isa(C, Union{PDMat, PDSparseMat, PDiagMat}) && t_cholesky && pdtest_cholesky(C, Cmat, cmat_eq, verbose)

@ararslan
Copy link
Member

Potential solution:

const PDMatType = if HAVE_CHOLMOD
    Union{PDMat, PDiagMat, PDSparseMat}
else
    Union{PDMat, PDiagMat}
end

Then change the check to isa(C, PDMatType)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants