1 // Dominik Wagenfuehr <dominik.wagenfuehr@arcor.de>
2 // Copyright (C) 2006
3
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public License
6 // as published by the Free Software Foundation; either version 2, or
7 // (at your option) any later version.
8
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Lesser General Public License for more details.
13
14 // You should have received a copy of the GNU Lesser General Public License along
15 // with this library; see the file COPYING. If not, write to the Free
16 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 // USA.
18
19
20 // constructor/destructor functions
21
22 #ifdef HAVE_CONFIG_H
23 # include <config.h>
24 #endif
25
26 #include "lafnames.h"
27 #include LA_EXCEPTION_H
28 #include LA_SYMM_BAND_FACT_DOUBLE_H
29 #include "lapack.h"
30
31 /// Factorize a real-valued symmetric positive definite band matrix with Cholesky in-place.
LaSymmBandMatFactorizeIP(LaSymmBandMatDouble & A)32 void LaSymmBandMatFactorizeIP(LaSymmBandMatDouble &A)
33 {
34 char uplo = 'L';
35 integer n = A.size(1), kd = A.subdiags(), lda = A.gdim(0), info = 0;
36
37 F77NAME(dpbtrf)( &uplo, &n, &kd, &A(0, 0), &lda, &info);
38
39 LA_ASSERTZERO(info);
40 }
41
42 /// Factorize a real-valued symmetric positive definite band matrix with Cholesky.
LaSymmBandMatFactorize(const LaSymmBandMatDouble & A,LaSymmBandMatDouble & AF)43 void LaSymmBandMatFactorize(const LaSymmBandMatDouble &A,
44 LaSymmBandMatDouble& AF)
45 {
46 AF.copy(A);
47 LaSymmBandMatFactorizeIP(AF);
48 }
49
50 /// Solve A*X=B in-place where A is a real-valued symmetric positive definite band matrix.
LaLinearSolveIP(LaSymmBandMatDouble & A,LaGenMatDouble & B)51 void LaLinearSolveIP(LaSymmBandMatDouble &A, LaGenMatDouble &B)
52 {
53 assert (A.size(1) == B.size(0));
54
55 LaSymmBandMatFactorizeIP(A);
56
57 char uplo = 'L';
58 integer N = A.size(1);
59 integer KD = A.subdiags();
60 integer M = B.size(1);
61 integer lda = A.gdim(0);
62 integer ldb = B.gdim(0);
63 integer info = 0;
64
65 F77NAME(dpbtrs)(&uplo, &N, &KD, &M, &A(0, 0), &lda, &B(0, 0), &ldb, &info);
66
67 assert (info == 0);
68 }
69
70 /// Solve A*X=B where A is a real-valued symmetric positive definite band matrix.
LaLinearSolve(const LaSymmBandMatDouble A,LaGenMatDouble & X,const LaGenMatDouble & B)71 void LaLinearSolve(const LaSymmBandMatDouble A, LaGenMatDouble &X,
72 const LaGenMatDouble &B)
73 {
74 LaSymmBandMatDouble AF(A);
75 X.copy(B);
76 LaLinearSolveIP(AF, X);
77 }
78
79