47 #ifdef HAVE_FEI_AZTECOO
58 #define AZTEC_MPI AZTEC_MPI
66 #include <az_blas_wrappers.h>
72 namespace fei_trilinos {
81 int tmp1 = data_org[AZ_N_internal];
82 int tmp2 = data_org[AZ_N_border];
83 length_ = tmp1 + tmp2 + data_org[AZ_N_external];
85 localCoeffs_ =
new double[length_];
100 : amap_(source.amap_)
105 length_ = source.length_;
106 localCoeffs_ =
new double[length_];
120 int N_update =
amap_->localSize();
123 double *py = (
double*)y.startPointer();
125 double dot = AZ_gdot(N_update, pv, py,
amap_->getProcConfig());
136 for (
int i = 0; i <
length_; i++)
145 int N_update =
amap_->localSize();
158 int N_update =
amap_->localSize();
162 double *pc = (
double*)c.startPointer();
174 int N_update =
amap_->localSize();
184 int N_update =
amap_->localSize();
194 int offset =
amap_->localOffset();
204 int offset =
amap_->localOffset();
234 if ((
amap_->globalSize() != rhs.amap_->globalSize()) ||
235 (
amap_->localSize() != rhs.amap_->localSize()) ) {
237 <<
" Aborting assignment." <<
FEI_ENDL;
241 int N_update =
amap_->localSize();
242 double *pr = (
double*)rhs.startPointer();
244 for(
int i=0; i<N_update; ++i) {
261 int globalSize =
amap_->globalSize();
269 if (fileName == NULL) {
274 if (strstr(fileName,
".txt") != NULL) {
278 fei::console_out() <<
"Aztec_LSVector::readFromFile: fileName doesn't contain "
279 <<
"'.txt', assuming binary data..." <<
FEI_ENDL;
283 FILE *file = fopen(fileName,
"r");
290 if (fread((
char *)&nn,
sizeof(
int),1,file) != 1)
291 throw "fei_Aztec_LSVector.cpp: I/O error.";
292 if (fread((
char *)&nnz,
sizeof(
int),1,file) != 1)
293 throw "fei_Aztec_LSVector.cpp: I/O error.";
297 if (fgets(line,128,file) == NULL)
298 throw "fei_Aztec_LSVector.cpp: I/O error.";
299 }
while(strchr(line,
'%'));
300 sscanf(line,
"%d",&nn);
302 if (nn != globalSize) {
309 int start =
amap_->localOffset();
310 int end = start +
amap_->localSize() - 1;
312 while (!feof(file)) {
314 if (fread((
char *)&i,
sizeof(
int),1,file) != 1)
315 throw "fei_Aztec_LSVector.cpp: I/O error.";
316 if (fread((
char *)&value,
sizeof(
double),1,file) != 1)
317 throw "fei_Aztec_LSVector.cpp: I/O error.";
320 if (fgets(line,128,file) == NULL)
321 throw "fei_Aztec_LSVector.cpp: I/O error.";
322 sscanf(line,
"%d %le",&i,&value);
326 if ((start <= i) && (i <= end)) {
337 int N_update =
amap_->localSize();
338 int start =
amap_->localOffset();
340 int localRank =
amap_->getProcConfig()[AZ_node];
352 if (masterRank == localRank){
354 file = fopen(fileName,
"w");
357 fprintf(file,
"%d\n",
amap_->globalSize());
361 file = fopen(fileName,
"a");
365 for(i=0; i<N_update; i++) {
366 fprintf(file,
"%d %20.13e\n",start + i,
localCoeffs_[i]);
void PREFIX DSCAL_F77(const int *n, const double *alpha, double *x, const int *incx)
bool writeToFile(const char *fileName) const
Aztec_LSVector(fei::SharedPtr< Aztec_Map > map, int *data_org)
bool readFromFile(const char *fileName)
void PREFIX DAXPY_F77(const int *n, const double *alpha, const double x[], const int *incx, double y[], const int *incy)
void addVec(double s, const Aztec_LSVector &c)
Aztec_LSVector & operator=(const Aztec_LSVector &rhs)
fei::SharedPtr< Aztec_Map > amap_
double & operator[](int index)
virtual void assign(const Aztec_LSVector &rhs)
double dotProd(const Aztec_LSVector &y) const
Aztec_LSVector * newVector() const
std::ostream & console_out()
virtual ~Aztec_LSVector()
int numProcs(MPI_Comm comm)