Compute Cholesky decomposition of Sparse Matrix in Python
I'm trying to implement Reinsch's Algorithm (pp 4).
Since the working matrices are sparse, I'm using scipy.sparse module, but as you can see, Reinsch's algorithm needs the Cholesky decomposition of a sparse matrix (let's call it my_matrix) in order to solve certain system, but I couldn't find anything related to this.
Of course, in the same algorithm I can solve the sparse system using, for instance scipy.sparse.linalg.spsolve, and then at the end of the algorithm use something like:
R = numpy.linalg.chol( my_matrix.A )
But, in my application my_matrix is usualy about 800*800, so the last one is very inneficient.
So, my question is, where I can find such decomposition?.
Thank's in advance.
python numpy scipy sparse-matrix
add a comment |
I'm trying to implement Reinsch's Algorithm (pp 4).
Since the working matrices are sparse, I'm using scipy.sparse module, but as you can see, Reinsch's algorithm needs the Cholesky decomposition of a sparse matrix (let's call it my_matrix) in order to solve certain system, but I couldn't find anything related to this.
Of course, in the same algorithm I can solve the sparse system using, for instance scipy.sparse.linalg.spsolve, and then at the end of the algorithm use something like:
R = numpy.linalg.chol( my_matrix.A )
But, in my application my_matrix is usualy about 800*800, so the last one is very inneficient.
So, my question is, where I can find such decomposition?.
Thank's in advance.
python numpy scipy sparse-matrix
google helps :) pythonhosted.org/scikits.sparse/cholmod.html
– cel
Aug 19 '16 at 17:25
I'm aware of scykit.sparse, but: This is a home for sparse matrix code in Python that plays well with scipy.sparse, but that is somehow unsuitable for inclusion in scipy proper. Usually this will be because it is released under the GPL Also, I can't install it for some reason.
– Angel Pérez
Aug 19 '16 at 17:31
1
Do you explicitly require the Cholesky decomposition? Or other decomposition (such as LU) would also work for you? If so, scipy has nice bindings to SuperLU.
– Imanol Luengo
Aug 19 '16 at 17:55
Probably the OP doesn't solved his problem by now but for others who come across this question: the scikit-sparse package can be easily installed with pip. pypi.org/project/scikit-sparse
– marcin_j
May 30 '18 at 17:54
add a comment |
I'm trying to implement Reinsch's Algorithm (pp 4).
Since the working matrices are sparse, I'm using scipy.sparse module, but as you can see, Reinsch's algorithm needs the Cholesky decomposition of a sparse matrix (let's call it my_matrix) in order to solve certain system, but I couldn't find anything related to this.
Of course, in the same algorithm I can solve the sparse system using, for instance scipy.sparse.linalg.spsolve, and then at the end of the algorithm use something like:
R = numpy.linalg.chol( my_matrix.A )
But, in my application my_matrix is usualy about 800*800, so the last one is very inneficient.
So, my question is, where I can find such decomposition?.
Thank's in advance.
python numpy scipy sparse-matrix
I'm trying to implement Reinsch's Algorithm (pp 4).
Since the working matrices are sparse, I'm using scipy.sparse module, but as you can see, Reinsch's algorithm needs the Cholesky decomposition of a sparse matrix (let's call it my_matrix) in order to solve certain system, but I couldn't find anything related to this.
Of course, in the same algorithm I can solve the sparse system using, for instance scipy.sparse.linalg.spsolve, and then at the end of the algorithm use something like:
R = numpy.linalg.chol( my_matrix.A )
But, in my application my_matrix is usualy about 800*800, so the last one is very inneficient.
So, my question is, where I can find such decomposition?.
Thank's in advance.
python numpy scipy sparse-matrix
python numpy scipy sparse-matrix
asked Aug 19 '16 at 17:15
Angel PérezAngel Pérez
163
163
google helps :) pythonhosted.org/scikits.sparse/cholmod.html
– cel
Aug 19 '16 at 17:25
I'm aware of scykit.sparse, but: This is a home for sparse matrix code in Python that plays well with scipy.sparse, but that is somehow unsuitable for inclusion in scipy proper. Usually this will be because it is released under the GPL Also, I can't install it for some reason.
– Angel Pérez
Aug 19 '16 at 17:31
1
Do you explicitly require the Cholesky decomposition? Or other decomposition (such as LU) would also work for you? If so, scipy has nice bindings to SuperLU.
– Imanol Luengo
Aug 19 '16 at 17:55
Probably the OP doesn't solved his problem by now but for others who come across this question: the scikit-sparse package can be easily installed with pip. pypi.org/project/scikit-sparse
– marcin_j
May 30 '18 at 17:54
add a comment |
google helps :) pythonhosted.org/scikits.sparse/cholmod.html
– cel
Aug 19 '16 at 17:25
I'm aware of scykit.sparse, but: This is a home for sparse matrix code in Python that plays well with scipy.sparse, but that is somehow unsuitable for inclusion in scipy proper. Usually this will be because it is released under the GPL Also, I can't install it for some reason.
– Angel Pérez
Aug 19 '16 at 17:31
1
Do you explicitly require the Cholesky decomposition? Or other decomposition (such as LU) would also work for you? If so, scipy has nice bindings to SuperLU.
– Imanol Luengo
Aug 19 '16 at 17:55
Probably the OP doesn't solved his problem by now but for others who come across this question: the scikit-sparse package can be easily installed with pip. pypi.org/project/scikit-sparse
– marcin_j
May 30 '18 at 17:54
google helps :) pythonhosted.org/scikits.sparse/cholmod.html
– cel
Aug 19 '16 at 17:25
google helps :) pythonhosted.org/scikits.sparse/cholmod.html
– cel
Aug 19 '16 at 17:25
I'm aware of scykit.sparse, but: This is a home for sparse matrix code in Python that plays well with scipy.sparse, but that is somehow unsuitable for inclusion in scipy proper. Usually this will be because it is released under the GPL Also, I can't install it for some reason.
– Angel Pérez
Aug 19 '16 at 17:31
I'm aware of scykit.sparse, but: This is a home for sparse matrix code in Python that plays well with scipy.sparse, but that is somehow unsuitable for inclusion in scipy proper. Usually this will be because it is released under the GPL Also, I can't install it for some reason.
– Angel Pérez
Aug 19 '16 at 17:31
1
1
Do you explicitly require the Cholesky decomposition? Or other decomposition (such as LU) would also work for you? If so, scipy has nice bindings to SuperLU.
– Imanol Luengo
Aug 19 '16 at 17:55
Do you explicitly require the Cholesky decomposition? Or other decomposition (such as LU) would also work for you? If so, scipy has nice bindings to SuperLU.
– Imanol Luengo
Aug 19 '16 at 17:55
Probably the OP doesn't solved his problem by now but for others who come across this question: the scikit-sparse package can be easily installed with pip. pypi.org/project/scikit-sparse
– marcin_j
May 30 '18 at 17:54
Probably the OP doesn't solved his problem by now but for others who come across this question: the scikit-sparse package can be easily installed with pip. pypi.org/project/scikit-sparse
– marcin_j
May 30 '18 at 17:54
add a comment |
1 Answer
1
active
oldest
votes
For fast decomposition, you can try,
from scikits.sparse.cholmod import cholesky
factor = cholesky(A.toarray())
x = factor(b)
A is your sparse, symmetric, positive-definite matrix.
Since your matrix is not "Huge!!" converting it into numpy array doesn't cause any problem.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f39044559%2fcompute-cholesky-decomposition-of-sparse-matrix-in-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
For fast decomposition, you can try,
from scikits.sparse.cholmod import cholesky
factor = cholesky(A.toarray())
x = factor(b)
A is your sparse, symmetric, positive-definite matrix.
Since your matrix is not "Huge!!" converting it into numpy array doesn't cause any problem.
add a comment |
For fast decomposition, you can try,
from scikits.sparse.cholmod import cholesky
factor = cholesky(A.toarray())
x = factor(b)
A is your sparse, symmetric, positive-definite matrix.
Since your matrix is not "Huge!!" converting it into numpy array doesn't cause any problem.
add a comment |
For fast decomposition, you can try,
from scikits.sparse.cholmod import cholesky
factor = cholesky(A.toarray())
x = factor(b)
A is your sparse, symmetric, positive-definite matrix.
Since your matrix is not "Huge!!" converting it into numpy array doesn't cause any problem.
For fast decomposition, you can try,
from scikits.sparse.cholmod import cholesky
factor = cholesky(A.toarray())
x = factor(b)
A is your sparse, symmetric, positive-definite matrix.
Since your matrix is not "Huge!!" converting it into numpy array doesn't cause any problem.
answered Jan 1 at 12:59
Prashant DomadiyaPrashant Domadiya
11
11
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f39044559%2fcompute-cholesky-decomposition-of-sparse-matrix-in-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
google helps :) pythonhosted.org/scikits.sparse/cholmod.html
– cel
Aug 19 '16 at 17:25
I'm aware of scykit.sparse, but: This is a home for sparse matrix code in Python that plays well with scipy.sparse, but that is somehow unsuitable for inclusion in scipy proper. Usually this will be because it is released under the GPL Also, I can't install it for some reason.
– Angel Pérez
Aug 19 '16 at 17:31
1
Do you explicitly require the Cholesky decomposition? Or other decomposition (such as LU) would also work for you? If so, scipy has nice bindings to SuperLU.
– Imanol Luengo
Aug 19 '16 at 17:55
Probably the OP doesn't solved his problem by now but for others who come across this question: the scikit-sparse package can be easily installed with pip. pypi.org/project/scikit-sparse
– marcin_j
May 30 '18 at 17:54