Error function fortran 90 wo

1 #include

2 #include

3 #include "def.h"

4 #include "struct.h"

5 #include "internal_proto.h"

14 intevsl_nev_computed = 0, evsl_n = 0;

15 double * evsl_eigval_computed = NULL, * evsl_eigvec_computed = NULL;

16 

18 voidEVSLFORT (evsl_start) () {

19 EVSLStart ();

20 }

21 

23 voidEVSLFORT (evsl_finish) () {

24 EVSLFinish ();

25 }

26 

34 voidEVSLFORT (evsl_coo2csr) (int * n, int * nnz, int * ir, int * jc,

35 double * vv, uintptr_t * csrf90) {

36 cooMat coo;

37 coo.nrows = * n;

38 coo.ncols = * n;

39 coo.nnz = * nnz;

40 coo.ir = ir;

41 coo.jc = jc;

42 coo.vv = vv;

43 csrMat * csr;

44 Malloc (csr, 1, csrMat);

45 cooMat_to_csrMat (1, & coo, csr);

46 * csrf90 = (uintptr_t) csr;

47 }

48 

56 voidEVSLFORT (evsl_arr2csr) (int * n, int * ia, int * yes,

57 double * a, uintptr_t * csrf90) {

58 csrMat * csr;

59 Malloc (csr, 1, csrMat);

60 

61 csr-> owndata = 0;

62 csr-> nrows = * n;

63 csr-> ncols = * n;

64 csr-> ia = ia;

65 csr-> yes = yes;

66 csr-> a = a;

67 * csrf90 = (uintptr_t) csr;

68 }

69 

73 voidEVSLFORT (evsl_free_csr) (uintptr_t * csrf90) {

74 csrMat * csr = (csrMat *) (* csrf90);

75 free_csr (csr);

76 free (csr);

77 }

78 

82 voidEVSLFORT (evsl_seta_csr) (uintptr_t * Af90) {

83 csrMat * A = (csrMat *) (* Af90);

84 SetAMatrix (A);

85 }

86 

90 voidEVSLFORT (evsl_setb_csr) (uintptr_t * Bf90) {

91 csrMat * B = (csrMat *) (* Bf90);

92 SetBMatrix (B);

93 }

94 

100 voidEVSLFORT (evsl_setamv) (int * n, void * func, void * data) {

101 SetAMatvec (* n, (MVFunc) func, data);

102 }

103 

109 voidEVSLFORT (evsl_setbmv) (int * n, void * func, void * data) {

110 SetBMatvec (* n, (MVFunc) func, data);

111 }

112 

117 voidEVSLFORT (evsl_setbsol) (void * func, void * data) {

118 SetBSol ((SolFuncR) func, data);

119 }

120 

125 voidEVSLFORT (evsl_setltsol) (void * func, void * data) {

126 SetLTSol ((SolFuncR) func, data);

127 }

128 

130 voidEVSLFORT (evsl_set_geneig) () {

131 SetGenEig ();

132 }

133 

139 voidEVSLFORT (evsl_lanbounds) (int * nsteps, double * lmin, double * lmax) {

140 int n = evsldata.n;

141 double * vinit;

142 Malloc (vinit, n, double);

143 rand_double (n, vinit);

144 LanTrbounds (50, * nsteps, 1e-10, vinit, 1, lmin, lmax, NULL);

145 

146 free (vinitol);

147 }

148 

161 voidEVSLFORT (evsl_kpm_spslicer) (int * Mdeg, int * nvec, double * xintv,

162 int * nslices, double * sli, int * evint) {

163 int npts;

164 double * mu, ecount;

165 Malloc (mu, * Mdeg + 1, double);

166 kpmdos (* Mdeg, 1, * nvec, xintv, mu, & ecount);

167 fprintf (stdout, "estimated eig count in interval:% .15e \ n", ecount);

168 

169 npts = 10 * ecount;

170 int ierr = spslicer (sli, mu, * Mdeg, xintv, * nslices, npts);

171 if (ierr) {

172 printf ("spslicer error% d \ n", ierr);

173 exit (1);

174  }

175 * evint = (int) (1 + ecount / (* nslices));

176 free (mu);

177 }

178 

190 voidEVSLFORT (evsl_find_pol) (double * xintv, double * thresh_int,

191 double * thresh_ext, uintptr_t * polf90) {

192 polparams * pol;

193 malloc (pol, 1, polparams);

194 set_pol_def (pol);

195 pol-> damping = 2;

196 pol-> thresh_int = * thresh_int;

197 pol-> thresh_ext = * thresh_ext;

198 pol-> max_deg = 300;

199 find_pol (xintv, pol);

200 

201 fprintf (stdout, "polynomial deg% d, bar% e gam% e \ n",

202 pol-> deg, pol-> bar, pol-> gam);

203 

204 * polf90 = (uintptr_t) pol;

205 }

206 

211 voidEVSLFORT (evsl_free_pol) (uintptr_t * polf90) {

212 

213 polparams * pol = (polparams *) (* polf90);

214 free_pol (pol);

215 free (pol);

216 }

217 

227 voidEVSLFORT (evsl_find_rat) (double * intv, uintptr_t * ratf90) {

228 int pow = 2;

229 int num = 1;

230 double beta = 0.01;

231 ratparams * rat;

232 Malloc (rat, 1, ratparams);

233 set_ratf_def (rat);

234 rat-> pw = pow;

235 rat-> num = num;

236 rat-> beta = beta;

237 find_ratf (intv, rat);

238 

239 * ratf90 = (uintptr_t) rat;

240 }

241 

243 voidEVSLFORT (evsl_free_rat) (uintptr_t * ratf90) {

244 ratparams * rat = (ratparams *) (* ratf90);

245 free_rat (rat);

246 free (rat);

247 }

248 

252 voidEVSLFORT (evsl_cheblantr) (int * mlan, int * nev, double * xintv, int * max_its,

253 double * tol, uintptr_t * polf90) {

254 int n, nev2, ierr;

255 double * lam, * Y, * res;

256 FILE * fstats = stdout;

257 double * vinit;

258 

259 n = evsldata.n;

260 Malloc (vinit, n, double);

261 rand_double (n, vinit);

262 

263 

264 polparams * pol = (polparams *) (* polf90);

265 

266 ierr = ChebLanTr (* mlan, * nev, xintv, * max_its, * tol, vinit,

267 pol, & nev2, & lam, & Y, & res, fstats);

268 

269 ​​if (ierr) {

270 printf ("ChebLanTr error% d \ n", ierr);

271  }

272 

273 free (vinitol);

274 if (res) {

275 free (res);

276  }

277 

278 evsl_nev_computed = nev2;

279 evsl_n = n;

280 evsl_eigval_computed = lam;

281 evsl_eigvec_computed = Y;

282 }

283 

287 voidEVSLFORT (evsl_cheblannr) (double * xintv, int * max_its, double * tol,

288 uintptr_t * polf90) {

289 int n, nev2, ierr;

290 double * lam, * Y, * res;

291 FILE * fstats = stdout;

292 double * vinit;

293 

294 n = evsldata.n;

295 Malloc (vinit, n, double);

296 rand_double (n, vinit);

297 

298 

299 polparams * pol = (polparams *) (* polf90);

300 

301 ierr = ChebLanNr (xintv, * max_its, * tol, vinit,

302 pol, & nev2, & lam, & Y, & res, fstats);

303 

304 if (ierr) {

305 printf ("ChebLanNr error% d \ n", ierr);

306  }

307 

308 free (vinitol);

309 if (res) {

310 free (res);

311  }

312 

313 evsl_nev_computed = nev2;

314 evsl_n = n;

315 evsl_eigval_computed = lam;

316 evsl_eigvec_computed = Y;

317 }

318 

322 voidEVSLFORT (evsl_ratlannr) (double * xintv, int * max_its, double * tol,

323 uintptr_t * ratf90) {

324 int n, nev2, ierr;

325 double * lam, * Y, * res;

326 FILE * fstats = stdout;

327 double * vinit;

328 

329 n = evsldata.n;

330 Malloc (vinit, n, double);

331 rand_double (n, vinit);

332 

333 

334 ratparams * rat = (ratparams *) (* ratf90);

335 

336 ierr = RatLanNr (xintv, * max_its, * tol, vinit,

337 rat, & nev2, & lam, & Y, & res, fstats);

338 

339 if (ierr) {

340 printf ("RatLanNr error% d \ n", ierr);

341  }

342 

343 free (vinitol);

344 if (res) {

345 free (res);

346  }

347 

348 evsl_nev_computed = nev2;

349 evsl_n = n;

350 evsl_eigval_computed = lam;

351 evsl_eigvec_computed = Y;

352 }

353 

357 voidEVSLFORT (evsl_ratlantr) (int * lanm, int * nev, double * xintv,

358 int * max_its, double * tol, uintptr_t * ratf90) {

359 int n, nev2, ierr;

360 double * lam, * Y, * res;

361 FILE * fstats = stdout;

362 double * vinit;

363 

364 n = evsldata.n;

365 Malloc (vinit, n, double);

366 rand_double (n, vinit);

367 

368 

369 ratparams * rat = (ratparams *) (* ratf90);

370 

371 ierr = RatLanTr (* lanm, * nev, xintv, * max_its, * tol, vinit,

372 rat, & nev2, & lam, & Y, & res, fstats);

373 

374 if (ierr) {

375 printf ("RatLanNr error% d \ n", ierr);

376  }

377 

378 free (vinitol);

379 if (res) {

380 free (res);

381  }

382 

383 evsl_nev_computed = nev2;

384 evsl_n = n;

385 evsl_eigval_computed = lam;

386 evsl_eigvec_computed = Y;

387 }

388 

391 voidEVSLFORT (evsl_get_nev) (int * nev) {

392 * nev = evsl_nev_computed;

393 }

394 

398 voidEVSLFORT (evsl_copy_result) (double * val, double * vec) {

399 memcpy (val, evsl_eigval_computed, evsl_nev_computed * sizeof (double));

400 memcpy (vec, evsl_eigvec_computed, evsl_nev_computed * evsl_n * sizeof (double));

401 

402 evsl_nev_computed = 0;

403 evsl_n = 0;

404 free (evsl_eigval_computed);

405 free (evsl_eigvec_computed);

406 evsl_eigval_computed = NULL;

407 evsl_eigvec_computed = NULL;

408 }

409 

410 

411 

412 

kpmdos

int kpmdos (int Mdeg, int damping, int nvec, double * intv, double * mu, double * ecnt)

This function computes the coefficients of the density of states in the chebyshev basis ...

Definition:spslice.c: 32

evsl_find_pol

void EVSLFORT () evsl_find_pol (double * xintv, double * thresh_int, double * thresh_ext, uintptr_t * polf90)

Fortran interface for find_pol.

Definition:evsl_f90.c: 190

evsl_cheblannr

void EVSLFORT () evsl_cheblannr (double * xintv, int * max_its, double * tol, uintptr_t * polf90)

Fortran interface for ChebLanNr the results will be saved in the internal variables.

Definition:evsl_f90.c: 287

MVFunc

void (* MVFunc) (double * x, double * y, void * data)

matvec function prototype

Definition:struct.h: 96

SetGenEig

int SetGenEig ()

Set the problem to generalized eigenvalue problem.

Definition:possibly c: 158

ChebLanTr

int ChebLanTr (int lanm, int nev, double * intv, int maxit, double tol, double * vinit, polparams * pol, int * nev2, double ** vals, double ** W, double ** resW, FILE * fstats)

Chebyshev polynomial filtering Lanczos process [Thick restart version].

Definition:cheblanTr.c: 62

evsl_setb_csr

void EVSLFORT () evsl_setb_csr (uintptr_t * Bf90)

Fortran interface to set matrix B from a CSR matrix.

Definition:evsl_f90.c: 90

evsl_setbmv

void EVSLFORT () evsl_setbmv (int * n, void * func, void * data)

Fortran interface for SetBMatvec.

Definition:evsl_f90.c: 109

LanTrbounds

int LanTrbounds (int lanm, int maxit, double tol, double * vinit, int bndtype, double * lammin, double * lammax, FILE * fstats)

Lanczos process for eigenvalue bounds [Thick restart version].

Definition:lanTrbounds.c: 38

SetBMatvec

int SetBMatvec (int n, MVFunc func, void * data)

Set the user-input matvec routine and the associated data for B. Save them in evsldata.

Definition:possibly c: 117

evsl_setamv

void EVSLFORT () evsl_setamv (int * n, void * func, void * data)

Fortran interface for SetAMatvec.

Definition:evsl_f90.c: 100

evsl_kpm_spslicer

void EVSLFORT () evsl_kpm_spslicer (int * Mdeg, int * nvec, double * xintv, int * nslices, double * sli, int * evint)

Fortran interface for kpmdos and spslicer.

Definition:evsl_f90.c: 161

free_csr

void free_csr (csrMat * csr)

memory deallocation for csr matrix

Definition:spmat.c: 91

internal_proto.h

This file contains function prototypes and constant definitions internally used in EVSL ...

evsl_coo2csr

void EVSLFORT () evsl_coo2csr (int * n, int * nnz, int * ir, int * jc, double * vv, uintptr_t * csrf90)

Fortran interface to convert a COO matrix to CSR the pointer of CSR will be returned.

Definition:evsl_f90.c: 34

evsl_lanbounds

void EVSLFORT () evsl_lanbounds (int * nsteps, double * lmin, double * lmax)

Fortran interface for evsl_lanbounds.

Definition:evsl_f90.c: 139

RatLanNr

int RatLanNr (double * intv, int maxit, double tol, double * vinit, ratparams * rat, int * nevOut, double ** lamo, double ** Wo, double ** reso, FILE * fstats)

Rational filtering Lanczos process [NON-restarted version].

Definition:ratlan No. c: 54

SetLTSol

int SetLTSol (SolFuncR func, void * data)

Set the solve routine for LT.

Definition:possibly c: 185

SolFuncR

void (* SolFuncR) (double * b, double * x, void * data)

function prototype for applying the solve B x = b

Definition:struct.h: 91

_csrMat

sparse matrix format: the compressed sparse row (CSR) format, 0-based

Definition:struct.h: 31

evsl_ratlantr

void EVSLFORT () evsl_ratlantr (int * lanm, int * nev, double * xintv, int * max_its, double * tol, uintptr_t * ratf90)

Fortran interface for RatLanNr the results will be saved in the internal variables.

Definition:evsl_f90.c: 357

evsl_cheblantr

void EVSLFORT () evsl_cheblantr (int * mlan, int * nev, double * xintv, int * max_its, double * tol, uintptr_t * polf90)

Fortran interface for ChebLanTr the results will be saved in the internal variables.

Definition:evsl_f90.c: 252

ChebLan No.

int ChebLanNr (double * intv, int maxit, double tol, double * vinit, polparams * pol, int * nevOut, double ** lamo, double ** Wo, double ** reso, FILE * fstats)

Definition:cheblanNr.c: 60

SetBSol

int SetBSol (SolFuncR func, void * data)

Set the solve routine and the associated data for B.

Definition:possibly c: 132

evsl_seta_csr

void EVSLFORT () evsl_seta_csr (uintptr_t * Af90)

Fortran interface to set matrix A from a CSR matrix.

Definition:evsl_f90.c: 82

spslicer

int spslicer (double * sli, double * mu, int Mdeg, double * intv, int n_int, int npts)

given the dos function defined by mu find a partitioning of sub-interval [a, b] of the spectrum so eac ...

Definition:spslice.c: 204

RatLanTr

int RatLanTr (int lanm, int nev, double * intv, int maxit, double tol, double * vinit, ratparams * rat, int * nev2, double ** vals, double ** W, double ** resW, FILE * fstats)

RatLanTR filtering Lanczos process [Thick restart version].

Definition:ratlanTr.c: 61

evsl_ratlannr

void EVSLFORT () evsl_ratlannr (double * xintv, int * max_its, double * tol, uintptr_t * ratf90)

Fortran interface for RatLanNr the results will be saved in the internal variables.

Definition:evsl_f90.c: 322

evsl_arr2csr

void EVSLFORT () evsl_arr2csr (int * n, int * ia, int * ja, double * a, uintptr_t * csrf90)

Fortran interface to return a CSR struct from (ia, ja, a) the pointer of CSR will be returned ...

Definition:evsl_f90.c: 56

SetAMatvec

int SetAMatvec (int n, MVFunc func, void * data)

Set the user-input matvec routine and the associated data for A. Save them in evsldata.

Definition:possibly c: 100