GNU Octave
4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
liboctave
numeric
SparseCmplxCHOL.cc
Go to the documentation of this file.
1
/*
2
3
Copyright (C) 2005-2015 David Bateman
4
Copyright (C) 1998-2005 Andy Adler
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
10
Free Software Foundation; either version 3 of the License, or (at your
11
option) any later version.
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
19
along with Octave; see the file COPYING. If not, see
20
<http://www.gnu.org/licenses/>.
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
{
46
MatrixType
mattype (r);
47
int
typ = mattype.
type
(
false
);
48
double
rcond;
49
octave_idx_type
info;
50
SparseComplexMatrix
rinv;
51
52
if
(typ ==
MatrixType::Upper
)
53
{
54
rinv = r.
inverse
(mattype, info, rcond,
true
,
false
);
55
retval = rinv.
transpose
() * rinv;
56
}
57
else
if
(typ ==
MatrixType::Lower
)
58
{
59
rinv = r.
transpose
().
inverse
(mattype, info, rcond,
true
,
false
);
60
retval = rinv.
transpose
() * rinv;
61
}
62
else
63
(*
current_liboctave_error_handler
)
64
(
"U must be a triangular matrix"
);
65
}
66
else
67
(*
current_liboctave_error_handler
) (
"U must be a square matrix"
);
68
69
return
retval;
70
}
Sparse::cols
octave_idx_type cols(void) const
Definition:
Sparse.h:264
Sparse::rows
octave_idx_type rows(void) const
Definition:
Sparse.h:263
MatrixType
Definition:
MatrixType.h:34
SparseComplexMatrix
Definition:
CSparse.h:49
SparseComplexMatrix::inverse
SparseComplexMatrix inverse(void) const
Definition:
CSparse.cc:733
MatrixType::Lower
Definition:
MatrixType.h:46
sparse_base_chol< SparseComplexMatrix, Complex, SparseMatrix >
SparseComplexMatrix::transpose
SparseComplexMatrix transpose(void) const
Definition:
CSparse.h:137
current_liboctave_error_handler
liboctave_error_handler current_liboctave_error_handler
Definition:
lo-error.c:38
MatrixType::type
int type(bool quiet=true)
Definition:
MatrixType.cc:963
chol2inv
SparseComplexMatrix chol2inv(const SparseComplexMatrix &r)
Definition:
SparseCmplxCHOL.cc:38
SparseCmplxCHOL.h
MatrixType::Upper
Definition:
MatrixType.h:45
sparse-base-chol.h
octave_idx_type
sparse-base-chol.cc
Generated on Thu Jun 4 2015 23:30:25 for GNU Octave by
1.8.8