Add C++11 interface (#117)
This commit is contained in:
committed by
Sylvestre Ledru
parent
d7deefda82
commit
74784a5309
@@ -63,6 +63,8 @@ endfunction(pexamples)
|
||||
if (ICB)
|
||||
enable_language(C CXX) # For testing binding with c/c++.
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
|
||||
|
||||
file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/PROG_ICB.f90
|
||||
"
|
||||
PROGRAM PROG_ICB
|
||||
|
||||
+184
-156
@@ -6,182 +6,210 @@
|
||||
* Note: to debug arpack, call debug_c.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include "arpack.hpp"
|
||||
#include <complex.h> // creal, cimag.
|
||||
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "debug_c.hpp" // debug arpack.
|
||||
#include "stat_c.hpp" // arpack statistics.
|
||||
#include "stat_c.hpp" // arpack statistics.
|
||||
|
||||
/* test program to solve for the 9 largest eigenvalues of
|
||||
* A*x = lambda*x where A is the diagonal matrix
|
||||
* with entries 1000, 999, ... , 2, 1 on the diagonal.
|
||||
* */
|
||||
*/
|
||||
#ifndef BLASINT
|
||||
#define BLASINT int
|
||||
#endif
|
||||
|
||||
void sMatVec(float * x, float * y) {
|
||||
int i;
|
||||
for ( i = 0; i < 1000; ++i)
|
||||
y[i] = ((float) (i+1))*x[i];
|
||||
};
|
||||
|
||||
int ss() {
|
||||
BLASINT ido = 0;
|
||||
std::string bmat("I");
|
||||
BLASINT N = 1000;
|
||||
std::string which("LM");
|
||||
BLASINT nev = 9;
|
||||
float tol = 0;
|
||||
float resid[N];
|
||||
BLASINT ncv = 2*nev+1;
|
||||
float V[ncv*N];
|
||||
BLASINT ldv = N;
|
||||
BLASINT iparam[11];
|
||||
BLASINT ipntr[14];
|
||||
float workd[3*N];
|
||||
bool rvec = true;
|
||||
std::string howmny("A");
|
||||
float* d = (float*) new float[(nev+1)];
|
||||
int select[ncv];
|
||||
float z[(N+1)*(nev+1)];
|
||||
BLASINT ldz = N+1;
|
||||
float sigma=0;
|
||||
int k;
|
||||
for (k=0; k < 3*N; ++k )
|
||||
workd[k] = 0;
|
||||
float workl[3*(ncv*ncv) + 6*ncv];
|
||||
for (k=0; k < 3*(ncv*ncv) + 6*ncv; ++k )
|
||||
workl[k] = 0;
|
||||
BLASINT lworkl = 3*(ncv*ncv) + 6*ncv;
|
||||
BLASINT info = 0;
|
||||
|
||||
iparam[0] = 1;
|
||||
iparam[2] = 10*N;
|
||||
iparam[3] = 1;
|
||||
iparam[4] = 0; // number of ev found by arpack.
|
||||
iparam[6] = 1;
|
||||
|
||||
while(ido != 99) {
|
||||
/* call arpack like you would have, but, use ssaupd_c instead of ssaupd_ */
|
||||
ssaupd_c(ido, bmat.c_str(), N, which.c_str(), nev, tol, resid, ncv, V, ldv, iparam, ipntr,
|
||||
workd, workl, lworkl, info);
|
||||
|
||||
sMatVec(&(workd[ipntr[0]-1]), &(workd[ipntr[1]-1]));
|
||||
}
|
||||
if (iparam[4] != nev) return 1; // check number of ev found by arpack.
|
||||
|
||||
/* call arpack like you would have, but, use sseupd_c instead of sseupd_ */
|
||||
sseupd_c(rvec, howmny.c_str(), select, d, z, ldz, sigma,
|
||||
bmat.c_str(), N, which.c_str(), nev, tol, resid, ncv, V, ldv, iparam, ipntr,
|
||||
workd, workl, lworkl, info);
|
||||
int i;
|
||||
for (i = 0; i < nev; ++i) {
|
||||
std::cout << d[i] << std::endl;
|
||||
if(fabs(d[i] - (float)(1000-(nev-1)+i))>1e-1){
|
||||
delete [] d;
|
||||
return 1;
|
||||
void diagonal_matrix_vector_product(float const* const x, float* const y)
|
||||
{
|
||||
for (int i = 0; i < 1000; ++i)
|
||||
{
|
||||
y[i] = static_cast<float>(i + 1) * x[i];
|
||||
}
|
||||
}
|
||||
delete [] d;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cMatVec(float _Complex * x, float _Complex * y) {
|
||||
int i;
|
||||
for (i = 0; i < 1000; ++i)
|
||||
y[i] = x[i] * (i+1.0f + _Complex_I * (i+1.0f));
|
||||
};
|
||||
void real_symmetric_runner()
|
||||
{
|
||||
BLASINT const N = 1000;
|
||||
BLASINT const nev = 9;
|
||||
|
||||
int cn() {
|
||||
BLASINT ido = 0;
|
||||
std::string bmat("I");
|
||||
BLASINT N = 1000;
|
||||
std::string which("LM");
|
||||
BLASINT nev = 9;
|
||||
float tol = 0;
|
||||
float _Complex resid[N];
|
||||
BLASINT ncv = 2*nev+1;
|
||||
float _Complex V[ncv*N];
|
||||
BLASINT ldv = N;
|
||||
BLASINT iparam[11];
|
||||
BLASINT ipntr[14];
|
||||
float _Complex workd[3*N];
|
||||
bool rvec = true;
|
||||
std::string howmny("A");
|
||||
float _Complex* d = (float _Complex*) new float _Complex[(nev+1)];
|
||||
int select[ncv];
|
||||
float _Complex z[(N+1)*(nev+1)];
|
||||
BLASINT ldz = N+1;
|
||||
float sigma=0;
|
||||
int k;
|
||||
for (k=0; k < 3*N; ++k )
|
||||
workd[k] = 0;
|
||||
float _Complex workl[3*(ncv*ncv) + 6*ncv];
|
||||
for (k=0; k < 3*(ncv*ncv) + 6*ncv; ++k )
|
||||
workl[k] = 0;
|
||||
BLASINT lworkl = 3*(ncv*ncv) + 6*ncv;
|
||||
float _Complex rwork[ncv];
|
||||
float _Complex workev[2*ncv];
|
||||
BLASINT info = 0;
|
||||
BLASINT const ncv = 2 * nev + 1;
|
||||
BLASINT const ldv = N;
|
||||
|
||||
iparam[0] = 1;
|
||||
iparam[2] = 10*N;
|
||||
iparam[3] = 1;
|
||||
iparam[4] = 0; // number of ev found by arpack.
|
||||
iparam[6] = 1;
|
||||
BLASINT const ldz = N + 1;
|
||||
|
||||
while(ido != 99) {
|
||||
/* call arpack like you would have, but, use cnaupd_c instead of cnaupd_ */
|
||||
cnaupd_c(ido, bmat.c_str(), N, which.c_str(), nev, tol, resid, ncv, V, ldv, iparam, ipntr,
|
||||
workd, workl, lworkl, rwork, info);
|
||||
BLASINT const lworkl = 3 * (ncv * ncv) + 6 * ncv;
|
||||
|
||||
cMatVec(&(workd[ipntr[0]-1]), &(workd[ipntr[1]-1]));
|
||||
}
|
||||
if (iparam[4] != nev) return 1; // check number of ev found by arpack.
|
||||
float const tol = 0.0f;
|
||||
float const sigma = 0.0f;
|
||||
|
||||
/* call arpack like you would have, but, use cneupd_c instead of cneupd_ */
|
||||
cneupd_c(rvec, howmny.c_str(), select, d, z, ldz, sigma, workev,
|
||||
bmat.c_str(), N, which.c_str(), nev, tol, resid, ncv, V, ldv, iparam, ipntr,
|
||||
workd, workl, lworkl, rwork, info);
|
||||
int i;
|
||||
for (i = 0; i < nev; ++i) {
|
||||
std::cout << creal(d[i]) << " " << cimag(d[i]) << std::endl;
|
||||
if(fabs(creal(d[i]) - (float)(1000-i))>1e-1 || fabs(cimag(d[i]) - (float)(1000-i))>1e-1){
|
||||
delete [] d;
|
||||
return 1;
|
||||
bool const rvec = true;
|
||||
|
||||
std::vector<float> resid(N);
|
||||
std::vector<float> V(ncv * N);
|
||||
std::vector<float> workd(3 * N, 0.0f);
|
||||
std::vector<float> workl(lworkl, 0.0f);
|
||||
std::vector<float> d((nev + 1));
|
||||
std::vector<float> z((N + 1) * (nev + 1));
|
||||
|
||||
std::array<BLASINT, 11> iparam{};
|
||||
|
||||
iparam[0] = 1;
|
||||
iparam[2] = 10 * N;
|
||||
iparam[3] = 1;
|
||||
iparam[4] = 0; // number of ev found by arpack.
|
||||
iparam[6] = 1;
|
||||
|
||||
std::array<BLASINT, 14> ipntr{};
|
||||
|
||||
BLASINT info = 0, ido = 0;
|
||||
|
||||
while (ido != 99)
|
||||
{
|
||||
/* call arpack like you would have, but, use ssaupd_c instead of ssaupd_ */
|
||||
arpack::saupd_c(ido, arpack::bmat::identity, N, arpack::which::largest_magnitude, nev, tol,
|
||||
resid.data(), ncv, V.data(), ldv, iparam.data(), ipntr.data(), workd.data(),
|
||||
workl.data(), lworkl, info);
|
||||
|
||||
diagonal_matrix_vector_product(&(workd[ipntr[0] - 1]), &(workd[ipntr[1] - 1]));
|
||||
}
|
||||
}
|
||||
delete [] d;
|
||||
return 0;
|
||||
|
||||
// check number of ev found by arpack.
|
||||
if (iparam[4] != nev || info != 0)
|
||||
{
|
||||
throw std::domain_error("Error inside ARPACK routines");
|
||||
}
|
||||
|
||||
std::vector<int> select(ncv);
|
||||
|
||||
/* call arpack like you would have, but, use sseupd_c instead of sseupd_ */
|
||||
arpack::seupd_c(rvec, arpack::howmny::ritz_vectors, select.data(), d.data(), z.data(), ldz,
|
||||
sigma, arpack::bmat::identity, N, arpack::which::largest_magnitude, nev, tol,
|
||||
resid.data(), ncv, V.data(), ldv, iparam.data(), ipntr.data(), workd.data(),
|
||||
workl.data(), lworkl, info);
|
||||
|
||||
for (int i = 0; i < nev; ++i)
|
||||
{
|
||||
std::cout << d[i] << "\n";
|
||||
|
||||
if (std::abs(d[i] - static_cast<float>(1000 - (nev - 1) + i)) > 1e-1)
|
||||
{
|
||||
throw std::domain_error("Correct eigenvalues not computed");
|
||||
}
|
||||
}
|
||||
std::cout << "------\n";
|
||||
}
|
||||
|
||||
int main() {
|
||||
sstats_c();
|
||||
int rc = ss(); // arpack without debug.
|
||||
if (rc != 0) return rc;
|
||||
int nopx_c, nbx_c, nrorth_c, nitref_c, nrstrt_c;
|
||||
float tsaupd_c, tsaup2_c, tsaitr_c, tseigt_c, tsgets_c, tsapps_c, tsconv_c;
|
||||
float tnaupd_c, tnaup2_c, tnaitr_c, tneigt_c, tngets_c, tnapps_c, tnconv_c;
|
||||
float tcaupd_c, tcaup2_c, tcaitr_c, tceigt_c, tcgets_c, tcapps_c, tcconv_c;
|
||||
float tmvopx_c, tmvbx_c, tgetv0_c, titref_c, trvec_c;
|
||||
stat_c( nopx_c, nbx_c, nrorth_c, nitref_c, nrstrt_c,
|
||||
tsaupd_c, tsaup2_c, tsaitr_c, tseigt_c, tsgets_c, tsapps_c, tsconv_c,
|
||||
tnaupd_c, tnaup2_c, tnaitr_c, tneigt_c, tngets_c, tnapps_c, tnconv_c,
|
||||
tcaupd_c, tcaup2_c, tcaitr_c, tceigt_c, tcgets_c, tcapps_c, tcconv_c,
|
||||
tmvopx_c, tmvbx_c, tgetv0_c, titref_c, trvec_c);
|
||||
std::cout << "Timers : nopx " << nopx_c << ", tmvopx " << tmvopx_c;
|
||||
std::cout << " - nbx " << nbx_c << ", tmvbx " << tmvbx_c << std::endl;
|
||||
|
||||
std::cout << "------" << std::endl;
|
||||
|
||||
debug_c(6, -6, 1,
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1); // set debug flags.
|
||||
rc = cn(); // arpack with debug.
|
||||
|
||||
return rc;
|
||||
void diagonal_matrix_vector_product(std::complex<float> const* const x, std::complex<float>* const y)
|
||||
{
|
||||
for (int i = 0; i < 1000; ++i)
|
||||
{
|
||||
y[i] = x[i] * std::complex<float>{i + 1.0f, i + 1.0f};
|
||||
}
|
||||
}
|
||||
|
||||
void complex_symmetric_runner()
|
||||
{
|
||||
BLASINT const N = 1000;
|
||||
BLASINT const nev = 9;
|
||||
|
||||
BLASINT const ncv = 2 * nev + 1;
|
||||
BLASINT const ldv = N;
|
||||
|
||||
BLASINT const ldz = N + 1;
|
||||
|
||||
BLASINT const lworkl = 3 * (ncv * ncv) + 6 * ncv;
|
||||
|
||||
float const tol = 0.0f;
|
||||
float const sigma = 0.0f;
|
||||
|
||||
bool const rvec = true;
|
||||
|
||||
std::vector<std::complex<float>> resid(N);
|
||||
std::vector<std::complex<float>> V(ncv * N);
|
||||
std::vector<std::complex<float>> workd(3 * N);
|
||||
std::vector<std::complex<float>> workl(lworkl);
|
||||
std::vector<std::complex<float>> d(nev + 1);
|
||||
std::vector<std::complex<float>> z((N + 1) * (nev + 1));
|
||||
std::vector<std::complex<float>> rwork(ncv);
|
||||
std::vector<std::complex<float>> workev(2 * ncv);
|
||||
|
||||
std::array<BLASINT, 11> iparam{};
|
||||
iparam[0] = 1;
|
||||
iparam[2] = 10 * N;
|
||||
iparam[3] = 1;
|
||||
iparam[4] = 0; // number of ev found by arpack.
|
||||
iparam[6] = 1;
|
||||
|
||||
std::array<BLASINT, 14> ipntr{};
|
||||
|
||||
BLASINT info = 0, ido = 0;
|
||||
|
||||
while (ido != 99)
|
||||
{
|
||||
/* call arpack like you would have, but, use cnaupd_c instead of cnaupd_ */
|
||||
arpack::naupd_c(ido, arpack::bmat::identity, N, arpack::which::largest_magnitude, nev, tol,
|
||||
resid.data(), ncv, V.data(), ldv, iparam.data(), ipntr.data(), workd.data(),
|
||||
workl.data(), lworkl, rwork.data(), info);
|
||||
|
||||
diagonal_matrix_vector_product(&(workd[ipntr[0] - 1]), &(workd[ipntr[1] - 1]));
|
||||
}
|
||||
|
||||
// check number of ev found by arpack.
|
||||
if (iparam[4] != nev || info != 0)
|
||||
{
|
||||
throw std::domain_error("Error inside ARPACK routines");
|
||||
}
|
||||
|
||||
std::vector<int> select(ncv);
|
||||
|
||||
/* call arpack like you would have, but, use cneupd_c instead of cneupd_ */
|
||||
arpack::neupd_c(rvec, arpack::howmny::ritz_vectors, select.data(), d.data(), z.data(), ldz, sigma,
|
||||
workev.data(), arpack::bmat::identity, N, arpack::which::largest_magnitude, nev,
|
||||
tol, resid.data(), ncv, V.data(), ldv, iparam.data(), ipntr.data(),
|
||||
workd.data(), workl.data(), lworkl, rwork.data(), info);
|
||||
|
||||
for (int i = 0; i < nev; ++i)
|
||||
{
|
||||
std::cout << d[i] << "\n";
|
||||
|
||||
if (std::abs(std::real(d[i]) - static_cast<float>(1000 - i)) > 1e-1
|
||||
|| std::abs(std::imag(d[i]) - static_cast<float>(1000 - i)) > 1e-1)
|
||||
{
|
||||
throw std::domain_error("Correct eigenvalues not computed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
sstats_c();
|
||||
|
||||
real_symmetric_runner(); // arpack without debug.
|
||||
|
||||
int nopx_c, nbx_c, nrorth_c, nitref_c, nrstrt_c;
|
||||
float tsaupd_c, tsaup2_c, tsaitr_c, tseigt_c, tsgets_c, tsapps_c, tsconv_c;
|
||||
float tnaupd_c, tnaup2_c, tnaitr_c, tneigt_c, tngets_c, tnapps_c, tnconv_c;
|
||||
float tcaupd_c, tcaup2_c, tcaitr_c, tceigt_c, tcgets_c, tcapps_c, tcconv_c;
|
||||
float tmvopx_c, tmvbx_c, tgetv0_c, titref_c, trvec_c;
|
||||
stat_c(nopx_c, nbx_c, nrorth_c, nitref_c, nrstrt_c, tsaupd_c, tsaup2_c, tsaitr_c, tseigt_c,
|
||||
tsgets_c, tsapps_c, tsconv_c, tnaupd_c, tnaup2_c, tnaitr_c, tneigt_c, tngets_c, tnapps_c,
|
||||
tnconv_c, tcaupd_c, tcaup2_c, tcaitr_c, tceigt_c, tcgets_c, tcapps_c, tcconv_c, tmvopx_c,
|
||||
tmvbx_c, tgetv0_c, titref_c, trvec_c);
|
||||
std::cout << "Timers : nopx " << nopx_c << ", tmvopx " << tmvopx_c;
|
||||
std::cout << " - nbx " << nbx_c << ", tmvbx " << tmvbx_c << std::endl;
|
||||
|
||||
std::cout << "------" << std::endl;
|
||||
|
||||
debug_c(6, -6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1); // set debug flags.
|
||||
|
||||
complex_symmetric_runner(); // arpack with debug.
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+300
-56
@@ -1,78 +1,322 @@
|
||||
#ifndef __ARPACK_HPP__
|
||||
#define __ARPACK_HPP__
|
||||
|
||||
#include <complex.h>
|
||||
#include <complex>
|
||||
|
||||
namespace arpack
|
||||
{
|
||||
enum class which : int {
|
||||
/// 'LA' - compute the NEV largest (algebraic) eigenvalues
|
||||
largest_algebraic,
|
||||
/// 'SA' - compute the NEV smallest (algebraic) eigenvalues.
|
||||
smallest_algebraic,
|
||||
/// 'LM' - compute the NEV largest (in magnitude) eigenvalues.
|
||||
largest_magnitude,
|
||||
/// 'SM' - compute the NEV smallest (in magnitude) eigenvalues.
|
||||
smallest_magnitude,
|
||||
/// 'BE' - compute NEV eigenvalues, half from each end of the
|
||||
/// spectrum. When NEV is odd, compute one more from the
|
||||
/// high end than from the low end.
|
||||
both_ends
|
||||
};
|
||||
|
||||
enum class bmat : int {
|
||||
/// B = 'I' -> standard eigenvalue problem A*x = lambda*x
|
||||
identity,
|
||||
/// B = 'G' -> generalized eigenvalue problem A*x = lambda*B*x
|
||||
generalized
|
||||
};
|
||||
|
||||
enum class howmny : int {
|
||||
/// 'A' Compute NEV Ritz vectors
|
||||
ritz_vectors,
|
||||
/// 'P' Compute NEV Schur vectors;
|
||||
schur_vectors,
|
||||
/// 'S' compute some of the Ritz vectors, specified by the logical array SELECT.
|
||||
ritz_specified
|
||||
};
|
||||
|
||||
namespace internal
|
||||
{
|
||||
/*
|
||||
* From C++, arpack does not exist.
|
||||
* Arpack is Fortran. ISO_C_BINDING is a gateway from Fortran to C, not C++. But, C++ can "get back" to C.
|
||||
* This is why you find C types in the arpack.hpp (C++ header) to be as safe as possible.
|
||||
*/
|
||||
extern "C" {
|
||||
void ssaupd_c(int& ido, const char* bmat, int n, const char* which, int nev, float tol,
|
||||
float* resid, int ncv, float* v, int ldv, int* iparam, int* ipntr, float* workd,
|
||||
float* workl, int lworkl, int& info);
|
||||
|
||||
extern "C" void ssaupd_c(int & ido, const char * bmat, int n, const char * which, int nev,
|
||||
float tol, float * resid, int ncv, float * v,
|
||||
int ldv, int * iparam, int * ipntr, float * workd,
|
||||
float * workl, int lworkl, int & info);
|
||||
void sseupd_c(bool rvec, const char* howmny, int* select, float* d, float* z, int ldz, float sigma,
|
||||
const char* bmat, int n, const char* which, int nev, float tol, float* resid, int ncv,
|
||||
float* v, int ldv, int* iparam, int* ipntr, float* workd, float* workl, int lworkl,
|
||||
int& info);
|
||||
|
||||
extern "C" void sseupd_c(bool rvec, const char * howmny, int * select, float * d, float * z, int ldz, float sigma,
|
||||
const char * bmat, int n, const char * which, int nev,
|
||||
float tol, float * resid, int ncv, float * v,
|
||||
int ldv, int * iparam, int * ipntr, float * workd,
|
||||
float * workl, int lworkl, int & info);
|
||||
void dsaupd_c(int& ido, const char* bmat, int n, const char* which, int nev, double tol,
|
||||
double* resid, int ncv, double* v, int ldv, int* iparam, int* ipntr, double* workd,
|
||||
double* workl, int lworkl, int& info);
|
||||
|
||||
extern "C" void dsaupd_c(int & ido, const char * bmat, int n, const char * which, int nev,
|
||||
double tol, double * resid, int ncv, double * v,
|
||||
int ldv, int * iparam, int * ipntr, double * workd,
|
||||
double * workl, int lworkl, int & info);
|
||||
void dseupd_c(bool rvec, const char* howmny, int* select, double* d, double* z, int ldz,
|
||||
double sigma, const char* bmat, int n, const char* which, int nev, double tol,
|
||||
double* resid, int ncv, double* v, int ldv, int* iparam, int* ipntr, double* workd,
|
||||
double* workl, int lworkl, int& info);
|
||||
|
||||
extern "C" void dseupd_c(bool rvec, const char * howmny, int * select, double * d, double * z, int ldz, double sigma,
|
||||
const char * bmat, int n, const char * which, int nev,
|
||||
double tol, double * resid, int ncv, double * v,
|
||||
int ldv, int * iparam, int * ipntr, double * workd,
|
||||
double * workl, int lworkl, int & info);
|
||||
void snaupd_c(int& ido, const char* bmat, int n, const char* which, int nev, float tol,
|
||||
float* resid, int ncv, float* v, int ldv, int* iparam, int* ipntr, float* workd,
|
||||
float* workl, int lworkl, int& info);
|
||||
|
||||
extern "C" void snaupd_c(int & ido, const char * bmat, int n, const char * which, int nev,
|
||||
float tol, float * resid, int ncv, float * v,
|
||||
int ldv, int * iparam, int * ipntr, float * workd,
|
||||
float * workl, int lworkl, int & info);
|
||||
void sneupd_c(bool rvec, const char* howmny, int* select, float* dr, float* di, float* z, int ldz,
|
||||
float sigmar, float sigmai, const char* bmat, int n, const char* which, int nev,
|
||||
float tol, float* resid, int ncv, float* v, int ldv, int* iparam, int* ipntr,
|
||||
float* workd, float* workl, int lworkl, int& info);
|
||||
|
||||
extern "C" void sneupd_c(bool rvec, const char * howmny, int * select, float * dr, float * di, float * z, int ldz, float sigmar, float sigmai,
|
||||
const char * bmat, int n, const char * which, int nev,
|
||||
float tol, float * resid, int ncv, float * v,
|
||||
int ldv, int * iparam, int * ipntr, float * workd,
|
||||
float * workl, int lworkl, int & info);
|
||||
void dnaupd_c(int& ido, const char* bmat, int n, const char* which, int nev, double tol,
|
||||
double* resid, int ncv, double* v, int ldv, int* iparam, int* ipntr, double* workd,
|
||||
double* workl, int lworkl, int& info);
|
||||
|
||||
extern "C" void dnaupd_c(int & ido, const char * bmat, int n, const char * which, int nev,
|
||||
double tol, double * resid, int ncv, double * v,
|
||||
int ldv, int * iparam, int * ipntr, double * workd,
|
||||
double * workl, int lworkl, int & info);
|
||||
void dneupd_c(bool rvec, const char* howmny, int* select, double* dr, double* di, double* z,
|
||||
int ldz, double sigmar, double sigmai, const char* bmat, int n, const char* which,
|
||||
int nev, double tol, double* resid, int ncv, double* v, int ldv, int* iparam,
|
||||
int* ipntr, double* workd, double* workl, int lworkl, int& info);
|
||||
|
||||
extern "C" void dneupd_c(bool rvec, const char * howmny, int * select, double * dr, double * di, double * z, int ldz, double sigmar, double sigmai,
|
||||
const char * bmat, int n, const char * which, int nev,
|
||||
double tol, double * resid, int ncv, double * v,
|
||||
int ldv, int * iparam, int * ipntr, double * workd,
|
||||
double * workl, int lworkl, int & info);
|
||||
void cnaupd_c(int& ido, const char* bmat, int n, const char* which, int nev, float tol,
|
||||
float _Complex* resid, int ncv, float _Complex* v, int ldv, int* iparam, int* ipntr,
|
||||
float _Complex* workd, float _Complex* workl, int lworkl, float _Complex* rwork,
|
||||
int& info);
|
||||
|
||||
extern "C" void cnaupd_c(int & ido, const char * bmat, int n, const char * which, int nev,
|
||||
float tol, float _Complex * resid, int ncv, float _Complex * v,
|
||||
int ldv, int * iparam, int * ipntr, float _Complex * workd,
|
||||
float _Complex * workl, int lworkl, float _Complex * rwork, int & info);
|
||||
void cneupd_c(bool rvec, const char* howmny, int* select, float _Complex* d, float _Complex* z,
|
||||
int ldz, float _Complex sigma, float _Complex* workev, const char* bmat, int n,
|
||||
const char* which, int nev, float tol, float _Complex* resid, int ncv,
|
||||
float _Complex* v, int ldv, int* iparam, int* ipntr, float _Complex* workd,
|
||||
float _Complex* workl, int lworkl, float _Complex* rwork, int& info);
|
||||
|
||||
extern "C" void cneupd_c(bool rvec, const char * howmny, int * select,
|
||||
float _Complex * d, float _Complex * z, int ldz, float _Complex sigma, float _Complex * workev,
|
||||
const char * bmat, int n, const char * which, int nev,
|
||||
float tol, float _Complex * resid, int ncv, float _Complex * v,
|
||||
int ldv, int * iparam, int * ipntr, float _Complex * workd,
|
||||
float _Complex * workl, int lworkl, float _Complex * rwork, int & info);
|
||||
void znaupd_c(int& ido, const char* bmat, int n, const char* which, int nev, double tol,
|
||||
double _Complex* resid, int ncv, double _Complex* v, int ldv, int* iparam, int* ipntr,
|
||||
double _Complex* workd, double _Complex* workl, int lworkl, double _Complex* rwork,
|
||||
int& info);
|
||||
|
||||
extern "C" void znaupd_c(int & ido, const char * bmat, int n, const char * which, int nev,
|
||||
double tol, double _Complex * resid, int ncv, double _Complex * v,
|
||||
int ldv, int * iparam, int * ipntr, double _Complex * workd,
|
||||
double _Complex * workl, int lworkl, double _Complex * rwork, int & info);
|
||||
void zneupd_c(bool rvec, const char* howmny, int* select, double _Complex* d, double _Complex* z,
|
||||
int ldz, double _Complex sigma, double _Complex* workev, const char* bmat, int n,
|
||||
const char* which, int nev, double tol, double _Complex* resid, int ncv,
|
||||
double _Complex* v, int ldv, int* iparam, int* ipntr, double _Complex* workd,
|
||||
double _Complex* workl, int lworkl, double _Complex* rwork, int& info);
|
||||
}
|
||||
|
||||
extern "C" void zneupd_c(bool rvec, const char * howmny, int * select,
|
||||
double _Complex * d, double _Complex * z, int ldz, double _Complex sigma, double _Complex * workev,
|
||||
const char * bmat, int n, const char * which, int nev,
|
||||
double tol, double _Complex * resid, int ncv, double _Complex * v,
|
||||
int ldv, int * iparam, int * ipntr, double _Complex * workd,
|
||||
double _Complex * workl, int lworkl, double _Complex * rwork, int & info);
|
||||
inline char const* convert_to_char(which const option)
|
||||
{
|
||||
switch (option)
|
||||
{
|
||||
case which::largest_algebraic:
|
||||
{
|
||||
return "LA";
|
||||
break;
|
||||
}
|
||||
case which::smallest_algebraic:
|
||||
{
|
||||
return "SA";
|
||||
break;
|
||||
}
|
||||
case which::largest_magnitude:
|
||||
{
|
||||
return "LM";
|
||||
break;
|
||||
}
|
||||
case which::smallest_magnitude:
|
||||
{
|
||||
return "SM";
|
||||
break;
|
||||
}
|
||||
case which::both_ends:
|
||||
{
|
||||
return "BE";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return "LM";
|
||||
}
|
||||
|
||||
inline char const* convert_to_char(bmat const option)
|
||||
{
|
||||
return option == bmat::identity ? "I" : "B";
|
||||
}
|
||||
|
||||
inline char const* convert_to_char(howmny const option)
|
||||
{
|
||||
switch (option)
|
||||
{
|
||||
case howmny::ritz_vectors:
|
||||
{
|
||||
return "A";
|
||||
break;
|
||||
}
|
||||
case howmny::schur_vectors:
|
||||
{
|
||||
return "P";
|
||||
break;
|
||||
}
|
||||
case howmny::ritz_specified:
|
||||
{
|
||||
return "S";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return "A";
|
||||
}
|
||||
}
|
||||
|
||||
inline void saupd_c(int& ido, bmat const bmat_option, int n, which const ritz_option, int nev,
|
||||
float tol, float* resid, int ncv, float* v, int ldv, int* iparam, int* ipntr,
|
||||
float* workd, float* workl, int lworkl, int& info)
|
||||
{
|
||||
internal::ssaupd_c(ido, internal::convert_to_char(bmat_option), n,
|
||||
internal::convert_to_char(ritz_option), nev, tol, resid, ncv, v, ldv, iparam,
|
||||
ipntr, workd, workl, lworkl, info);
|
||||
}
|
||||
|
||||
inline void seupd_c(bool rvec, howmny const howmny_option, int* select, float* d, float* z, int ldz,
|
||||
float sigma, bmat const bmat_option, int n, which const ritz_option, int nev,
|
||||
float tol, float* resid, int ncv, float* v, int ldv, int* iparam, int* ipntr,
|
||||
float* workd, float* workl, int lworkl, int& info)
|
||||
{
|
||||
internal::sseupd_c(rvec, internal::convert_to_char(howmny_option), select, d, z, ldz, sigma,
|
||||
internal::convert_to_char(bmat_option), n,
|
||||
internal::convert_to_char(ritz_option), nev, tol, resid, ncv, v, ldv, iparam,
|
||||
ipntr, workd, workl, lworkl, info);
|
||||
}
|
||||
|
||||
inline void saupd_c(int& ido, bmat const bmat_option, int n, which const ritz_option, int nev,
|
||||
double tol, double* resid, int ncv, double* v, int ldv, int* iparam, int* ipntr,
|
||||
double* workd, double* workl, int lworkl, int& info)
|
||||
{
|
||||
internal::dsaupd_c(ido, internal::convert_to_char(bmat_option), n,
|
||||
internal::convert_to_char(ritz_option), nev, tol, resid, ncv, v, ldv, iparam,
|
||||
ipntr, workd, workl, lworkl, info);
|
||||
}
|
||||
|
||||
inline void seupd_c(bool rvec, howmny const howmny_option, int* select, double* d, double* z,
|
||||
int ldz, double sigma, bmat const bmat_option, int n, which const ritz_option,
|
||||
int nev, double tol, double* resid, int ncv, double* v, int ldv, int* iparam,
|
||||
int* ipntr, double* workd, double* workl, int lworkl, int& info)
|
||||
{
|
||||
internal::dseupd_c(rvec, internal::convert_to_char(howmny_option), select, d, z, ldz, sigma,
|
||||
internal::convert_to_char(bmat_option), n,
|
||||
internal::convert_to_char(ritz_option), nev, tol, resid, ncv, v, ldv, iparam,
|
||||
ipntr, workd, workl, lworkl, info);
|
||||
}
|
||||
|
||||
inline void naupd_c(int& ido, bmat const bmat_option, int n, which const ritz_option, int nev,
|
||||
float tol, float* resid, int ncv, float* v, int ldv, int* iparam, int* ipntr,
|
||||
float* workd, float* workl, int lworkl, int& info)
|
||||
{
|
||||
internal::snaupd_c(ido, internal::convert_to_char(bmat_option), n,
|
||||
internal::convert_to_char(ritz_option), nev, tol, resid, ncv, v, ldv, iparam,
|
||||
ipntr, workd, workl, lworkl, info);
|
||||
}
|
||||
|
||||
inline void neupd_c(bool rvec, howmny const howmny_option, int* select, float* dr, float* di,
|
||||
float* z, int ldz, float sigmar, float sigmai, bmat const bmat_option, int n,
|
||||
which const ritz_option, int nev, float tol, float* resid, int ncv, float* v,
|
||||
int ldv, int* iparam, int* ipntr, float* workd, float* workl, int lworkl,
|
||||
int& info)
|
||||
{
|
||||
internal::sneupd_c(rvec, internal::convert_to_char(howmny_option), select, dr, di, z, ldz,
|
||||
sigmar, sigmai, internal::convert_to_char(bmat_option), n,
|
||||
internal::convert_to_char(ritz_option), nev, tol, resid, ncv, v, ldv, iparam,
|
||||
ipntr, workd, workl, lworkl, info);
|
||||
}
|
||||
|
||||
inline void naupd_c(int& ido, bmat const bmat_option, int n, which const ritz_option, int nev,
|
||||
double tol, double* resid, int ncv, double* v, int ldv, int* iparam, int* ipntr,
|
||||
double* workd, double* workl, int lworkl, int& info)
|
||||
{
|
||||
internal::dnaupd_c(ido, internal::convert_to_char(bmat_option), n,
|
||||
internal::convert_to_char(ritz_option), nev, tol, resid, ncv, v, ldv, iparam,
|
||||
ipntr, workd, workl, lworkl, info);
|
||||
}
|
||||
|
||||
inline void neupd_c(bool rvec, howmny const howmny_option, int* select, double* dr, double* di,
|
||||
double* z, int ldz, double sigmar, double sigmai, bmat const bmat_option, int n,
|
||||
which const ritz_option, int nev, double tol, double* resid, int ncv, double* v,
|
||||
int ldv, int* iparam, int* ipntr, double* workd, double* workl, int lworkl,
|
||||
int& info)
|
||||
{
|
||||
internal::dneupd_c(rvec, internal::convert_to_char(howmny_option), select, dr, di, z, ldz,
|
||||
sigmar, sigmai, internal::convert_to_char(bmat_option), n,
|
||||
internal::convert_to_char(ritz_option), nev, tol, resid, ncv, v, ldv, iparam,
|
||||
ipntr, workd, workl, lworkl, info);
|
||||
}
|
||||
|
||||
inline void naupd_c(int& ido, bmat const bmat_option, int n, which const ritz_option, int nev,
|
||||
float tol, std::complex<float>* resid, int ncv, std::complex<float>* v, int ldv,
|
||||
int* iparam, int* ipntr, std::complex<float>* workd, std::complex<float>* workl,
|
||||
int lworkl, std::complex<float>* rwork, int& info)
|
||||
{
|
||||
internal::cnaupd_c(ido, internal::convert_to_char(bmat_option), n,
|
||||
internal::convert_to_char(ritz_option), nev, tol,
|
||||
reinterpret_cast<_Complex float*>(resid), ncv,
|
||||
reinterpret_cast<_Complex float*>(v), ldv, iparam, ipntr,
|
||||
reinterpret_cast<_Complex float*>(workd),
|
||||
reinterpret_cast<_Complex float*>(workl), lworkl,
|
||||
reinterpret_cast<_Complex float*>(rwork), info);
|
||||
}
|
||||
|
||||
inline void neupd_c(bool rvec, howmny const howmny_option, int* select, std::complex<float>* d,
|
||||
std::complex<float>* z, int ldz, std::complex<float> sigma,
|
||||
std::complex<float>* workev, bmat const bmat_option, int n,
|
||||
which const ritz_option, int nev, float tol, std::complex<float>* resid,
|
||||
int ncv, std::complex<float>* v, int ldv, int* iparam, int* ipntr,
|
||||
std::complex<float>* workd, std::complex<float>* workl, int lworkl,
|
||||
std::complex<float>* rwork, int& info)
|
||||
{
|
||||
internal::cneupd_c(rvec, internal::convert_to_char(howmny_option), select,
|
||||
reinterpret_cast<_Complex float*>(d), reinterpret_cast<_Complex float*>(z),
|
||||
ldz, std::real(sigma) + std::imag(sigma) * I,
|
||||
reinterpret_cast<_Complex float*>(workev),
|
||||
internal::convert_to_char(bmat_option), n,
|
||||
internal::convert_to_char(ritz_option), nev, tol,
|
||||
reinterpret_cast<_Complex float*>(resid), ncv,
|
||||
reinterpret_cast<_Complex float*>(v), ldv, iparam, ipntr,
|
||||
reinterpret_cast<_Complex float*>(workd),
|
||||
reinterpret_cast<_Complex float*>(workl), lworkl,
|
||||
reinterpret_cast<_Complex float*>(rwork), info);
|
||||
}
|
||||
|
||||
inline void naupd_c(int& ido, bmat const bmat_option, int n, which const ritz_option, int nev,
|
||||
double tol, std::complex<double>* resid, int ncv, std::complex<double>* v,
|
||||
int ldv, int* iparam, int* ipntr, std::complex<double>* workd,
|
||||
std::complex<double>* workl, int lworkl, std::complex<double>* rwork, int& info)
|
||||
{
|
||||
internal::znaupd_c(ido, internal::convert_to_char(bmat_option), n,
|
||||
internal::convert_to_char(ritz_option), nev, tol,
|
||||
reinterpret_cast<_Complex double*>(resid), ncv,
|
||||
reinterpret_cast<_Complex double*>(v), ldv, iparam, ipntr,
|
||||
reinterpret_cast<_Complex double*>(workd),
|
||||
reinterpret_cast<_Complex double*>(workl), lworkl,
|
||||
reinterpret_cast<_Complex double*>(rwork), info);
|
||||
}
|
||||
|
||||
inline void neupd_c(bool rvec, howmny const howmny_option, int* select, std::complex<double>* d,
|
||||
std::complex<double>* z, int ldz, std::complex<double> sigma,
|
||||
std::complex<double>* workev, bmat const bmat_option, int n,
|
||||
which const ritz_option, int nev, double tol, std::complex<double>* resid,
|
||||
int ncv, std::complex<double>* v, int ldv, int* iparam, int* ipntr,
|
||||
std::complex<double>* workd, std::complex<double>* workl, int lworkl,
|
||||
std::complex<double>* rwork, int& info)
|
||||
{
|
||||
internal::zneupd_c(rvec, internal::convert_to_char(howmny_option), select,
|
||||
reinterpret_cast<_Complex double*>(d), reinterpret_cast<_Complex double*>(z),
|
||||
ldz, std::real(sigma) + _Complex_I * std::imag(sigma),
|
||||
reinterpret_cast<_Complex double*>(workev),
|
||||
internal::convert_to_char(bmat_option), n,
|
||||
internal::convert_to_char(ritz_option), nev, tol,
|
||||
reinterpret_cast<_Complex double*>(resid), ncv,
|
||||
reinterpret_cast<_Complex double*>(v), ldv, iparam, ipntr,
|
||||
reinterpret_cast<_Complex double*>(workd),
|
||||
reinterpret_cast<_Complex double*>(workl), lworkl,
|
||||
reinterpret_cast<_Complex double*>(rwork), info);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+2
-2
@@ -138,7 +138,7 @@ if test x"$enable_icb" != x"no"; then
|
||||
|
||||
AC_PROG_CC
|
||||
AC_PROG_CXX
|
||||
AX_CXX_COMPILE_STDCXX([11])
|
||||
AX_CXX_COMPILE_STDCXX(11, ext)
|
||||
AM_CONDITIONAL([ICB], [true])
|
||||
AC_CONFIG_FILES([arpack.h:arpack.h])
|
||||
AC_CONFIG_FILES([arpack.hpp:arpack.hpp])
|
||||
@@ -159,7 +159,7 @@ if test x"$enable_icb" != x"no"; then
|
||||
AC_LANG_PUSH([C++])
|
||||
AX_MPI([], AC_MSG_ERROR([could not compile a C++ MPI test program]))
|
||||
AC_SUBST([MPI_CXX_LIBS], ["$MPILIBS $FCLIBS"])
|
||||
CXX=$MPICXX
|
||||
CXX="$MPICXX -std=gnu++11"
|
||||
AC_LANG_POP([C++])
|
||||
|
||||
AC_LANG_PUSH([C])
|
||||
|
||||
Reference in New Issue
Block a user