Mercurial > hg > octave-nkf
annotate liboctave/numeric/CmplxCHOL.h @ 20809:ffc6cdcd02c5 stable
Fix segfault when complex double matrix calls ZGETRF (bug #45577).
* CMatrix.cc (finverse, determinant, rcond, fsolve): Calculate norm of matrix
and if it is NaN, skip calling ZGETRF in LAPACK and set info to non-zero value
to signal an error.
author | Rik <rik@octave.org> |
---|---|
date | Sat, 10 Oct 2015 16:46:00 -0700 |
parents | 4197fc428c7d |
children | 5ce959c55cc0 |
rev | line source |
---|---|
457 | 1 /* |
2 | |
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17822
diff
changeset
|
3 Copyright (C) 1994-2015 John W. Eaton |
11523 | 4 Copyright (C) 2008-2009 Jaroslav Hajek |
457 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
457 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
457 | 21 |
22 */ | |
23 | |
17822
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17769
diff
changeset
|
24 #if !defined (octave_CmplxCHOL_h) |
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17769
diff
changeset
|
25 #define octave_CmplxCHOL_h 1 |
457 | 26 |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8562
diff
changeset
|
27 #include <iosfwd> |
457 | 28 |
29 #include "CMatrix.h" | |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
7700
diff
changeset
|
30 #include "CColVector.h" |
457 | 31 |
1881 | 32 class |
6108 | 33 OCTAVE_API |
1881 | 34 ComplexCHOL |
457 | 35 { |
36 public: | |
37 | |
11498
367bfee35ba0
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
38 ComplexCHOL (void) : chol_mat (), xrcond (0) { } |
1528 | 39 |
11498
367bfee35ba0
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
40 ComplexCHOL (const ComplexMatrix& a, bool calc_cond = false) |
367bfee35ba0
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
41 : chol_mat (), xrcond (0) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
42 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
43 init (a, calc_cond); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
44 } |
1528 | 45 |
11498
367bfee35ba0
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
46 ComplexCHOL (const ComplexMatrix& a, octave_idx_type& info, |
367bfee35ba0
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
47 bool calc_cond = false) |
367bfee35ba0
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
48 : chol_mat (), xrcond (0) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
49 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
50 info = init (a, calc_cond); |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
51 } |
1528 | 52 |
4055 | 53 ComplexCHOL (const ComplexCHOL& a) |
6486 | 54 : chol_mat (a.chol_mat), xrcond (a.xrcond) { } |
1528 | 55 |
4055 | 56 ComplexCHOL& operator = (const ComplexCHOL& a) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
57 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
58 if (this != &a) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
59 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
60 chol_mat = a.chol_mat; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
61 xrcond = a.xrcond; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
62 } |
1528 | 63 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
64 return *this; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
65 } |
1528 | 66 |
5340 | 67 ComplexMatrix chol_matrix (void) const { return chol_mat; } |
68 | |
6486 | 69 double rcond (void) const { return xrcond; } |
70 | |
5340 | 71 ComplexMatrix inverse (void) const; |
457 | 72 |
7554
40574114c514
implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
73 void set (const ComplexMatrix& R); |
40574114c514
implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
74 |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
7700
diff
changeset
|
75 void update (const ComplexColumnVector& u); |
7554
40574114c514
implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
76 |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
7700
diff
changeset
|
77 octave_idx_type downdate (const ComplexColumnVector& u); |
7554
40574114c514
implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents:
7017
diff
changeset
|
78 |
8547
d66c9b6e506a
imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
7700
diff
changeset
|
79 octave_idx_type insert_sym (const ComplexColumnVector& u, octave_idx_type j); |
7700
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
80 |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
81 void delete_sym (octave_idx_type j); |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
82 |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
83 void shift_sym (octave_idx_type i, octave_idx_type j); |
efccca5f2ad7
more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7554
diff
changeset
|
84 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
85 friend OCTAVE_API std::ostream& operator << (std::ostream& os, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
86 const ComplexCHOL& a); |
457 | 87 |
88 private: | |
89 | |
1881 | 90 ComplexMatrix chol_mat; |
457 | 91 |
6486 | 92 double xrcond; |
93 | |
94 octave_idx_type init (const ComplexMatrix& a, bool calc_cond); | |
457 | 95 }; |
96 | |
6108 | 97 ComplexMatrix OCTAVE_API chol2inv (const ComplexMatrix& r); |
5340 | 98 |
457 | 99 #endif |