00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include <BandSPDLinLapackSolver.h>
00037 #include <BandSPDLinSOE.h>
00038 #include <f2c.h>
00039 #include <math.h>
00040
00041
00042 BandSPDLinLapackSolver::BandSPDLinLapackSolver()
00043 :BandSPDLinSolver(SOLVER_TAGS_BandSPDLinLapackSolver)
00044 {
00045
00046 }
00047
00048 BandSPDLinLapackSolver::~BandSPDLinLapackSolver()
00049 {
00050
00051 }
00052
00053
00054 #ifdef _WIN32
00055 extern "C" int DPBSV(char *UPLO,
00056 int *N, int *KD, int *NRHS,
00057 double *A, int *LDA, double *B, int *LDB,
00058 int *INFO);
00059
00060 extern "C" int DPBTRS(char *UPLO,
00061 int *N, int *KD, int *NRHS,
00062 double *A, int *LDA, double *B, int *LDB,
00063 int *INFO);
00064 #else
00065
00066 extern "C" int dpbsv_(char *UPLO, int *N, int *KD, int *NRHS,
00067 double *A, int *LDA, double *B, int *LDB,
00068 int *INFO);
00069
00070 extern "C" int dpbtrs_(char *UPLO, int *N, int *KD, int *NRHS,
00071 double *A, int *LDA, double *B, int *LDB,
00072 int *INFO);
00073
00074 #endif
00075
00076
00077 int
00078 BandSPDLinLapackSolver::solve(void)
00079 {
00080 if (theSOE == 0) {
00081 opserr << "WARNING BandSPDLinLapackSolver::solve(void)- ";
00082 opserr << " No LinearSOE object has been set\n";
00083 return -1;
00084 }
00085
00086 int n = theSOE->size;
00087 int kd = theSOE->half_band -1;
00088 int ldA = kd +1;
00089 int nrhs = 1;
00090 int ldB = n;
00091 int info;
00092 double *Aptr = theSOE->A;
00093 double *Xptr = theSOE->X;
00094 double *Bptr = theSOE->B;
00095
00096
00097 for (int i=0; i<n; i++)
00098 *(Xptr++) = *(Bptr++);
00099 Xptr = theSOE->X;
00100
00101
00102
00103
00104
00105 #ifdef _WIN32
00106 if (theSOE->factored == false) {
00107
00108 unsigned int sizeC = 1;
00109 DPBSV("U", &n,&kd,&nrhs,Aptr,&ldA,Xptr,&ldB,&info);
00110 }
00111 else {
00112
00113 unsigned int sizeC = 1;
00114
00115 DPBTRS("U", &n,&kd,&nrhs,Aptr,&ldA,Xptr,&ldB,&info);
00116 }
00117 #else
00118 { if (theSOE->factored == false)
00119 dpbsv_("U",&n,&kd,&nrhs,Aptr,&ldA,Xptr,&ldB,&info);
00120 else
00121 dpbtrs_("U",&n,&kd,&nrhs,Aptr,&ldA,Xptr,&ldB,&info);
00122 }
00123 #endif
00124
00125
00126 if (info != 0) {
00127 opserr << "WARNING BandSPDLinLapackSolver::solve() - the LAPACK";
00128 opserr << " routines returned " << info << endln;
00129 return -info;
00130 }
00131
00132 theSOE->factored = true;
00133 return 0;
00134 }
00135
00136
00137
00138 int
00139 BandSPDLinLapackSolver::setSize()
00140 {
00141
00142 return 0;
00143 }
00144
00145 int
00146 BandSPDLinLapackSolver::sendSelf(int cTag,
00147 Channel &theChannel)
00148 {
00149
00150 return 0;
00151 }
00152
00153 int
00154 BandSPDLinLapackSolver::recvSelf(int tag,
00155 Channel &theChannel,
00156 FEM_ObjectBroker &theBroker)
00157 {
00158
00159 return 0;
00160 }
00161
00162
00163