Mercurial > hg > octave-nkf
annotate liboctave/numeric/SparseCmplxCHOL.cc @ 20830:b65888ec820e draft default tip gccjit
dmalcom gcc jit import
author | Stefan Mahr <dac922@gmx.de> |
---|---|
date | Fri, 27 Feb 2015 16:59:36 +0100 |
parents | 4197fc428c7d |
children |
rev | line source |
---|---|
5506 | 1 /* |
2 | |
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17783
diff
changeset
|
3 Copyright (C) 2005-2015 David Bateman |
11523 | 4 Copyright (C) 1998-2005 Andy Adler |
7016 | 5 |
6 This file is part of Octave. | |
5506 | 7 |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
5506 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
5506 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
28 #include "SparseCmplxCHOL.h" | |
29 | |
30 // Instantiate the base CHOL class for the type we need | |
31 #define OCTAVE_CHOLMOD_TYPE CHOLMOD_COMPLEX | |
32 #include "sparse-base-chol.h" | |
33 #include "sparse-base-chol.cc" | |
34 template class sparse_base_chol <SparseComplexMatrix, Complex, SparseMatrix>; | |
35 | |
36 // Compute the inverse of a matrix using the Cholesky factorization. | |
37 SparseComplexMatrix | |
38 chol2inv (const SparseComplexMatrix& r) | |
39 { | |
40 octave_idx_type r_nr = r.rows (); | |
41 octave_idx_type r_nc = r.cols (); | |
42 SparseComplexMatrix retval; | |
43 | |
44 if (r_nr == r_nc) | |
45 { | |
5785 | 46 MatrixType mattype (r); |
5506 | 47 int typ = mattype.type (false); |
48 double rcond; | |
49 octave_idx_type info; | |
50 SparseComplexMatrix rinv; | |
51 | |
5785 | 52 if (typ == MatrixType::Upper) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
53 { |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
54 rinv = r.inverse (mattype, info, rcond, true, false); |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
55 retval = rinv.transpose () * rinv; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
56 } |
5785 | 57 else if (typ == MatrixType::Lower) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
58 { |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
59 rinv = r.transpose ().inverse (mattype, info, rcond, true, false); |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
60 retval = rinv.transpose () * rinv; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
61 } |
5506 | 62 else |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
63 (*current_liboctave_error_handler) |
17783
eca761671f16
SparseCmplxCHOL.cc, SparsedbleCHOL.cc: removed spchol2inv from error msg
Andreas Weber <andy.weber.aw@gmail.com>
parents:
17744
diff
changeset
|
64 ("U must be a triangular matrix"); |
5506 | 65 } |
66 else | |
17783
eca761671f16
SparseCmplxCHOL.cc, SparsedbleCHOL.cc: removed spchol2inv from error msg
Andreas Weber <andy.weber.aw@gmail.com>
parents:
17744
diff
changeset
|
67 (*current_liboctave_error_handler) ("U must be a square matrix"); |
5506 | 68 |
69 return retval; | |
70 } |