Mercurial > octave
annotate libinterp/corefcn/__ichol__.cc @ 30564:796f54d4ddbf stable
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2021.
In all .txi and .texi files except gpl.txi and gpl.texi in the
doc/liboctave and doc/interpreter directories, change the copyright
to "Octave Project Developers", the same as used for other source
files. Update copyright notices for 2022 (not done since 2019). For
gpl.txi and gpl.texi, change the copyright notice to be "Free Software
Foundation, Inc." and leave the date at 2007 only because this file
only contains the text of the GPL, not anything created by the Octave
Project Developers.
Add Paul Thomas to contributors.in.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 28 Dec 2021 18:22:40 -0500 |
parents | a61e1a0f6024 |
children | 820d2c802247 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30390
diff
changeset
|
3 // Copyright (C) 2013-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21568
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
27 # include "config.h" |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
28 #endif |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
29 |
19269
65554f5847ac
don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents:
19080
diff
changeset
|
30 #include "oct-locbuf.h" |
23099
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
31 #include "oct-norm.h" |
19269
65554f5847ac
don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents:
19080
diff
changeset
|
32 |
19877
12ecb7212b44
move some files without external dependencies from dldfcn to corefcn
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
33 #include "defun.h" |
12ecb7212b44
move some files without external dependencies from dldfcn to corefcn
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
34 #include "error.h" |
23099
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
35 |
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
36 #include "builtin-defun-decls.h" |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
37 |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29874
diff
changeset
|
38 OCTAVE_NAMESPACE_BEGIN |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29874
diff
changeset
|
39 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
40 // Secondary functions for complex and real case used in ichol algorithms. |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
41 Complex ichol_mult_complex (Complex a, Complex b) |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
42 { |
19080
af9c22e20a57
Apply std::complex feature tests to ichol helper function
Mike Miller <mtmiller@ieee.org>
parents:
19055
diff
changeset
|
43 #if defined (HAVE_CXX_COMPLEX_SETTERS) |
22274
edcad35c364f
don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents:
22105
diff
changeset
|
44 b.imag (-b.imag ()); |
19080
af9c22e20a57
Apply std::complex feature tests to ichol helper function
Mike Miller <mtmiller@ieee.org>
parents:
19055
diff
changeset
|
45 #elif defined (HAVE_CXX_COMPLEX_REFERENCE_ACCESSORS) |
22274
edcad35c364f
don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents:
22105
diff
changeset
|
46 b.imag () = -b.imag (); |
19080
af9c22e20a57
Apply std::complex feature tests to ichol helper function
Mike Miller <mtmiller@ieee.org>
parents:
19055
diff
changeset
|
47 #else |
22274
edcad35c364f
don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents:
22105
diff
changeset
|
48 b = b.conj (); |
19080
af9c22e20a57
Apply std::complex feature tests to ichol helper function
Mike Miller <mtmiller@ieee.org>
parents:
19055
diff
changeset
|
49 #endif |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
50 return a * b; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
51 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
52 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
53 double ichol_mult_real (double a, double b) |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
54 { |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
55 return a * b; |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
56 } |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
57 |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
58 bool ichol_checkpivot_complex (Complex pivot) |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
59 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
60 if (pivot.imag () != 0) |
21419
13415264b9f8
Fix out-of-bounds memory access in ichol, ilu (bug #46449).
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
61 error ("ichol: non-real pivot encountered. The matrix must be Hermitian."); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
62 else if (pivot.real () < 0) |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20802
diff
changeset
|
63 error ("ichol: negative pivot encountered"); |
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20802
diff
changeset
|
64 |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
65 return true; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
66 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
67 |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
68 bool ichol_checkpivot_real (double pivot) |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
69 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
70 if (pivot < 0) |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20802
diff
changeset
|
71 error ("ichol: negative pivot encountered"); |
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20802
diff
changeset
|
72 |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
73 return true; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
74 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
75 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
76 template <typename octave_matrix_t, typename T, T (*ichol_mult) (T, T), |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
77 bool (*ichol_checkpivot) (T)> |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
78 void ichol_0 (octave_matrix_t& sm, const std::string michol = "off") |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
79 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
80 const octave_idx_type n = sm.cols (); |
19315
9f8ec58b5c74
__ichol__.cc: Removed unused variables causing compilation warnings.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19269
diff
changeset
|
81 octave_idx_type j1, jend, j2, jrow, jjrow, j, jw, i, k, jj, r; |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
82 T tl; |
21419
13415264b9f8
Fix out-of-bounds memory access in ichol, ilu (bug #46449).
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
83 |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
84 char opt; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
85 enum {OFF, ON}; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
86 if (michol == "on") |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
87 opt = ON; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
88 else |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
89 opt = OFF; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
90 |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
91 // Input matrix pointers |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
92 octave_idx_type *cidx = sm.cidx (); |
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
93 octave_idx_type *ridx = sm.ridx (); |
30390
a61e1a0f6024
maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29961
diff
changeset
|
94 T *data = sm.data (); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
95 |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
96 // Working arrays |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
97 OCTAVE_LOCAL_BUFFER (octave_idx_type, Lfirst, n); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
98 OCTAVE_LOCAL_BUFFER (octave_idx_type, Llist, n); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
99 OCTAVE_LOCAL_BUFFER (octave_idx_type, iw, n); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
100 OCTAVE_LOCAL_BUFFER (T, dropsums, n); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
101 |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
102 // Initialize working arrays |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
103 for (i = 0; i < n; i++) |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
104 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
105 iw[i] = -1; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
106 Llist[i] = -1; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
107 Lfirst[i] = -1; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
108 dropsums[i] = 0; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
109 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
110 |
21419
13415264b9f8
Fix out-of-bounds memory access in ichol, ilu (bug #46449).
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
111 // Loop over all columns |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
112 for (k = 0; k < n; k++) |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
113 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
114 j1 = cidx[k]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
115 j2 = cidx[k+1]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
116 for (j = j1; j < j2; j++) |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
117 iw[ridx[j]] = j; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
118 |
21419
13415264b9f8
Fix out-of-bounds memory access in ichol, ilu (bug #46449).
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
119 jrow = Llist[k]; |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
120 // Iterate over each non-zero element in the actual row. |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
121 while (jrow != -1) |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
122 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
123 jjrow = Lfirst[jrow]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
124 jend = cidx[jrow+1]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
125 for (jj = jjrow; jj < jend; jj++) |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
126 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
127 r = ridx[jj]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
128 jw = iw[r]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
129 tl = ichol_mult (data[jj], data[jjrow]); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
130 if (jw != -1) |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
131 data[jw] -= tl; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
132 else |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
133 // Because of the symmetry of the matrix, we know |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
134 // the drops in the column r are also in the column k. |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
135 if (opt == ON) |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
136 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
137 dropsums[r] -= tl; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
138 dropsums[k] -= tl; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
139 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
140 } |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
141 // Update the linked list and the first entry of the actual column. |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
142 if ((jjrow + 1) < jend) |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
143 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
144 Lfirst[jrow]++; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
145 j = jrow; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
146 jrow = Llist[jrow]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
147 Llist[j] = Llist[ridx[Lfirst[j]]]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
148 Llist[ridx[Lfirst[j]]] = j; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
149 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
150 else |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
151 jrow = Llist[jrow]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
152 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
153 |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
154 if (opt == ON) |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
155 data[j1] += dropsums[k]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
156 |
21419
13415264b9f8
Fix out-of-bounds memory access in ichol, ilu (bug #46449).
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
157 // Test for j1 == j2 must be first to avoid invalid ridx[j1] access |
13415264b9f8
Fix out-of-bounds memory access in ichol, ilu (bug #46449).
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
158 if (j1 == j2 || ridx[j1] != k) |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20802
diff
changeset
|
159 error ("ichol: encountered a pivot equal to 0"); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
160 |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
161 if (! ichol_checkpivot (data[j1])) |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
162 break; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
163 |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
164 data[cidx[k]] = std::sqrt (data[j1]); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
165 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
166 // Update Llist and Lfirst with the k-column information. Also, |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
167 // scale the column elements by the pivot and reset the working array iw. |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
168 if (k < (n - 1)) |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
169 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
170 iw[ridx[j1]] = -1; |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
171 for (i = j1 + 1; i < j2; i++) |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
172 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
173 iw[ridx[i]] = -1; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
174 data[i] /= data[j1]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
175 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
176 Lfirst[k] = j1; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
177 if ((Lfirst[k] + 1) < j2) |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
178 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
179 Lfirst[k]++; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
180 jjrow = ridx[Lfirst[k]]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
181 Llist[k] = Llist[jjrow]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
182 Llist[jjrow] = k; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
183 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
184 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
185 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
186 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
187 |
20915
a3359fe50966
remove unused nargout variables
John W. Eaton <jwe@octave.org>
parents:
20909
diff
changeset
|
188 DEFUN (__ichol0__, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
189 doc: /* -*- texinfo -*- |
23099
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
190 @deftypefn {} {@var{L} =} __ichol0__ (@var{A}, @var{michol}) |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
191 Undocumented internal function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
192 @end deftypefn */) |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
193 { |
23099
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
194 if (args.length () != 2) |
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
195 print_usage (); |
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
196 |
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
197 std::string michol = args(1).string_value (); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
198 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
199 // In ICHOL0 algorithm the zero-pattern of the input matrix is preserved |
22105
3f5f1234c619
main: Fix typos "It's" -> "Its" and "it's" -> "its" (Bug #48508)
Andreas Weber <andy.weber.aw@gmail.com>
parents:
21966
diff
changeset
|
200 // so its structure does not change during the algorithm. The same input |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
201 // matrix is used to build the output matrix due to that fact. |
23581
c3075ae020e1
maint: Deprecate is_complex_type and replace with iscomplex.
Rik <rik@octave.org>
parents:
23449
diff
changeset
|
202 if (! args(0).iscomplex ()) |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
203 { |
23099
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
204 SparseMatrix sm = Ftril (args(0))(0).sparse_matrix_value (); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
205 ichol_0 <SparseMatrix, double, ichol_mult_real, |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
206 ichol_checkpivot_real> (sm, michol); |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20915
diff
changeset
|
207 return ovl (sm); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
208 } |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
209 else |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
210 { |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26946
diff
changeset
|
211 SparseComplexMatrix sm |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26946
diff
changeset
|
212 = Ftril (args(0))(0).sparse_complex_matrix_value (); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
213 ichol_0 <SparseComplexMatrix, Complex, ichol_mult_complex, |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
214 ichol_checkpivot_complex> (sm, michol); |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20915
diff
changeset
|
215 return ovl (sm); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
216 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
217 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
218 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
219 template <typename octave_matrix_t, typename T, T (*ichol_mult) (T, T), |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
220 bool (*ichol_checkpivot) (T)> |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
221 void ichol_t (const octave_matrix_t& sm, octave_matrix_t& L, const T* cols_norm, |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
222 const T droptol, const std::string michol = "off") |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
223 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
224 |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
225 const octave_idx_type n = sm.cols (); |
19315
9f8ec58b5c74
__ichol__.cc: Removed unused variables causing compilation warnings.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19269
diff
changeset
|
226 octave_idx_type j, jrow, jend, jjrow, i, k, jj, total_len, |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
227 w_len, max_len, ind; |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
228 char opt; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
229 enum {OFF, ON}; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
230 if (michol == "on") |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
231 opt = ON; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
232 else |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
233 opt = OFF; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
234 |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
235 // Input matrix pointers |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
236 octave_idx_type *cidx = sm.cidx (); |
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
237 octave_idx_type *ridx = sm.ridx (); |
30390
a61e1a0f6024
maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29961
diff
changeset
|
238 T *data = sm.data (); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
239 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
240 // Output matrix data structures. Because the final zero pattern pattern of |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
241 // the output matrix is not known due to fill-in elements, a heuristic |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
242 // approach has been adopted for memory allocation. The size of ridx_out_l |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
243 // and data_out_l is incremented 10% of their actual size (nnz (A) in the |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
244 // beginning). If that amount is less than n, their size is just incremented |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
245 // in n elements. This way the number of reallocations decreases throughout |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
246 // the process, obtaining a good performance. |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
247 max_len = sm.nnz (); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
248 max_len += (0.1 * max_len) > n ? 0.1 * max_len : n; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
249 Array <octave_idx_type> cidx_out_l (dim_vector (n + 1, 1)); |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
250 octave_idx_type *cidx_l = cidx_out_l.fortran_vec (); |
27932
b018f553fd85
maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
251 Array <octave_idx_type> ridx_out_l (dim_vector (max_len, 1)); |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
252 octave_idx_type *ridx_l = ridx_out_l.fortran_vec (); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
253 Array <T> data_out_l (dim_vector (max_len, 1)); |
30390
a61e1a0f6024
maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29961
diff
changeset
|
254 T *data_l = data_out_l.fortran_vec (); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
255 |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
256 // Working arrays |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
257 OCTAVE_LOCAL_BUFFER (T, w_data, n); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
258 OCTAVE_LOCAL_BUFFER (octave_idx_type, Lfirst, n); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
259 OCTAVE_LOCAL_BUFFER (octave_idx_type, Llist, n); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
260 OCTAVE_LOCAL_BUFFER (T, col_drops, n); |
23899
437ba51e8bcf
Fix segfault in ichol under certain conditions (bug #51736).
Richard Zweig <richard.zweig@gmx.de>
parents:
23219
diff
changeset
|
261 std::vector<octave_idx_type> vec (n, 0); |
437ba51e8bcf
Fix segfault in ichol under certain conditions (bug #51736).
Richard Zweig <richard.zweig@gmx.de>
parents:
23219
diff
changeset
|
262 std::vector<bool> mark (n, false); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
263 |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
264 T zero = T (0); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
265 cidx_l[0] = cidx[0]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
266 for (i = 0; i < n; i++) |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
267 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
268 Llist[i] = -1; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
269 Lfirst[i] = -1; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
270 w_data[i] = 0; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
271 col_drops[i] = zero; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
272 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
273 |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
274 total_len = 0; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
275 for (k = 0; k < n; k++) |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
276 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
277 ind = 0; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
278 for (j = cidx[k]; j < cidx[k+1]; j++) |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
279 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
280 w_data[ridx[j]] = data[j]; |
23899
437ba51e8bcf
Fix segfault in ichol under certain conditions (bug #51736).
Richard Zweig <richard.zweig@gmx.de>
parents:
23219
diff
changeset
|
281 // Mark column index, intentionally outside the if-clause to ensure |
437ba51e8bcf
Fix segfault in ichol under certain conditions (bug #51736).
Richard Zweig <richard.zweig@gmx.de>
parents:
23219
diff
changeset
|
282 // that mark[k] will be set to true as well. |
437ba51e8bcf
Fix segfault in ichol under certain conditions (bug #51736).
Richard Zweig <richard.zweig@gmx.de>
parents:
23219
diff
changeset
|
283 mark[ridx[j]] = true; |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
284 if (ridx[j] != k) |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
285 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
286 vec[ind] = ridx[j]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
287 ind++; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
288 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
289 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
290 jrow = Llist[k]; |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
291 while (jrow != -1) |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
292 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
293 jjrow = Lfirst[jrow]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
294 jend = cidx_l[jrow+1]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
295 for (jj = jjrow; jj < jend; jj++) |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
296 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
297 j = ridx_l[jj]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
298 // If the element in the j position of the row is zero, |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
299 // then it will become non-zero, so we add it to the |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
300 // vector that tracks non-zero elements in the working row. |
23899
437ba51e8bcf
Fix segfault in ichol under certain conditions (bug #51736).
Richard Zweig <richard.zweig@gmx.de>
parents:
23219
diff
changeset
|
301 if (! mark[j]) |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
302 { |
23899
437ba51e8bcf
Fix segfault in ichol under certain conditions (bug #51736).
Richard Zweig <richard.zweig@gmx.de>
parents:
23219
diff
changeset
|
303 mark[j] = true; |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
304 vec[ind] = j; |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
305 ind++; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
306 } |
21568
3d60ed163b70
maint: Eliminate bad spacing around '='.
Rik <rik@octave.org>
parents:
21419
diff
changeset
|
307 w_data[j] -= ichol_mult (data_l[jj], data_l[jjrow]); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
308 } |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
309 // Update the actual column first element and |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
310 // update the linked list of the jrow row. |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
311 if ((jjrow + 1) < jend) |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
312 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
313 Lfirst[jrow]++; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
314 j = jrow; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
315 jrow = Llist[jrow]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
316 Llist[j] = Llist[ridx_l[Lfirst[j]]]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
317 Llist[ridx_l[Lfirst[j]]] = j; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
318 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
319 else |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
320 jrow = Llist[jrow]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
321 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
322 |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
323 // Resizing output arrays |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
324 if ((max_len - total_len) < n) |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
325 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
326 max_len += (0.1 * max_len) > n ? 0.1 * max_len : n; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
327 data_out_l.resize (dim_vector (max_len, 1)); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
328 data_l = data_out_l.fortran_vec (); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
329 ridx_out_l.resize (dim_vector (max_len, 1)); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
330 ridx_l = ridx_out_l.fortran_vec (); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
331 } |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
332 |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
333 // The sorting of the non-zero elements of the working column can be |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
334 // handled in a couple of ways. The most efficient two I found, are |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
335 // keeping the elements in an ordered binary search tree dynamically or |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
336 // keep them unsorted in a vector and at the end of the outer iteration |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
337 // order them. The last approach exhibits lower execution times. |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
338 std::sort (vec.begin (), vec.begin () + ind); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
339 |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
340 data_l[total_len] = w_data[k]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
341 ridx_l[total_len] = k; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
342 w_len = 1; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
343 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
344 // Extract the non-zero elements of working column and |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
345 // drop the elements that are lower than droptol * cols_norm[k]. |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
346 for (i = 0; i < ind ; i++) |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
347 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
348 jrow = vec[i]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
349 if (w_data[jrow] != zero) |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
350 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
351 if (std::abs (w_data[jrow]) < (droptol * cols_norm[k])) |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
352 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
353 if (opt == ON) |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
354 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
355 col_drops[k] += w_data[jrow]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
356 col_drops[jrow] += w_data[jrow]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
357 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
358 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
359 else |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
360 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
361 data_l[total_len + w_len] = w_data[jrow]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
362 ridx_l[total_len + w_len] = jrow; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
363 w_len++; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
364 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
365 } |
23899
437ba51e8bcf
Fix segfault in ichol under certain conditions (bug #51736).
Richard Zweig <richard.zweig@gmx.de>
parents:
23219
diff
changeset
|
366 // Clear mark, vec, and w_data. However, mark[k] is not set to zero. |
437ba51e8bcf
Fix segfault in ichol under certain conditions (bug #51736).
Richard Zweig <richard.zweig@gmx.de>
parents:
23219
diff
changeset
|
367 mark[jrow] = false; |
437ba51e8bcf
Fix segfault in ichol under certain conditions (bug #51736).
Richard Zweig <richard.zweig@gmx.de>
parents:
23219
diff
changeset
|
368 vec[i] = 0; |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
369 w_data[jrow] = zero; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
370 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
371 |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
372 // Compensate column sums --> michol option |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
373 if (opt == ON) |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
374 data_l[total_len] += col_drops[k]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
375 |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
376 if (data_l[total_len] == zero) |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20802
diff
changeset
|
377 error ("ichol: encountered a pivot equal to 0"); |
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20802
diff
changeset
|
378 |
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20802
diff
changeset
|
379 if (! ichol_checkpivot (data_l[total_len])) |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
380 break; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
381 |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
382 // Once elements are dropped and compensation of column sums are done, |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
383 // scale the elements by the pivot. |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
384 data_l[total_len] = std::sqrt (data_l[total_len]); |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
385 for (jj = total_len + 1; jj < (total_len + w_len); jj++) |
21568
3d60ed163b70
maint: Eliminate bad spacing around '='.
Rik <rik@octave.org>
parents:
21419
diff
changeset
|
386 data_l[jj] /= data_l[total_len]; |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
387 total_len += w_len; |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
388 // Check if there are too many elements to be indexed with |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
389 // octave_idx_type type due to fill-in during the process. |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
390 if (total_len < 0) |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20802
diff
changeset
|
391 error ("ichol: integer overflow. Too many fill-in elements in L"); |
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20802
diff
changeset
|
392 |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
393 cidx_l[k+1] = cidx_l[k] - cidx_l[0] + w_len; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
394 |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
395 // Update Llist and Lfirst with the k-column information. |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
396 if (k < (n - 1)) |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
397 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
398 Lfirst[k] = cidx_l[k]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
399 if ((Lfirst[k] + 1) < cidx_l[k+1]) |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
400 { |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
401 Lfirst[k]++; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
402 jjrow = ridx_l[Lfirst[k]]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
403 Llist[k] = Llist[jjrow]; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
404 Llist[jjrow] = k; |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
405 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
406 } |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
407 } |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
408 |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
19877
diff
changeset
|
409 // Build the output matrices |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
19877
diff
changeset
|
410 L = octave_matrix_t (n, n, total_len); |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
19877
diff
changeset
|
411 |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
19877
diff
changeset
|
412 for (i = 0; i <= n; i++) |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
19877
diff
changeset
|
413 L.cidx (i) = cidx_l[i]; |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
19877
diff
changeset
|
414 |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
19877
diff
changeset
|
415 for (i = 0; i < total_len; i++) |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
416 { |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
19877
diff
changeset
|
417 L.ridx (i) = ridx_l[i]; |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
19877
diff
changeset
|
418 L.data (i) = data_l[i]; |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
419 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
420 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
421 |
20915
a3359fe50966
remove unused nargout variables
John W. Eaton <jwe@octave.org>
parents:
20909
diff
changeset
|
422 DEFUN (__icholt__, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
423 doc: /* -*- texinfo -*- |
23099
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
424 @deftypefn {} {@var{L} =} __icholt__ (@var{A}, @var{droptol}, @var{michol}) |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
425 Undocumented internal function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
426 @end deftypefn */) |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
427 { |
23099
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
428 if (args.length () != 3) |
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
429 print_usage (); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
430 |
23099
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
431 double droptol = args(1).double_value (); |
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
432 std::string michol = args(2).string_value (); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
433 |
23581
c3075ae020e1
maint: Deprecate is_complex_type and replace with iscomplex.
Rik <rik@octave.org>
parents:
23449
diff
changeset
|
434 if (! args(0).iscomplex ()) |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
435 { |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
436 SparseMatrix L; |
23099
d44537a50f4b
__ilu__ and __ichol__: use liboctave functions instead of feval (bug #50105)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
23084
diff
changeset
|
437 SparseMatrix sm_l = Ftril (args(0))(0).sparse_matrix_value (); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
438 ichol_t <SparseMatrix, |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
439 double, ichol_mult_real, ichol_checkpivot_real> |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
440 (sm_l, L, xcolnorms (sm_l, 1).fortran_vec (), droptol, michol); |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
19877
diff
changeset
|
441 |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20915
diff
changeset
|
442 return ovl (L); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
443 } |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
444 else |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
445 { |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
446 SparseComplexMatrix L; |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26946
diff
changeset
|
447 SparseComplexMatrix sm_l |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26946
diff
changeset
|
448 = Ftril (args(0))(0).sparse_complex_matrix_value (); |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
449 Array <Complex> cols_norm = xcolnorms (sm_l, 1); |
19055
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
450 ichol_t <SparseComplexMatrix, |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
451 Complex, ichol_mult_complex, ichol_checkpivot_complex> |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
452 (sm_l, L, cols_norm.fortran_vec (), |
38937efbee21
Incorporate new functions ichol and ilu into Octave.
Rik <rik@octave.org>
parents:
19054
diff
changeset
|
453 Complex (droptol), michol); |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
19877
diff
changeset
|
454 |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20915
diff
changeset
|
455 return ovl (L); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
456 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
457 } |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
458 |
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
459 /* |
26946
04e5cb5e2cb3
update bug status in tests
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
460 %!test <*51736> |
23901
b590c674e27d
Add BIST test for ichol_t (bug #51736).
Richard Zweig <richard.zweig@gmx.de>
parents:
23900
diff
changeset
|
461 %! k = 4; |
b590c674e27d
Add BIST test for ichol_t (bug #51736).
Richard Zweig <richard.zweig@gmx.de>
parents:
23900
diff
changeset
|
462 %! n = 2^k; |
b590c674e27d
Add BIST test for ichol_t (bug #51736).
Richard Zweig <richard.zweig@gmx.de>
parents:
23900
diff
changeset
|
463 %! Afull = diag (ones (n,1)) / ... |
b590c674e27d
Add BIST test for ichol_t (bug #51736).
Richard Zweig <richard.zweig@gmx.de>
parents:
23900
diff
changeset
|
464 %! 2+triu ([zeros(n,2), [n.^-[1;1;2]*ones(1,n-2);zeros(n-3,n-2)]], 1); |
b590c674e27d
Add BIST test for ichol_t (bug #51736).
Richard Zweig <richard.zweig@gmx.de>
parents:
23900
diff
changeset
|
465 %! A = sparse (Afull + Afull.'); |
b590c674e27d
Add BIST test for ichol_t (bug #51736).
Richard Zweig <richard.zweig@gmx.de>
parents:
23900
diff
changeset
|
466 %! opts.type = "ict"; |
b590c674e27d
Add BIST test for ichol_t (bug #51736).
Richard Zweig <richard.zweig@gmx.de>
parents:
23900
diff
changeset
|
467 %! opts.droptol = 0; |
b590c674e27d
Add BIST test for ichol_t (bug #51736).
Richard Zweig <richard.zweig@gmx.de>
parents:
23900
diff
changeset
|
468 %! L = ichol (A, opts); |
b590c674e27d
Add BIST test for ichol_t (bug #51736).
Richard Zweig <richard.zweig@gmx.de>
parents:
23900
diff
changeset
|
469 %! assert (norm (A - L*L.'), 0, 2*eps); |
19054
df64071e538c
Removed ichol0.cc, icholt.cc, ilu0.cc, iluc.cc, ilutp.cc. Created __ichol__.cc and __ilu__.cc. Minor bugs fixed.
Eduardo Ramos (edu159) <eduradical951@gmail.com>
parents:
diff
changeset
|
470 */ |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29874
diff
changeset
|
471 |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29874
diff
changeset
|
472 OCTAVE_NAMESPACE_END |