Mercurial > hg > octave-nkf
annotate liboctave/numeric/sparse-base-chol.cc @ 18238:8f256148d82b
maint: Periodic merge of gui-release to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 07 Jan 2014 16:07:54 -0500 |
parents | d63878346099 |
children | afd6179d2616 |
rev | line source |
---|---|
5506 | 1 /* |
2 | |
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
16313
diff
changeset
|
3 Copyright (C) 2005-2013 David Bateman |
11523 | 4 Copyright (C) 1998-2005 Andy Adler |
7016 | 5 |
6 This file is part of Octave. | |
5506 | 7 |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
5506 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
5506 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
28 #include "sparse-base-chol.h" | |
29 #include "sparse-util.h" | |
30 #include "lo-error.h" | |
31 #include "oct-sparse.h" | |
32 #include "oct-spparms.h" | |
33 #include "quit.h" | |
5785 | 34 #include "MatrixType.h" |
5506 | 35 |
5511 | 36 #ifdef HAVE_CHOLMOD |
5506 | 37 // Can't use CHOLMOD_NAME(drop)(0.0, S, cm). It doesn't treat complex matrices |
38 template <class chol_type, class chol_elt, class p_type> | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
39 void |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
40 sparse_base_chol<chol_type, chol_elt, p_type>::sparse_base_chol_rep::drop_zeros |
5506 | 41 (const cholmod_sparse* S) |
42 { | |
43 chol_elt sik; | |
44 octave_idx_type *Sp, *Si; | |
45 chol_elt *Sx; | |
46 octave_idx_type pdest, k, ncol, p, pend; | |
47 | |
5518 | 48 if (! S) |
5506 | 49 return; |
50 | |
51 Sp = static_cast<octave_idx_type *>(S->p); | |
52 Si = static_cast<octave_idx_type *>(S->i); | |
53 Sx = static_cast<chol_elt *>(S->x); | |
54 pdest = 0; | |
55 ncol = S->ncol; | |
56 | |
57 for (k = 0; k < ncol; k++) | |
58 { | |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
59 p = Sp[k]; |
15020
560317fd5977
maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents:
15018
diff
changeset
|
60 pend = Sp[k+1]; |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
61 Sp[k] = pdest; |
5506 | 62 for (; p < pend; p++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
63 { |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
64 sik = Sx[p]; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
65 if (CHOLMOD_IS_NONZERO (sik)) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
66 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
67 if (p != pdest) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
68 { |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
69 Si[pdest] = Si[p]; |
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
70 Sx[pdest] = sik; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
71 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
72 pdest++; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
73 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
74 } |
5506 | 75 } |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
76 Sp[ncol] = pdest; |
5506 | 77 } |
5511 | 78 #endif |
5506 | 79 |
80 template <class chol_type, class chol_elt, class p_type> | |
81 octave_idx_type | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
82 sparse_base_chol<chol_type, chol_elt, p_type>::sparse_base_chol_rep::init |
15264
94cdf82d4a0c
don't overload meaning of info in Sparse Cholesky factorization functions
John W. Eaton <jwe@octave.org>
parents:
15185
diff
changeset
|
83 (const chol_type& a, bool natural, bool force) |
5506 | 84 { |
5648 | 85 volatile octave_idx_type info = 0; |
15264
94cdf82d4a0c
don't overload meaning of info in Sparse Cholesky factorization functions
John W. Eaton <jwe@octave.org>
parents:
15185
diff
changeset
|
86 |
5506 | 87 #ifdef HAVE_CHOLMOD |
88 octave_idx_type a_nr = a.rows (); | |
89 octave_idx_type a_nc = a.cols (); | |
90 | |
91 if (a_nr != a_nc) | |
92 { | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
93 (*current_liboctave_error_handler) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
94 ("SparseCHOL requires square matrix"); |
5506 | 95 return -1; |
96 } | |
97 | |
98 cholmod_common *cm = &Common; | |
99 | |
100 // Setup initial parameters | |
101 CHOLMOD_NAME(start) (cm); | |
5518 | 102 cm->prefer_zomplex = false; |
5506 | 103 |
5893 | 104 double spu = octave_sparse_params::get_key ("spumoni"); |
5506 | 105 if (spu == 0.) |
106 { | |
107 cm->print = -1; | |
5518 | 108 cm->print_function = 0; |
5506 | 109 } |
110 else | |
111 { | |
5760 | 112 cm->print = static_cast<int> (spu) + 2; |
5506 | 113 cm->print_function =&SparseCholPrint; |
114 } | |
115 | |
116 cm->error_handler = &SparseCholError; | |
117 cm->complex_divide = CHOLMOD_NAME(divcomplex); | |
118 cm->hypotenuse = CHOLMOD_NAME(hypot); | |
119 | |
5518 | 120 cm->final_asis = false; |
121 cm->final_super = false; | |
122 cm->final_ll = true; | |
123 cm->final_pack = true; | |
124 cm->final_monotonic = true; | |
125 cm->final_resymbol = false; | |
5506 | 126 |
127 cholmod_sparse A; | |
128 cholmod_sparse *ac = &A; | |
129 double dummy; | |
130 ac->nrow = a_nr; | |
131 ac->ncol = a_nc; | |
132 | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
133 ac->p = a.cidx (); |
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
134 ac->i = a.ridx (); |
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
135 ac->nzmax = a.nnz (); |
5518 | 136 ac->packed = true; |
137 ac->sorted = true; | |
138 ac->nz = 0; | |
16313
6aafe87a3144
use int64_t for idx type if --enable-64
John W. Eaton <jwe@octave.org>
parents:
15271
diff
changeset
|
139 #ifdef USE_64_BIT_IDX_T |
5506 | 140 ac->itype = CHOLMOD_LONG; |
141 #else | |
142 ac->itype = CHOLMOD_INT; | |
143 #endif | |
144 ac->dtype = CHOLMOD_DOUBLE; | |
145 ac->stype = 1; | |
146 #ifdef OCTAVE_CHOLMOD_TYPE | |
147 ac->xtype = OCTAVE_CHOLMOD_TYPE; | |
148 #else | |
149 ac->xtype = CHOLMOD_REAL; | |
150 #endif | |
151 | |
152 if (a_nr < 1) | |
153 ac->x = &dummy; | |
154 else | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
155 ac->x = a.data (); |
5506 | 156 |
157 // use natural ordering if no q output parameter | |
158 if (natural) | |
159 { | |
160 cm->nmethods = 1 ; | |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
161 cm->method[0].ordering = CHOLMOD_NATURAL ; |
5518 | 162 cm->postorder = false ; |
5506 | 163 } |
164 | |
165 cholmod_factor *Lfactor; | |
166 BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; | |
167 Lfactor = CHOLMOD_NAME(analyze) (ac, cm); | |
168 CHOLMOD_NAME(factorize) (ac, Lfactor, cm); | |
169 END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; | |
170 | |
171 is_pd = cm->status == CHOLMOD_OK; | |
172 info = (is_pd ? 0 : cm->status); | |
173 | |
15264
94cdf82d4a0c
don't overload meaning of info in Sparse Cholesky factorization functions
John W. Eaton <jwe@octave.org>
parents:
15185
diff
changeset
|
174 if (is_pd || force) |
5506 | 175 { |
176 BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; | |
7637
2be056f03720
Fix fall back from sparse cholesky factorization to LU when matrix detected as not being positive definite
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
177 cond = CHOLMOD_NAME(rcond) (Lfactor, cm); |
5506 | 178 END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; |
7637
2be056f03720
Fix fall back from sparse cholesky factorization to LU when matrix detected as not being positive definite
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
179 |
2be056f03720
Fix fall back from sparse cholesky factorization to LU when matrix detected as not being positive definite
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
180 minor_p = Lfactor->minor; |
2be056f03720
Fix fall back from sparse cholesky factorization to LU when matrix detected as not being positive definite
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
181 |
2be056f03720
Fix fall back from sparse cholesky factorization to LU when matrix detected as not being positive definite
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
182 BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; |
2be056f03720
Fix fall back from sparse cholesky factorization to LU when matrix detected as not being positive definite
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
183 Lsparse = CHOLMOD_NAME(factor_to_sparse) (Lfactor, cm); |
2be056f03720
Fix fall back from sparse cholesky factorization to LU when matrix detected as not being positive definite
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
184 END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; |
5506 | 185 |
7637
2be056f03720
Fix fall back from sparse cholesky factorization to LU when matrix detected as not being positive definite
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
186 if (minor_p > 0 && minor_p < a_nr) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
187 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
188 size_t n1 = a_nr + 1; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
189 Lsparse->p = CHOLMOD_NAME(realloc) (minor_p+1, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
190 sizeof(octave_idx_type), |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
191 Lsparse->p, &n1, cm); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
192 BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
193 CHOLMOD_NAME(reallocate_sparse) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
194 (static_cast<octave_idx_type *>(Lsparse->p)[minor_p], Lsparse, cm); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
195 END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
196 Lsparse->ncol = minor_p; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
197 } |
7637
2be056f03720
Fix fall back from sparse cholesky factorization to LU when matrix detected as not being positive definite
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
198 |
2be056f03720
Fix fall back from sparse cholesky factorization to LU when matrix detected as not being positive definite
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
199 drop_zeros (Lsparse); |
5506 | 200 |
7637
2be056f03720
Fix fall back from sparse cholesky factorization to LU when matrix detected as not being positive definite
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
201 if (! natural) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
202 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
203 perms.resize (a_nr); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
204 for (octave_idx_type i = 0; i < a_nr; i++) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
205 perms(i) = static_cast<octave_idx_type *>(Lfactor->Perm)[i]; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
206 } |
7637
2be056f03720
Fix fall back from sparse cholesky factorization to LU when matrix detected as not being positive definite
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
207 |
2be056f03720
Fix fall back from sparse cholesky factorization to LU when matrix detected as not being positive definite
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
208 static char tmp[] = " "; |
2be056f03720
Fix fall back from sparse cholesky factorization to LU when matrix detected as not being positive definite
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
209 |
2be056f03720
Fix fall back from sparse cholesky factorization to LU when matrix detected as not being positive definite
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
210 BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; |
2be056f03720
Fix fall back from sparse cholesky factorization to LU when matrix detected as not being positive definite
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
211 CHOLMOD_NAME(free_factor) (&Lfactor, cm); |
2be056f03720
Fix fall back from sparse cholesky factorization to LU when matrix detected as not being positive definite
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
212 CHOLMOD_NAME(finish) (cm); |
2be056f03720
Fix fall back from sparse cholesky factorization to LU when matrix detected as not being positive definite
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
213 CHOLMOD_NAME(print_common) (tmp, cm); |
2be056f03720
Fix fall back from sparse cholesky factorization to LU when matrix detected as not being positive definite
David Bateman <dbateman@free.fr>
parents:
7036
diff
changeset
|
214 END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; |
5506 | 215 } |
216 #else | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
217 (*current_liboctave_error_handler) |
5506 | 218 ("Missing CHOLMOD. Sparse cholesky factorization disabled"); |
219 #endif | |
220 return info; | |
221 } | |
222 | |
223 template <class chol_type, class chol_elt, class p_type> | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
224 chol_type |
5506 | 225 sparse_base_chol<chol_type, chol_elt, p_type>::L (void) const |
226 { | |
227 #ifdef HAVE_CHOLMOD | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
228 cholmod_sparse *m = rep->L (); |
5506 | 229 octave_idx_type nc = m->ncol; |
230 octave_idx_type nnz = m->nzmax; | |
231 chol_type ret (m->nrow, nc, nnz); | |
232 for (octave_idx_type j = 0; j < nc+1; j++) | |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
233 ret.xcidx (j) = static_cast<octave_idx_type *>(m->p)[j]; |
5506 | 234 for (octave_idx_type i = 0; i < nnz; i++) |
235 { | |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
236 ret.xridx (i) = static_cast<octave_idx_type *>(m->i)[i]; |
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
237 ret.xdata (i) = static_cast<chol_elt *>(m->x)[i]; |
5506 | 238 } |
239 return ret; | |
240 #else | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
241 return chol_type (); |
5506 | 242 #endif |
243 } | |
244 | |
245 template <class chol_type, class chol_elt, class p_type> | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
246 p_type |
5506 | 247 sparse_base_chol<chol_type, chol_elt, p_type>:: |
248 sparse_base_chol_rep::Q (void) const | |
249 { | |
250 #ifdef HAVE_CHOLMOD | |
251 octave_idx_type n = Lsparse->nrow; | |
252 p_type p (n, n, n); | |
253 | |
254 for (octave_idx_type i = 0; i < n; i++) | |
255 { | |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
256 p.xcidx (i) = i; |
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
257 p.xridx (i) = static_cast<octave_idx_type>(perms (i)); |
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
258 p.xdata (i) = 1; |
5506 | 259 } |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
260 p.xcidx (n) = n; |
5506 | 261 |
262 return p; | |
263 #else | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
264 return p_type (); |
5506 | 265 #endif |
266 } | |
267 | |
268 template <class chol_type, class chol_elt, class p_type> | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
269 chol_type |
5506 | 270 sparse_base_chol<chol_type, chol_elt, p_type>::inverse (void) const |
271 { | |
272 chol_type retval; | |
273 #ifdef HAVE_CHOLMOD | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
274 cholmod_sparse *m = rep->L (); |
5506 | 275 octave_idx_type n = m->ncol; |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
276 ColumnVector perms = rep->perm (); |
5506 | 277 chol_type ret; |
278 double rcond2; | |
279 octave_idx_type info; | |
5785 | 280 MatrixType mattype (MatrixType::Upper); |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
281 chol_type linv = L ().hermitian ().inverse (mattype, info, rcond2, 1, 0); |
5506 | 282 |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
283 if (perms.length () == n) |
5506 | 284 { |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
285 p_type Qc = Q (); |
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
286 retval = Qc * linv * linv.hermitian () * Qc.transpose (); |
5506 | 287 } |
288 else | |
8402
2176f2b4599e
Fix sparse cholesky inversion
David Bateman <dbateman@free.fr>
parents:
7637
diff
changeset
|
289 retval = linv * linv.hermitian (); |
5506 | 290 #endif |
291 return retval; | |
292 } |