LINEAR++ library: AFF to LAPACK
trfd.h
Go to the documentation of this file.
1 // LAPACK++ (V. 1.1)
2 // (C) 1992-1996 All Rights Reserved.
3 // Copyright (c) 1992 by J. J. Dongarra, E. Greaser, R. Pozo, D. Walker
4 // see file README.lapack++
5 
6 #ifndef _LA_TRIDIAG_FACT_DOUBLE_H_
7 #define _LA_TRIDIAG_FACT_DOUBLE_H_
8 
9 #include LA_VECTOR_LONG_INT_H
10 #include LA_TRIDIAG_MAT_DOUBLE_H
11 
12 #include "lapack.h"
13 
15 {
16  int size_;
17  LaTridiagMatDouble T_;
18  LaVectorLongInt pivot_;
19 
20 public:
21 
22  // constructor
23 
28 
29  LaTridiagMatDouble& T() { return T_; }
30  LaVectorLongInt& pivot() { return pivot_; }
31  int size() { return size_; }
32  LaVectorDouble diag(int);
33 
34  // operators
35 
36  LaTridiagFactDouble& ref(LaTridiagMatDouble &);
38  LaTridiagFactDouble& copy(const LaTridiagMatDouble &);
40 
41 };
42 
43 
44 
45  // constructor/destructor functions
46 
47 inline LaTridiagFactDouble::LaTridiagFactDouble():T_(),pivot_(),size_(0)
48 {}
49 
50 
51 inline LaTridiagFactDouble::LaTridiagFactDouble(int N):T_(N),pivot_(N),size_(N)
52 {}
53 
54 
56 {
57  T_.copy(F.T_);
58  pivot_.copy(F.pivot_);
59  size_ = F.size_;
60 }
61 
63 {}
64 
65  // member functions
66 
67 inline LaVectorDouble LaTridiagFactDouble::diag(int k)
68 {
69  return T_.diag(k);
70 }
71 
72  // operators
73 
74 
76 {
77  T_.ref(F.T_);
78  pivot_.ref(F.pivot_);
79  size_ = F.size_;
80 
81  return *this;
82 }
83 
84 inline LaTridiagFactDouble& LaTridiagFactDouble::ref(LaTridiagMatDouble& A)
85 {
86  T_.ref(A);
87 
88  return *this;
89 }
90 
92 {
93  T_.copy(F.T_);
94  pivot_.copy(F.pivot_);
95  size_ = F.size_;
96 
97  return *this;
98 }
99 
100 inline LaTridiagFactDouble& LaTridiagFactDouble::copy(const LaTridiagMatDouble& A)
101 {
102  T_.copy(A);
103 
104  return *this;
105 }
106 
107 inline void LaTridiagMatFactorize(LaTridiagMatDouble &A,
109 {
110  integer N = A.size(), info = 0;
111  AF.copy(A);
112  double *DL = &AF.diag(-1)(0), *D = &AF.diag(0)(0),
113  *DU = &AF.diag(1)(0), *DU2 = &AF.diag(2)(0);
114 
115 cerr << " \t*\n";
116 
117  F77NAME(dgttrf)(&N, DL, D, DU, DU2, &(AF.pivot()(0)), &info);
118 
119 cerr << " \t\t**\n";
120 }
121 
122 
123 inline void LaLinearSolve(LaTridiagFactDouble &AF, LaGenMatDouble &X,
124  LaGenMatDouble &B)
125 {
126  char trans = 'N';
127  integer N = AF.size(), nrhs = X.size(1), ldb = B.size(0), info = 0;
128  double *DL = &AF.diag(-1)(0), *D = &AF.diag(0)(0),
129  *DU = &AF.diag(1)(0), *DU2 = &AF.diag(2)(0);
130 
131  X.inject(B);
132  F77NAME(dgttrs)(&trans, &N, &nrhs, DL, D, DU, DU2, &(AF.pivot()(0)),
133  &X(0,0), &ldb, &info);
134 }
135 
136 #endif
137 // _LA_TRIDIAG_FACT_DOUBLE_H_
void F77NAME() dgttrs(char *trans, integer *N, integer *nrhs, doublereal *DL, doublereal *D, doublereal *DU, doublereal *DU2, integer *ipiv, doublereal *b, integer *ldb, integer *info)
void LaTridiagMatFactorize(LaTridiagMatDouble &A, LaTridiagFactDouble &AF)
Definition: trfd.h:107
LaVectorDouble diag(int)
Definition: trfd.h:67
LaVectorLongInt pivot_
Definition: trfd.h:18
LaTridiagFactDouble()
Definition: trfd.h:47
LaVectorLongInt & pivot()
Definition: trfd.h:30
long int integer
Definition: f77lapack.h:61
void LaLinearSolve(LaTridiagFactDouble &AF, LaGenMatDouble &X, LaGenMatDouble &B)
Definition: trfd.h:123
LaTridiagFactDouble & ref(LaTridiagMatDouble &)
Definition: trfd.h:84
LaTridiagMatDouble T_
Definition: trfd.h:17
void F77NAME() dgttrf(integer *N, doublereal *DL, doublereal *D, doublereal *DU, doublereal *DU2, integer *ipiv, integer *info)
LaTridiagFactDouble & copy(const LaTridiagMatDouble &)
Definition: trfd.h:100
#define F77NAME(x)
Definition: arch.h:17
LaTridiagMatDouble & T()
Definition: trfd.h:29
~LaTridiagFactDouble()
Definition: trfd.h:62