1 //      LAPACK++ (V. 1.1)
2 //      (C) 1992-1996 All Rights Reserved.
3 
4 
5 #ifndef _LA_SYMM_FACT_DOUBLE_H_
6 #define _LA_SYMM_FACT_DOUBLE_H_
7 
8 /** @file
9 
10     Deprecated. Class for the LU factorization of a matrix. Note: This
11     class is probably broken by design, because the matrices L and U
12     do not exist separately in the internal lapack but they are part
13     of the modified input matrix A.
14 
15     Do not use this unless you are really sure you understand what
16     this class does.
17 */
18 
19 #include "lafnames.h"
20 #include LA_VECTOR_INT_H
21 #include LA_SYMM_MAT_DOUBLE_H
22 
23 
24 #include "lapack.h"
25 
26 /** Class for the LU factorization of a matrix. Note: This class is
27     probably broken by design, because the matrices L and U do not
28     exist separately in the internal lapack but they are part of the
29     modified input matrix A.
30 
31     Do not use this unless you are really sure you understand what
32     this class does. */
33 class LaSymmFactDouble
34 {
35     LaSymmMatDouble             S_;
36     LaVectorLongInt             pivot_;
37     int                      info_;
38     char                     uplo_;
39     int                     size_;
40     int                     gdim_;
41 
42 public:
43 
44     // constructor
45 
46     inline LaSymmFactDouble();
47     inline LaSymmFactDouble(int, int);
48     inline LaSymmFactDouble(const LaSymmFactDouble &);
49     inline ~LaSymmFactDouble();
50 
51     // extraction functions for components
52 
S()53     inline LaSymmMatDouble& S()
54     {
55         return S_;
56     }
pivot()57     inline LaVectorLongInt& pivot()
58     {
59         return pivot_;
60     }
info()61     inline int info()
62     {
63         return info_;
64     }
uplo()65     inline char uplo()
66     {
67         return uplo_;
68     }
size()69     inline int size()
70     {
71         return size_;
72     }
gdim()73     inline int gdim()
74     {
75         return gdim_;
76     }
77 
78     // operators
79 
80     inline LaSymmFactDouble ref(LaSymmFactDouble &);
81     inline LaSymmFactDouble ref(LaSymmMatDouble &);
82     inline LaSymmFactDouble& copy(const LaSymmFactDouble &);
83     inline LaSymmFactDouble& copy(const LaSymmMatDouble &);
84 
85 };
86 
87 
88 
89 // constructor/destructor functions
90 
LaSymmFactDouble()91 inline LaSymmFactDouble::LaSymmFactDouble(): S_(), pivot_(), info_(0), uplo_('L')
92 {}
93 
94 
LaSymmFactDouble(int n,int m)95 inline LaSymmFactDouble::LaSymmFactDouble(int n, int m): S_(n, m), pivot_(n*m),
96     info_(0), uplo_('L')
97 {}
98 
99 
LaSymmFactDouble(const LaSymmFactDouble & F)100 inline LaSymmFactDouble::LaSymmFactDouble(const LaSymmFactDouble &F)
101 {
102     S_.copy(F.S_);
103     pivot_.copy(F.pivot_);
104     info_ = F.info_;
105     uplo_ = F.uplo_;
106     size_ = F.size_;
107     gdim_ = F.gdim_;
108 }
109 
~LaSymmFactDouble()110 inline LaSymmFactDouble::~LaSymmFactDouble()
111 {}
112 
113 // operators
114 
115 
ref(LaSymmFactDouble & F)116 inline LaSymmFactDouble LaSymmFactDouble::ref(LaSymmFactDouble& F)
117 {
118     S_.ref(F.S_);
119     pivot_.ref(F.pivot_);
120     info_ = F.info_;
121     uplo_ = F.uplo_;
122     size_ = F.size_;
123     gdim_ = F.gdim_;
124 
125     return *this;
126 }
127 
copy(const LaSymmFactDouble & F)128 inline LaSymmFactDouble& LaSymmFactDouble::copy(const LaSymmFactDouble& F)
129 {
130     S_.copy(F.S_);
131     pivot_.copy(F.pivot_);
132     info_ = F.info_;
133     uplo_ = F.uplo_;
134     size_ = F.size_;
135     gdim_ = F.gdim_;
136 
137     return *this;
138 }
139 
ref(LaSymmMatDouble & G)140 inline LaSymmFactDouble LaSymmFactDouble::ref(LaSymmMatDouble &G)
141 {
142     S_.ref(G);
143     info_ = 0;
144     uplo_ = 'L';
145     size_ = G.size(0);
146     gdim_ = G.gdim(0);
147 
148     return *this;
149 }
150 
copy(const LaSymmMatDouble & G)151 inline LaSymmFactDouble& LaSymmFactDouble::copy(const LaSymmMatDouble &G)
152 {
153     S_.copy(G);
154     info_ = 0;
155     uplo_ = 'L';
156     size_ = G.size(0);
157     gdim_ = G.gdim(0);
158 
159     return *this;
160 }
161 
162 #if 0
163 inline void LaSymmMatFactorize(LaSymmMatDouble &A, LaSymmFactDouble &AF)
164 {
165     char UPLO = 'L';
166     integer N = A.size(0), LDA = A.gdim(0), info = 0;
167 //    integer M = DSYTRF;
168 //    integer NB = F77NAME(get_nb)(&N,&M);
169 
170     integer LWORK = N * NB;
171     double *WORK = new double[LWORK];
172     LaVectorLongInt piv(N);
173     AF.pivot().copy(piv); // make copies of A and pivot information
174     AF.copy(A);
175 
176     F77NAME(dsytrf)(&UPLO, &N, &(AF.S()(0, 0)), &LDA, &(AF.pivot()(0)), WORK,
177                     &LWORK, &info);
178 
179     delete [] WORK;
180 }
181 #endif
LaLinearSolve(LaSymmFactDouble & AF,LaGenMatDouble & X,LaGenMatDouble & B)182 inline void LaLinearSolve(LaSymmFactDouble &AF, LaGenMatDouble &X,
183                           LaGenMatDouble &B)
184 {
185     char uplo = 'L';
186     integer N = AF.size(), nrhs = X.size(1), lda = AF.gdim(),
187             ldb = B.size(0), info = 0;
188 
189     X.inject(B);
190     F77NAME(dsytrs)(&uplo, &N, &nrhs, &(AF.S()(0, 0)), &lda,
191                     &(AF.pivot()(0)), &X(0, 0), &ldb, &info);
192 
193 }
194 
195 #endif
196 // _LA_SYMM_FACT_DOUBLE_H_
197