OpenCAP
Electronic structure of metastable states
Macros | Functions
utils.h File Reference

Helper functions used by various pieces of the software. More...

#include <Eigen/Dense>
#include <map>

Go to the source code of this file.

Macros

#define M_PIl   3.141592653589793238462643383279502884
 
#define euler   2.718281828459045235360287471352662497
 

Functions

double fact2 (int n)
 
double fact (int n)
 
int parity (int i)
 
double binom (int p, int q)
 
std::vector< std::string > split (const std::string &s, char delimiter)
 
template<typename T >
void fill_mat (std::vector< T > &matrix_elements, Eigen::MatrixXd &opdm)
 
template<typename T >
void fill_LT (std::vector< T > matrix_elements, Eigen::MatrixXd &opdm)
 
void fortran_dfloats_to_efloats (std::string &str)
 
int shell2angmom (std::string angmom)
 
bool compare_strings (std::string s1, std::string s2)
 
bool is_number (const std::string &s)
 
bool is_letter (const std::string &s)
 
Eigen::MatrixXd read_matrix (size_t N, std::string filename)
 

Detailed Description

Helper functions used by various pieces of the software.

Macro Definition Documentation

◆ euler

#define euler   2.718281828459045235360287471352662497

◆ M_PIl

#define M_PIl   3.141592653589793238462643383279502884

Function Documentation

◆ binom()

double binom ( int  p,
int  q 
)

Computes binomial coefficient for P choose Q

Parameters
p: integer to be evaluated
q: integer to be evaluated

◆ compare_strings()

bool compare_strings ( std::string  s1,
std::string  s2 
)

Case insensitive comparison of two strings

◆ fact()

double fact ( int  n)

Computes factorial

Parameters
n: integer to be evaluated

◆ fact2()

double fact2 ( int  n)

Computes double factorial (https://mathworld.wolfram.com/DoubleFactorial.html)

Parameters
n: integer to be evaluated

◆ fill_LT()

template<typename T >
void fill_LT ( std::vector< T >  matrix_elements,
Eigen::MatrixXd &  opdm 
)

◆ fill_mat()

template<typename T >
void fill_mat ( std::vector< T > &  matrix_elements,
Eigen::MatrixXd &  opdm 
)

Populates symmetric matrix given list of elements read in row major order in lower triangular form

Parameters
matrix_elementslist of lower triangular matrix elements in row-major order
opdmmatrix to be populated

◆ fortran_dfloats_to_efloats()

void fortran_dfloats_to_efloats ( std::string &  str)

◆ is_letter()

bool is_letter ( const std::string &  s)

Checks if the string is a letter

◆ is_number()

bool is_number ( const std::string &  s)

Checks if the string is an integer

◆ parity()

int parity ( int  i)

Returns -1 if odd, 1 if even

Parameters
i: integer to be evaluated

◆ read_matrix()

Eigen::MatrixXd read_matrix ( size_t  N,
std::string  filename 
)

Reads formatted matrix from .txt file

◆ shell2angmom()

int shell2angmom ( std::string  angmom)

Converts angular momentum letter(s,p,d etc.) to quantum number l

◆ split()

std::vector<std::string> split ( const std::string &  s,
char  delimiter 
)

Helper function for splitting strings

Parameters
sstring to be split,
delimiterdelimiter for splitting
Returns
A vector containing the split string