Mercurial > hg > octave-nkf
annotate liboctave/numeric/ODEFunc.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 |
rev | line source |
---|---|
3 | 1 /* |
2 | |
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
3 Copyright (C) 1993-2015 John W. Eaton |
3 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
3 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
3 | 20 |
21 */ | |
22 | |
382 | 23 #if !defined (octave_ODEFunc_h) |
24 #define octave_ODEFunc_h 1 | |
25 | |
465 | 26 class Matrix; |
27 class ColumnVector; | |
3 | 28 |
1861 | 29 class |
30 ODEFunc | |
3 | 31 { |
32 public: | |
33 | |
1536 | 34 typedef ColumnVector (*ODERHSFunc) (const ColumnVector&, double); |
35 typedef Matrix (*ODEJacFunc) (const ColumnVector&, double); | |
36 | |
37 ODEFunc (void) | |
4049 | 38 : fun (0), jac (0), reset (true) { } |
532 | 39 |
1536 | 40 ODEFunc (ODERHSFunc f) |
4049 | 41 : fun (f), jac (0), reset (true) { } |
3 | 42 |
1536 | 43 ODEFunc (ODERHSFunc f, ODEJacFunc j) |
4049 | 44 : fun (f), jac (j), reset (true) { } |
3 | 45 |
1536 | 46 ODEFunc (const ODEFunc& a) |
4049 | 47 : fun (a.fun), jac (a.jac), reset (true) { } |
3 | 48 |
1536 | 49 ODEFunc& operator = (const ODEFunc& a) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
50 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
51 if (this != &a) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
52 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
53 fun = a.fun; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
54 jac = a.jac; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
55 reset = a.reset; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
56 } |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
57 return *this; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
58 } |
3 | 59 |
11504
81ff63e43f54
really make destuctors virtual in ODE/DAE base classes
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
60 virtual ~ODEFunc (void) { } |
1861 | 61 |
1536 | 62 ODERHSFunc function (void) const { return fun; } |
63 | |
64 ODEFunc& set_function (ODERHSFunc f) | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
65 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
66 fun = f; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
67 reset = true; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
68 return *this; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
69 } |
3 | 70 |
1536 | 71 ODEJacFunc jacobian_function (void) const { return jac; } |
3 | 72 |
1536 | 73 ODEFunc& set_jacobian_function (ODEJacFunc j) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
74 { |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
75 jac = j; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
76 reset = true; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
77 return *this; |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
78 } |
3 | 79 |
80 protected: | |
81 | |
82 ODERHSFunc fun; | |
83 ODEJacFunc jac; | |
4049 | 84 |
85 // This variable is TRUE when this object is constructed, and also | |
86 // after any internal data has changed. Derived classes may use | |
87 // this information (and change it) to know when to (re)initialize | |
88 // their own internal data related to this object. | |
89 | |
90 bool reset; | |
382 | 91 }; |
3 | 92 |
93 #endif |