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 _stdcall DPBSV(char *UPLO, unsigned int sizeUPLO,
00056 int *N, int *KD, int *NRHS,
00057 double *A, int *LDA, double *B, int *LDB,
00058 int *INFO);
00059
00060 extern "C" int _stdcall DPBTRS(char *UPLO, unsigned int sizeUPLO,
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 cerr << "WARNING BandSPDLinLapackSolver::solve(void)- ";
00082 cerr << " 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", sizeC, &n,&kd,&nrhs,Aptr,&ldA,Xptr,&ldB,&info);
00110 }
00111 else {
00112
00113 unsigned int sizeC = 1;
00114 DPBTRS("U", sizeC, &n,&kd,&nrhs,Aptr,&ldA,Xptr,&ldB,&info);
00115 }
00116 #else
00117 { if (theSOE->factored == false)
00118 dpbsv_("U",&n,&kd,&nrhs,Aptr,&ldA,Xptr,&ldB,&info);
00119 else
00120 dpbtrs_("U",&n,&kd,&nrhs,Aptr,&ldA,Xptr,&ldB,&info);
00121 }
00122 #endif
00123
00124
00125 if (info != 0) {
00126 cerr << "WARNING BandSPDLinLapackSolver::solve() - the LAPACK";
00127 cerr << " routines returned " << info << endl;
00128 return -info;
00129 }
00130
00131 theSOE->factored = true;
00132 return 0;
00133 }
00134
00135
00136
00137 int
00138 BandSPDLinLapackSolver::setSize()
00139 {
00140
00141 return 0;
00142 }
00143
00144 int
00145 BandSPDLinLapackSolver::sendSelf(int cTag,
00146 Channel &theChannel)
00147 {
00148
00149 return 0;
00150 }
00151
00152 int
00153 BandSPDLinLapackSolver::recvSelf(int tag,
00154 Channel &theChannel,
00155 FEM_ObjectBroker &theBroker)
00156 {
00157
00158 return 0;
00159 }
00160
00161
00162