Ejemplo n.º 1
0
parameters diagonalize_bisection(localized_matrix<double, MATRIX_MAJOR>& mat, double* eigvals,
				 rokko::parameters const& params) {
  rokko::parameters params_out;
  char jobz = 'N';  // only eigenvalues
  int dim = mat.outerSize();
  int ldim_mat = mat.innerSize();
  lapack_int m;  // output: found eigenvalues
  double abstol;
  get_key(params, "abstol", abstol);
  if (abstol < 0) {
    std::cerr << "Error in diagonalize_bisection" << std::endl
	      << "abstol is negative value, which means QR method." << std::endl
	      << "To use dsyevx as bisection solver, set abstol a positive value" << std::endl;
    throw;
  }
  if (!params.defined("abstol")) {  // default: optimal value for bisection method
    abstol = 2 * LAPACKE_dlamch('S');
  }
  params_out.set("abstol", abstol);
  char uplow = get_matrix_part(params);

  lapack_int il, iu;
  double vl, vu;
  char range = get_eigenvalues_range(params, vl, vu, il, iu);

  std::vector<lapack_int> ifail(dim);
  int info;
  if(mat.is_col_major())
    info = LAPACKE_dsyevx(LAPACK_COL_MAJOR, jobz, range, uplow, dim, &mat(0,0), ldim_mat, vl, vu, il, iu, abstol, &m, eigvals, NULL, ldim_mat, &ifail[0]);
  else
    info = LAPACKE_dsyevx(LAPACK_ROW_MAJOR, jobz, range, uplow, dim, &mat(0,0), ldim_mat, vl, vu, il, iu, abstol, &m, eigvals, NULL, ldim_mat, &ifail[0]);
  if (info) {
    std::cerr << "error at dsyevx function. info=" << info << std::endl;
    if (info < 0) {
      std::cerr << "This means that ";
      std::cerr << "the " << abs(info) << "-th argument had an illegal value." << std::endl;
    }
    exit(1);
  }
  params_out.set("m", m);
  params_out.set("ifail", ifail);
  
  if (params.get_bool("verbose")) {
    print_verbose("dsyevx (bisection)", jobz, range, uplow, vl, vu, il, iu, params_out);
  }

  return params_out;
}
Ejemplo n.º 2
0
void solve_entire_bi(int n, double *A, double *E, double *Q, char type){
  double tol = 0.;
  int *isuppz = malloc(2*n*sizeof(int)); assert(isuppz);
  int k;
  int info = LAPACKE_dsyevx(LAPACK_COL_MAJOR, type, 'A', 'L', 
			    n, A, n, 0., 0., 0, 0, tol, &k, E, Q, n, isuppz);
  assert(!info);
  free(isuppz);
}
Ejemplo n.º 3
0
void xx_eig(gsl_matrix *sym, gsl_vector *eval, gsl_matrix *evec, size_t NCOMP ){
  // simple Eigen decomposition with embedded cut
  size_t NSUB = sym->size1;
  lapack_int m=0;
  double abstol=-1.0, vl=0.0, vu=0.0;
  lapack_int *ifail = (lapack_int *)LAPACKE_malloc( sizeof(lapack_int) * NSUB );
  LAPACKE_dsyevx(LAPACK_ROW_MAJOR, 'V', 'I', 'U',
    NSUB, sym->data, NSUB, vl, vu, NSUB-NCOMP+1, NSUB,
    abstol, &m, eval->data, evec->data, NCOMP, ifail);
}