Example #1
0
void BasicOperator::mult_dirac(const Eigen::MatrixXcd& matrix,
                               Eigen::MatrixXcd& reordered, 
                               const size_t index) const {

  const vec_pdg_Corr op_Corr = global_data->get_lookup_corr();

  const size_t rows = matrix.rows();
  const size_t cols = matrix.cols();
  const size_t col = cols/4;
  if( (rows != reordered.rows()) || (cols != reordered.cols()) ){
    std::cout << "Error! In BasicOperator::mult_dirac: size of matrix and "
                 "reordered must be equal" << std::endl;
    exit(0);
  }

  for(const auto& dirac : op_Corr[index].gamma){
    if(dirac != 4){
      for(size_t block = 0; block < 4; block++){
        reordered.block(0, block * col, rows, col) = 
          gamma[dirac].value[block] *
          matrix.block(0, gamma[dirac].row[block]*col, rows, col);
      }
    }
  }

}
Example #2
0
//TODO complex values as matrix entries too
//TODO support endomorphisms over Rn too
Expression EigenvectorsCommand::operator()(const QList< Analitza::Expression >& args)
{
    Expression ret;
    
    QStringList errors;
    const Eigen::MatrixXcd eigeninfo = executeEigenSolver(args, true, errors);
    
    if (!errors.isEmpty()) {
        ret.addError(errors.first());
        
        return ret;
    }
    const int neigenvectors = eigeninfo.rows();
    
    QScopedPointer<Analitza::List> list(new Analitza::List);
    
    for (int j = 0; j < neigenvectors; ++j) {
        const Eigen::VectorXcd col = eigeninfo.col(j);
        QScopedPointer<Analitza::Vector> eigenvector(new Analitza::Vector(neigenvectors));
        
        for (int i = 0; i < neigenvectors; ++i) {
            const std::complex<double> eigenvalue = col(i);
            const double realpart = eigenvalue.real();
            const double imagpart = eigenvalue.imag();
            
            if (std::isnan(realpart) || std::isnan(imagpart)) {
                ret.addError(QCoreApplication::tr("Returned eigenvalue is NaN", "NaN means Not a Number, is an invalid float number"));
                return ret;
            } else if (std::isinf(realpart) || std::isinf(imagpart)) {
                ret.addError(QCoreApplication::tr("Returned eigenvalue is too big"));
                return ret;
            } else {
                bool isonlyreal = true;
                
                if (std::isnormal(imagpart)) {
                    isonlyreal = false;
                }
                
                Analitza::Cn * eigenvalueobj = 0;
                
                if (isonlyreal) {
                    eigenvalueobj = new Analitza::Cn(realpart);
                } else {
                    eigenvalueobj = new Analitza::Cn(realpart, imagpart);
                }
                
                eigenvector->appendBranch(eigenvalueobj);
            }
        }
        
        list->appendBranch(eigenvector.take());
    }
    
    ret.setTree(list.take());
    
    return ret;
}
Example #3
0
int main(int argc, char ** argv) {
  // initialize parameters /////////////////////////////////////////////////////
  Parameters p;

#ifdef DEBUG
  cout << "Memory usage of p: " << sizeof(p) << " bytes." << endl;

  Eigen::MatrixXcd H = p.Ham();

  cout << "size of Hamiltonian: " << H.rows() << "x" << H.cols() << endl;
  cout << "Hamiltonian: " << H << endl;
  cout << "Second element of Hamiltonian: " << p.Ham(0,1) << endl;
#endif

  // propagate /////////////////////////////////////////////////////////////////

  return 0;
}
Example #4
0
// TODO: work on interface with eigenvector class
// transform matrix of eigenvectors with gauge array
Eigen::MatrixXcd GaugeField::trafo_ev(const Eigen::MatrixXcd &eig_sys) {
  const ssize_t dim_row = eig_sys.rows();
  const ssize_t dim_col = eig_sys.cols();
  Eigen::MatrixXcd ret(dim_row, dim_col);
  if (omega.shape()[0] == 0)
    build_gauge_array(1);
  // write_gauge_matrices("ev_trafo_log.bin",Omega);

  for (ssize_t nev = 0; nev < dim_col; ++nev) {
    for (ssize_t vol = 0; vol < dim_row; ++vol) {
      int ind_c = vol % 3;
      Eigen::Vector3cd tmp =
          omega[0][ind_c].adjoint() * (eig_sys.col(nev)).segment(ind_c, 3);
      (ret.col(nev)).segment(ind_c, 3) = tmp;
    }  // end loop nev
  }    // end loop vol
  return ret;
}
Example #5
0
 inline int size_at() const { return coef_iat_ipn.rows(); }