Exemplo n.º 1
0
void blas_gemm(const MatrixXcd& a, const MatrixXcd& b, MatrixXcd& c)
{
  int M = c.rows(); int N = c.cols(); int K = a.cols();
  int lda = a.rows(); int ldb = b.rows(); int ldc = c.rows();

  zgemm_(&notrans,&notrans,&M,&N,&K,(double*)&cdone,
         const_cast<double*>((const double*)a.data()),&lda,
         const_cast<double*>((const double*)b.data()),&ldb,(double*)&cdone,
         (double*)c.data(),&ldc);
}
Exemplo n.º 2
0
complex<double> compute_Determinant(MatrixXcd& K) {
  FullPivLU<MatrixXcd> Kinverse;
  Kinverse.compute(K);
  complex<double> determinant;
  if (K.rows()>0) {        //      Check needed when the matrix is predominantly diagonal.
    MatrixXcd LU    =       Kinverse.matrixLU();
    determinant     =       log(LU(0,0));
    for (int k=1; k<K.rows(); ++k) {
      determinant+=log(LU(k,k));
    }
    //              Previous version which had some underflow.
    //              determinant	=	log(abs(K.determinant()));
  }
  return determinant;
};
Exemplo n.º 3
0
PyObject* calc_Gavg(PyObject *pyw, const double &delta, const double &mu, 
    PyObject *pySE, PyObject *pyTB, const double &Hf, PyObject *py_bp, 
    PyObject *py_wf, const int nthreads) {
  try {
    if (nthreads > 0) omp_set_num_threads(nthreads);
    MatrixXcd SE;
    VectorXcd w;
    VectorXd bp, wf;
    VectorXd SlaterKosterCoeffs;

    numpy::from_numpy(pySE, SE);
    numpy::from_numpy(pyTB, SlaterKosterCoeffs);
    numpy::from_numpy(py_bp, bp);
    numpy::from_numpy(py_wf, wf);
    numpy::from_numpy(pyw, w);
    assert(w.size() == SE.rows());

    double t = SlaterKosterCoeffs(0);
    VectorXd xl(DIM), xh(DIM);
    xl << -2*t;
    xh << 2*t;
    double BZ1 = 1.;

    MatrixXcd result(SE.rows(), MSIZE*MSIZE);
    VectorXcd tmp(MSIZE);
    GreenIntegrand green_integrand(w, mu, SE, SlaterKosterCoeffs, Hf);
    result.setZero();
    for (int n = 0; n < w.size(); ++n) {
      green_integrand.set_data(n);
      tmp = md_int::Integrate(xl, xh, green_integrand, bp, wf);
      for (int i = 0; i < MSIZE; ++i)
        result(n, MSIZE*i + i) = tmp(i);
    }
    result /= BZ1;
    return numpy::to_numpy(result);
  } catch (const char *str) {
      std::cerr << str << std::endl;
      return Py_None;
    }
}