示例#1
0
std::vector<typename MAT::type>
cal_det_as_vector(const O& creation_operators, const O& annihilation_operators, MAT& M, double BETA, const G& F) {
  typedef typename MAT::type SCALAR;

  const int size1 = creation_operators.size();

  if (size1 == 0) {
    throw std::runtime_error("size is zero in cal_det_as_vector");
  }

  assert(creation_operators.size() == annihilation_operators.size());

  Eigen::Matrix<SCALAR, Eigen::Dynamic, Eigen::Dynamic> matrix(size1, size1);
  construct_blas_matrix(matrix, creation_operators, annihilation_operators, BETA, F);

  Eigen::FullPivLU<Eigen::Matrix<SCALAR, Eigen::Dynamic, Eigen::Dynamic> > lu(matrix);
  std::vector<SCALAR> results(size1);
  for (int i = 0; i < size1; ++i) {
    results[i] = lu.matrixLU()(i,i);
  }
  results[0] *= lu.permutationP().determinant()*lu.permutationQ().determinant();

  M.destructive_resize(size1, size1);
  if (size1 > 0) {
    M.block() = matrix;
    M.safe_invert();
  }

  return results;
}
示例#2
0
double update_inverse_matrix_global_shift(const MAT & M, MAT & M_new, const operator_container_t &creation_operators,
                           const operator_container_t &annihilation_operators, double BETA, double dtau)
{
  typedef boost::tuple<double,int,double> key_t;
  typedef std::set<key_t> map_t;

  map_t annset, crset;
  double det_rat = 1.0;
  det_rat *= make_set_impl(annihilation_operators, BETA, dtau, annset);
  det_rat *= make_set_impl(creation_operators, BETA, dtau, crset);

  M_new.destructive_resize(M.size1(), M.size2());
  int row = -1;
  int column = -1;
  for (map_t::iterator ita = annset.begin(); ita != annset.end(); ita++) {
    column++;
    for (map_t::iterator itc = crset.begin(); itc != crset.end(); itc++) {
      row++;

      M_new(row, column) = M(boost::get<1>(*itc), boost::get<1>(*ita))*
        boost::get<2>(*itc)*boost::get<2>(*ita);
    }
    row = -1;
  }

  return det_rat;
}
示例#3
0
RET
cal_det(const O& creation_operators, const O& annihilation_operators, MAT& M, double BETA, const G& F) {
    typedef typename MAT::type SCALAR;

    const int size1 = creation_operators.size();

    if (size1==0) return RET(1.0);

    assert(creation_operators.size()==annihilation_operators.size());

    Eigen::Matrix<SCALAR,Eigen::Dynamic,Eigen::Dynamic> matrix(size1,size1);
    construct_blas_matrix(matrix, creation_operators, annihilation_operators, BETA, F);
    RET det = safe_determinant<RET>(matrix);

    M.destructive_resize(size1,size1);
    if (size1>0) {
      M.block() = matrix;
      M.safe_invert();
    }
    return det;
}