- 积分
- 0
- 注册时间
- 2004-11-12
- 仿真币
-
- 最后登录
- 1970-1-1
|
在网上看到了这样的例子(附后),下载了SparseLib++ 1.6版,但是编译下面的文件的时候提示:“COMPLEX没有定义”。编译器不认识COMPLEX这个结构(或类)。找遍了spareselib的所有头文件,没找到COMPLEX定义的地方;在VC的include目录下面也没找到。因此,我怀疑用VC在Windows2000下面是不是不能编译这个文件?这个SparseLIb++是不是用于linux的?
请用过的朋友指点一二。
另外:这个软件包运行的速度怎样?
#include <cstdlib>
#include <iostream>
#include "compcol_double.h"
#include "mvvtp.h"
#include "mvblasd.h"
#include "ilupre_double.h"
#include "gmres.h"
#include "spblas.h"
#include "mvm.h"
//#include MATRIX_H
//using namespace std;
int main(void)
{
double val[] = {10, 3, 3, 9, 7, 8, 4, 9, 8, 7, 7, 9, -2, 5, 9, 2, 3, 13, -1};
int row_ind[] = {0, 1, 3, 1, 2, 4, 5, 2, 3, 2, 3, 4, 0, 3, 4, 5, 1, 4, 5};
int col_ptr[] = {0, 3, 7, 9, 12, 16, 19};
int maxit = 150; // maximum iteration
int nUnknown = 6; // unknown, the size of Jacobi
int nNonZero = 19; // nonZero values in the matrix
int results;
int restart = 10; // restart iterations
double tol = 1.e-6; // convergence tolerance
CompCol_Mat_double Jacobi(nUnknown, nUnknown, nNonZero, val, row_ind, col_ptr);
//cout << Jacobi;
CompCol_ILUPreconditioner_double M(Jacobi); // construct preconditioner
MATRIX_double H(restart+1, restart, 0.0); // storage for upper Hessenberg H;
VECTOR_double xi(nUnknown, 0);
VECTOR_double rhs(nUnknown);
for(int i=0; i<nUnknown; i++) rhs(i) =i+1;
/**********************************************************************
* maxit AND tol WILL BE CHANGED AFTER ONE CALL OF GMRES, **
* SO FOR NEXT CALL, YOU SHOULD RESTORE THE OLD VALUE OF THEM **
***********************************************************************/
results = GMRES(Jacobi, xi, rhs, M, H, restart, maxit, tol); // call solver
cout << "GMRES flag = " << results << endl;
cout << "Iterations performed: " << maxit << endl;
cout << "Tolerance achieved :" << tol << endl;
for (i = 0; i < nUnknown; i ++){
cout <<"xi["<<i<<"]="<<xi<<"\n";
}
return results;
} |
|