ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 20 Jun 2019 00:15:36 +0200Inverting matrix after Cholesky decomposition does not finish for "large" dimensionhttps://ask.sagemath.org/question/46918/inverting-matrix-after-cholesky-decomposition-does-not-finish-for-large-dimension/I'm trying to invert the cholesky decomposition of a matrix. While this works for small a, for around a=~30, it no longer finishes.
From the _print_, I know that the problem is in the last line.
This seems a very odd behavior, as like matrix inversion would blow exponentially, which is not true, but even if it was it shouldn't go from taking 10s to finish to not finishing at all. Moreover, since the matrix N is triangular, shouldn't it even be faster to compute the inverse matrix?
I am very puzzled about this, sorry...
a = 30
M = random_matrix(ZZ, a, x = -a, y = a)
M = M.T * M
N = M.inverse().cholesky()
print "choleskied"
Ni = N.inverse()
Thanks for the help!Sat, 15 Jun 2019 17:28:27 +0200https://ask.sagemath.org/question/46918/inverting-matrix-after-cholesky-decomposition-does-not-finish-for-large-dimension/Answer by popoti9 for <p>I'm trying to invert the cholesky decomposition of a matrix. While this works for small a, for around a=~30, it no longer finishes.</p>
<p>From the _print_, I know that the problem is in the last line.</p>
<p>This seems a very odd behavior, as like matrix inversion would blow exponentially, which is not true, but even if it was it shouldn't go from taking 10s to finish to not finishing at all. Moreover, since the matrix N is triangular, shouldn't it even be faster to compute the inverse matrix?</p>
<p>I am very puzzled about this, sorry...</p>
<pre><code>a = 30
M = random_matrix(ZZ, a, x = -a, y = a)
M = M.T * M
N = M.inverse().cholesky()
print "choleskied"
Ni = N.inverse()
</code></pre>
<p>Thanks for the help!</p>
https://ask.sagemath.org/question/46918/inverting-matrix-after-cholesky-decomposition-does-not-finish-for-large-dimension/?answer=46949#post-id-46949So, I found the problem.
In fact,
`N.parent() == Full MatrixSpace of 30 by 30 dense matrices over Algebraic Real Field`
since this has infinite precision, the computation takes forever.
This is solved, and the computation is almost instant (as expected), by using finite precision, i.e.
`Ni = N.n().inverse()`
Maybe this'll help someone.
Cheers! `: )`
Thu, 20 Jun 2019 00:15:01 +0200https://ask.sagemath.org/question/46918/inverting-matrix-after-cholesky-decomposition-does-not-finish-for-large-dimension/?answer=46949#post-id-46949Comment by popoti9 for <p>So, I found the problem.</p>
<p>In fact,</p>
<p><code>N.parent() == Full MatrixSpace of 30 by 30 dense matrices over Algebraic Real Field</code></p>
<p>since this has infinite precision, the computation takes forever.</p>
<p>This is solved, and the computation is almost instant (as expected), by using finite precision, i.e.</p>
<p><code>Ni = N.n().inverse()</code></p>
<p>Maybe this'll help someone. </p>
<p>Cheers! <code>: )</code></p>
https://ask.sagemath.org/question/46918/inverting-matrix-after-cholesky-decomposition-does-not-finish-for-large-dimension/?comment=46950#post-id-46950I cannot accept my answer, unfortunately (not enough points)Thu, 20 Jun 2019 00:15:36 +0200https://ask.sagemath.org/question/46918/inverting-matrix-after-cholesky-decomposition-does-not-finish-for-large-dimension/?comment=46950#post-id-46950