Psi4
Files | Namespaces | Functions
libqt: The Quantum-Trio Miscellaneous Library

Files

file  3d_array.cc
 Routines for 3d arrays.
 
file  blas_intfc.cc
 The PSI3 BLAS1 interface routines.
 
file  blas_intfc23.cc
 Interface to all BLAS routinesAutogenerated by Rob Parrish on 1/24/2011.
 
file  blas_intfc23_mangle.h
 The PSI3 BLAS2 and BLAS3 interface routines.
 
file  blas_intfc_mangle.h
 The PSI3 BLAS1 interface routines.
 
file  cc_excited.cc
 Determine if a wavefunction is a CC-excited wavefunction type.
 
file  cc_wfn.cc
 Check if wavefunction is coupled-cluster type.
 
file  ci_wfn.cc
 Check if wavefunction is CI-type.
 
file  david.cc
 In-core Davidson-Liu diagonalization of symm matrices.
 
file  dirprd_block.cc
 Take a direct product of two matrices.
 
file  dot_block.cc
 Take dot product of two block matrices.
 
file  fill_sym_matrix.cc
 Fill a symmetric matrix from a lower triangle.
 
file  filter.cc
 Filter out unneeded frozen core/virt integrals.
 
file  invert.cc
 Invert a small matrix.
 
file  lapack_intfc.cc
 Interface to all LAPACK routinesAutogenerated by Rob Parrish on 1/23/2011.
 
file  lapack_intfc.h
 Interface to LAPACK routinesRollin A. King and T. Daniel Crawford August 2001 - January 2002.
 
file  lapack_intfc_mangle.h
 The PSI3 LAPACK interface routines.
 
file  mat_in.cc
 read in a matrix from an input stream (deprecated)
 
file  mat_print.cc
 Print a matrix to a file in a formatted style.
 
file  newmm_rking.cc
 Matrix multiplication routine (deprecated)
 
file  normalize.cc
 Normalize a set of vectors.
 
file  orient_fragment.cc
 function which places one fragment into the coordinate system of another
 
file  pople.cc
 Pople's method for solving linear equations.
 
file  probabil.cc
 Contains some probability functions.
 
file  qt.h
 Header file for the Quantum Trio LibraryDavid Sherrill 1994.
 
file  ras_set.cc
 Obtain orbital space and reordering for CI/MCSCF wavefunctions.
 
file  reorder_qt.cc
 Obtain the QT orbital reordering array between Pitzer and correlated order.
 
file  rootfind.cc
 Simple root finding methods
 (1) Bisection method
 (2) Newton's method
 (3) Secant method

.

 
file  schmidt.cc
 Gram-Schmidt orthogonalize a set of vectors.
 
file  libqt/schmidt_add.cc
 Gram-Schmidt orthogonalize vector and add to set.
 
file  slaterdset.cc
 Utility functions for importing/exporting sets of Slater determinants from the CI codesEdward Valeev, June 2002.
 
file  slaterdset.h
 Header file for SlaterDetSetsEdward Valeev, June 2002.
 
file  solve_pep.cc
 Solve a 2x2 pseudo-eigenvalue problem.
 
file  libqt/sort.cc
 Sort eigenvalues and eigenvectors into ascending order.
 
file  strncpy.cc
 Override strncpy to ensure strings are terminatedBy Edward Valeev.
 
file  timer.cc
 Obtain user and system timings for blocks of codeTIMER.CC: These functions allow one to obtain user and system timings for arbitrary blocks of code. If a code block is called repeatedly during the course of program execution, the timer functions will report the block's cumulative execution time and the number of calls. In addition, one may time multiple code blocks simultaneously, and even ``overlap'' timers. Timing data is written to the file "timer.dat" at the end of timer execution, i.e., when timer_done() is called.
 
file  v_3.cc
 simple functions for 3-vectors
 
file  zmat_point.cc
 xyz coordinates for three points and R, theta, and phi, returns the coordinates a fourth point; angles should enter function in degrees
 

Namespaces

 psi
 Rotate a set of vectors around an arbitrary axis Vectors are rows of input matrix.
 

Functions

double *** psi::init_3d_array (int p, int q, int r)
 
void psi::free_3d_array (double ***A, int p, int q)
 
void psi::C_DSWAP (unsigned long int length, double *x, int inc_x, double *y, int inc_y)
 
void psi::C_DAXPY (unsigned long int length, double a, double *x, int inc_x, double *y, int inc_y)
 
void psi::C_DCOPY (unsigned long int length, double *x, int inc_x, double *y, int inc_y)
 
void psi::C_DSCAL (unsigned long int length, double alpha, double *vec, int inc)
 
void psi::C_DROT (unsigned long int length, double *x, int inc_x, double *y, int inc_y, double costheta, double sintheta)
 
double psi::C_DDOT (unsigned long int length, double *x, int inc_x, double *y, int inc_y)
 
double psi::C_DNRM2 (unsigned long int length, double *x, int inc_x)
 
double psi::C_DASUM (unsigned long int length, double *x, int inc_x)
 
unsigned long int psi::C_IDAMAX (unsigned long int length, double *x, int inc_x)
 
int psi::cc_excited (const char *wfn)
 
int psi::cc_excited (std::string wfn)
 
int psi::cc_wfn (const char *wfn)
 
int psi::cc_wfn (std::string wfn)
 
int psi::ci_wfn (char *wfn)
 
int psi::ci_wfn (std::string wfn)
 
int psi::david (double **A, int N, int M, double *eps, double **v, double cutoff, int print)
 
void psi::dirprd_block (double **A, double **B, int rows, int cols)
 
double psi::dot_block (double **A, double **B, int rows, int cols, double alpha)
 
void psi::fill_sym_matrix (double **A, int size)
 
void psi::filter (double *input, double *output, int *ioff, int norbs, int nfzc, int nfzv)
 
double psi::invert_matrix (double **a, double **y, int N, std::string out)
 
int psi::C_DGEEV (int n, double **a, int lda, double *wr, double *wi, double **vl, int ldvl, double **vr, int ldvr, double *work, int lwork, int info)
 
int psi::C_DGESV (int n, int nrhs, double *a, int lda, int *ipiv, double *b, int ldb)
 
int psi::C_DGETRF (int m, int n, double *a, int lda, int *ipiv)
 
int psi::C_DPOTRF (char uplo, int n, double *a, int lda)
 
int psi::C_DGETRI (int n, double *a, int lda, int *ipiv, double *work, int lwork)
 
int psi::C_DPOTRI (char uplo, int n, double *a, int lda)
 
int psi::C_DPOTRS (char uplo, int n, int nrhs, double *a, int lda, double *b, int ldb)
 
int psi::C_DGESVD (char jobu, char jobvt, int m, int n, double *A, int lda, double *s, double *u, int ldu, double *vt, int ldvt, double *work, int lwork)
 
int psi::C_DSYEV (char jobz, char uplo, int n, double *a, int lda, double *w, double *work, int lwork)
 
int psi::mat_in (FILE *fp, double **array, int width, int max_length, int *stat)
 
int psi::mat_print (double **matrix, int rows, int cols, std::string out)
 
void psi::normalize (double **A, int rows, int cols)
 
int psi::pople (double **A, double *x, int dimen, int, double tolerance, std::string out, int print_lvl)
 
double psi::combinations (int n, int k)
 
double psi::factorial (int n)
 
int psi::ras_set3 (int nirreps, int nmo, int *orbspi, int *docc, int *socc, int *frdocc, int *fruocc, int *restrdocc, int *restruocc, int **ras_opi, int *core_guess, int *order, int ras_type, bool is_mcscf, Options &options)
 
int psi::ras_set (int nirreps, int nbfso, int freeze_core, int *orbspi, int *docc, int *socc, int *frdocc, int *fruocc, int **ras_opi, int *order, int ras_type)
 
int psi::ras_set2 (int nirreps, int nbfso, int delete_fzdocc, int delete_restrdocc, int *orbspi, int *docc, int *socc, int *frdocc, int *fruocc, int *restrdocc, int *restruocc, int **ras_opi, int *order, int ras_type, int hoffmann, Options &options)
 
void psi::reorder_qt (int *docc_in, int *socc_in, int *frozen_docc_in, int *frozen_uocc_in, int *order, int *orbs_per_irrep, int nirreps)
 
void psi::reorder_qt_uhf (int *docc, int *socc, int *frozen_docc, int *frozen_uocc, int *order_alpha, int *order_beta, int *orbspi, int nirreps)
 
double psi::bisect (double(*function)(double), double low, double high, double tolerance, int maxiter, int printflag)
 
double psi::newton (double(*F)(double), double(*dF)(double), double x, double tolerance, int maxiter, int printflag)
 
double psi::secant (double(*F)(double), double x0, double x1, double tolerance, int maxiter, int printflag)
 
void psi::schmidt (double **A, int rows, int cols, std::string OutFileRMR)
 
int psi::schmidt_add (double **A, int rows, int cols, double *v)
 
void psi::stringset_init (StringSet *sset, int size, int nelec, int ndrc, short int *drc_occ)
 
void psi::stringset_delete (StringSet *sset)
 
void psi::stringset_add (StringSet *sset, int index, unsigned char *Occ)
 
void psi::stringset_reindex (StringSet *sset, short int *mo_map)
 
void psi::stringset_write (ULI unit, const char *prefix, StringSet *sset)
 
void psi::stringset_read (ULI unit, const char *prefix, StringSet **stringset)
 
void psi::slaterdetset_init (SlaterDetSet *sdset, int size, StringSet *alphastrings, StringSet *betastrings)
 
void psi::slaterdetset_delete (SlaterDetSet *sdset)
 
void psi::slaterdetset_delete_full (SlaterDetSet *sdset)
 
void psi::slaterdetset_add (SlaterDetSet *sdset, int index, int alphastring, int betastring)
 
void psi::slaterdetset_write (ULI unit, const char *prefix, SlaterDetSet *sdset)
 
void psi::slaterdetset_read (ULI unit, const char *prefix, SlaterDetSet **slaterdetset)
 
void psi::slaterdetvector_init (SlaterDetVector *sdvector, SlaterDetSet *sdset)
 
void psi::slaterdetvector_delete (SlaterDetVector *sdvector)
 
void psi::slaterdetvector_delete_full (SlaterDetVector *sdvector)
 
void psi::slaterdetvector_add (SlaterDetVector *sdvector, int index, double coeff)
 
void psi::slaterdetvector_set (SlaterDetVector *sdvector, double *coeffs)
 
void psi::slaterdetvector_write (ULI unit, const char *prefix, SlaterDetVector *vector)
 
void psi::slaterdetset_write_vect (ULI unit, const char *prefix, double *coeffs, int size, int vectnum)
 
void psi::slaterdetvector_read (ULI unit, const char *prefix, SlaterDetVector **sdvector)
 
void psi::slaterdetset_read_vect (ULI unit, const char *prefix, double *coeffs, int size, int vectnum)
 
void psi::solve_2x2_pep (double **H, double S, double *evals, double **evecs)
 
void psi::sort_vector (double *A, int n)
 
void psi::timer_init (void)
 
void psi::timer_done (void)
 
struct timer * psi::timer_scan (const char *key)
 
void psi::timer_on (const char *key)
 
double psi::timer_nsdiff (struct timeval &endt, struct timeval &begint)
 
void psi::timer_off (const char *key)
 

Detailed Description

Function Documentation

double psi::bisect ( double(*)(double)  function,
double  low,
double  high,
double  tolerance,
int  maxiter,
int  printflag 
)

bisect(): Finds the root of a function between two points to within a given tolerance. Iterations are limited to a given maximum, and a print flag specifies whether this function should print the results of each iteration to stdout. Note that the values of the function at the two endpoints of the interval must have different signs for the bisection method to work! This routine checks for this initially.

Parameters
function= pointer to function we want to examine (must return double)
low= lower bound of interval to search for root
high= upper bound of interval
tolerance= how small is the maximum allowable error
maxiter= maximum number of iterations
printflag= whether or not to print results for each iteration (1 or 0)

Returns: the value of the root

double psi::C_DASUM ( unsigned long int  length,
double *  x,
int  inc_x 
)

This function returns the sum of the absolute value of this vector.

Parameters
lengthNumber of elements in x.
xA pointer to the beginning of the data in x. Must be of at least length (1+(N-1)*abs(inc_x).
inc_xhow many places to skip to get to next element in x
Returns
the sum of the absolute value
void psi::C_DAXPY ( unsigned long int  length,
double  a,
double *  x,
int  inc_x,
double *  y,
int  inc_y 
)

This function performs y = a * x + y.

Steps every inc_x in x and every inc_y in y (normally both 1).

Parameters
lengthlength of arrays
ascalar a to multiply vector x
xvector x
inc_xhow many places to skip to get to next element in x
yvector y
inc_yhow many places to skip to get to next element in y
void psi::C_DCOPY ( unsigned long int  length,
double *  x,
int  inc_x,
double *  y,
int  inc_y 
)

This function copies x into y.

Steps every inc_x in x and every inc_y in y (normally both 1).

Parameters
length= length of array
x= vector x
inc_x= how many places to skip to get to next element in x
y= vector y
inc_y= how many places to skip to get to next element in y
double psi::C_DDOT ( unsigned long int  length,
double *  x,
int  inc_x,
double *  y,
int  inc_y 
)

This function returns the dot product of two vectors, x and y.

Parameters
lengthNumber of elements in x and y.
xA pointer to the beginning of the data in x. Must be of at least length (1+(N-1)*abs(inc_x).
inc_xhow many places to skip to get to next element in x
yA pointer to the beginning of the data in y.
inc_yhow many places to skip to get to next element in y
Returns
the dot product
int psi::C_DGEEV ( int  n,
double **  a,
int  lda,
double *  wr,
double *  wi,
double **  vl,
int  ldvl,
double **  vr,
int  ldvr,
double *  work,
int  lwork,
int  info 
)

C_DGEEV()

This function computes the eigenvalues and the left and right right eigenvectors of a real, nonsymmetric matrix A. For symmetric matrices, refer to C_DSYEV().

Parameters
n= The order of the matrix A. n >= 0.
a= The n-by-n matrix A. As with all other lapack routines, must be allocated by contiguous memory (i.e., block_matrix()).
lda= The leading dimension of matrix A. lda >= max(1,n).
wr= array of length n containing the real parts of computed eigenvalues.
wi= array of length n containing the imaginary parts of computed eigenvalues.
vl= matrix of dimensions ldvl*n. The columns store the left eigenvectors u(j). If the j-th eigenvalues is real, then u(j) = vl(:,j), the j-th column of vl. If the j-th and (j+1)-st eigenvalues form a complex conjugate pair, then u(j) = vl(:,j) + i*vl(:,j+1) and u(j+1) = vl(:,j) - i*vl(:,j+1). Note: this is the Fortran documentation, may need to change cols <-> rows.
ldvl= The leading dimension of matrix vl.
vr= matrix of dimensions ldvr*n. The columns store the right eigenvectors v(j). If the j-th eigenvalues is real, then v(j) = vr(:,j), the j-th column of vr. If the j-th and (j+1)-st eigenvalues form a complex conjugate pair, then v(j) = vr(:,j) + i*vr(:,j+1) and v(j+1) = vr(:,j) - i*vr(:,j+1). Note: this is the Fortran documentation, may need to change cols <-> rows.
ldvr= The leading dimension of matrix vr.
work= Array for scratch computations, of dimension lwork. On successful exit, work[0] returns the optimal value of lwork.
lwork= The dimension of the array work. lwork >= max(1,3*n), and if eigenvectors are required (default for this wrapper at present) then actually lwork >= 4*n. For good performance, lwork must generally be larger. If lwork = -1, then a workspace query is assumed. The routine only calculates the optimal size of the work array, returns this value ans the first entry of the work array, and no error message related to lword is issued by xerbla.
info= On output (returned by C_DGEEV), a status flag. info = 0 for successful exit, if info = -i, the ith argument had an illegal value. If info = i, the QR algorithm failed to compute all the eigenvalues, and no eigenvectors have been computed. Elements i+1:n of wr and wi contain eigenvalues which have converged.
int psi::C_DGESV ( int  n,
int  nrhs,
double *  a,
int  lda,
int *  ipiv,
double *  b,
int  ldb 
)

Purpose

DGESV computes the solution to a real system of linear equations A * X = B, where A is an N-by-N matrix and X and B are N-by-NRHS matrices.

The LU decomposition with partial pivoting and row interchanges is used to factor A as A = P * L * U, where P is a permutation matrix, L is unit lower triangular, and U is upper triangular. The factored form of A is then used to solve the system of equations A * X = B.

Arguments

N (input) INTEGER The number of linear equations, i.e., the order of the matrix A. N >= 0.

NRHS (input) INTEGER The number of right hand sides, i.e., the number of columns of the matrix B. NRHS >= 0.

A (input/output) DOUBLE PRECISION array, dimension (LDA,N) On entry, the N-by-N coefficient matrix A. On exit, the factors L and U from the factorization A = P*L*U; the unit diagonal elements of L are not stored.

LDA (input) INTEGER The leading dimension of the array A. LDA >= max(1,N).

IPIV (output) INTEGER array, dimension (N) The pivot indices that define the permutation matrix P; row i of the matrix was interchanged with row IPIV(i).

B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) On entry, the N-by-NRHS matrix of right hand side matrix B. On exit, if INFO = 0, the N-by-NRHS solution matrix X.

LDB (input) INTEGER The leading dimension of the array B. LDB >= max(1,N).

C++ Return value: INFO (output) INTEGER = 0: successful exit < 0: if INFO = -i, the i-th argument had an illegal value > 0: if INFO = i, U(i,i) is exactly zero. The factorization has been completed, but the factor U is exactly singular, so the solution could not be computed.


.. External Subroutines ..

C_DGESV()

This function solves a system of linear equations A * X = B, where A is an n x n matrix and X and B are n x nrhs matrices.

Parameters
n= The number of linear equations, i.e., the order of the matrix A. n >= 0.
nrhs= The number of right hand sides, i.e., the number of columns of the matrix B. nrhs >= 0.
A= On entry, the n-by-n coefficient matrix A. On exit, the factors L and U from the factorization A = P*L*U; the unit diagonal elements of L are not stored.

lda = The leading dimension of the array A. lda >= max(1,n).

Parameters
intipiv = An integer array of length n. The pivot indices that define the permutation matrix P; row i of the matrix was interchanged with row ipiv(i).
B= On entry, the n-by-nrhs matrix of right hand side matrix B. On exit, if info = 0, the n-by-nrhs solution matrix X.
ldb= The leading dimension of the array B. ldb >= max(1,n).

Returns: int info. info = 0: successful exit. info < 0: if info = -i, the i-th argument had an illegal value. info > 0: if info = i, U(i,i) is exactly zero. The factorization has been completed, but the factor U is exactly singular, so the solution could not be computed.

int psi::C_DGESVD ( char  jobu,
char  jobvt,
int  m,
int  n,
double *  A,
int  lda,
double *  s,
double *  u,
int  ldu,
double *  vt,
int  ldvt,
double *  work,
int  lwork 
)

C_DGESVD() This function computes the singular value decomposition (SVD) of a real mxn matrix A, ** optionally computing the left and/or right singular vectors. The SVD is written

A = U * S * transpose(V)

where S is an mxn matrix which is zero except for its min(m,n) diagonal elements, U is an M-by-M orthogonal matrix, and V is an N-by-N orthogonal matrix. The diagonal elements of SIGMA are the singular values of A; they are real and non-negative, and are returned in descending order. The first min(m,n) columns of U and V are the left and right singular vectors of A.

Note that the routine returns V^t, not V;

These arguments mimic their Fortran counterparts. See the LAPACK manual for additional information.

Parameters
jobu= 'A' = all m columns of U are returned 'S' = the first min(m,n) columns of U are returned 'O' = the first min(m,n) columns of U are returned in the input matrix A 'N' = no columns of U are returned
jobvt= 'A' = all n rows of VT are returned 'S' = the first min(m,n) rows of VT are returned 'O' = the first min(m,n) rows of VT are returned in the input matrix A 'N' = no rows of VT are returned

Obviously jobu and jobvt cannot both be 'O'.

Parameters
m= The row dimension of the matrix A.
n= The column dimension of the matrix A.
A= On entry, the mxn matrix A with dimensions m by lda. On exit, if jobu='O' the first min(m,n) columns of A are overwritten with the left singular vectors; if jobvt='O' the first min(m,n) rows of A are overwritten with the right singular vectors; otherwise, the contents of A are destroyed.
lda= The number of columns allocated for A.
s= The singular values of A.
u= The right singular vectors of A, returned as column of the matrix u if jobu='A'. If jobu='N' or 'O', u is not referenced.
ldu= The number of columns allocated for u.
vt= The left singular vectors of A, returned as rows of the matrix VT is jobvt='A'. If jobvt='N' or 'O', vt is not referenced.
ldvt= The number of columns allocated for vt.
work= Workspace array of length lwork.
lwork= The length of the workspace array work, which should be at least as large as max(3*min(m,n)+max(m,n),5*min(m,n)). For good performance, lwork should generally be larger. If lwork=-1, a workspace query is assumed, and the value of work[0] upon return is the optimal size of the work array.

Return value: int info. If info=0, successful exit. If info = -i, the i-th argument had an illegal value. If info > 0, Related to failure in the convergence of the upper bidiagonal matrix B. See the LAPACK manual for additiona information.

Interface written by TDC, July 2001, updated April 2004

int psi::C_DGETRF ( int  m,
int  n,
double *  a,
int  lda,
int *  ipiv 
)

Purpose

DGETRF computes an LU factorization of a general M-by-N matrix A using partial pivoting with row interchanges.

The factorization has the form A = P * L * U where P is a permutation matrix, L is lower triangular with unit diagonal elements (lower trapezoidal if m > n), and U is upper triangular (upper trapezoidal if m < n).

This is the right-looking Level 3 BLAS version of the algorithm.

Arguments

M (input) INTEGER The number of rows of the matrix A. M >= 0.

N (input) INTEGER The number of columns of the matrix A. N >= 0.

A (input/output) DOUBLE PRECISION array, dimension (LDA,N) On entry, the M-by-N matrix to be factored. On exit, the factors L and U from the factorization A = P*L*U; the unit diagonal elements of L are not stored.

LDA (input) INTEGER The leading dimension of the array A. LDA >= max(1,M).

IPIV (output) INTEGER array, dimension (min(M,N)) The pivot indices; for 1 <= i <= min(M,N), row i of the matrix was interchanged with row IPIV(i).

C++ Return value: INFO (output) INTEGER = 0: successful exit < 0: if INFO = -i, the i-th argument had an illegal value > 0: if INFO = i, U(i,i) is exactly zero. The factorization has been completed, but the factor U is exactly singular, and division by zero will occur if it is used to solve a system of equations.


.. Parameters ..

C_DGETRF(): Compute an LU factorization of a general M-by-N matrix a using partial pivoting with row interchanges.

The factorization has the form A = P * L * U where P is a permutation matrix, L is lower triangular with unit diagonal elements (lower trapezoidal if nrow > ncol), and U is upper triangular (upper trapezoidal if nrow < ncol).

Parameters
nrow= number of rows
ncol= number of colums
a= matrix to factorize
lda= leading dimension of a, lda >= max(1,ncol)
ipiv= output integer array of the pivot indices; for 1 <= i <= min(nrow, ncol), col i of the matrix was interchanged with col ipiv(i).

Returns: int info. info = 0: successful exit. info < 0: if info=-i, the ith-argument had an illegal vale. info>0: if info=i, U(i,i) is exactly zero. The factorization has been completed, but the factor U is exactly singular, and division by zero will occur if it is used to solve a system of equations.

int psi::C_DGETRI ( int  n,
double *  a,
int  lda,
int *  ipiv,
double *  work,
int  lwork 
)

Purpose

DGETRI computes the inverse of a matrix using the LU factorization computed by DGETRF.

This method inverts U and then computes inv(A) by solving the system inv(A)*L = inv(U) for inv(A).

Arguments

N (input) INTEGER The order of the matrix A. N >= 0.

A (input/output) DOUBLE PRECISION array, dimension (LDA,N) On entry, the factors L and U from the factorization A = P*L*U as computed by DGETRF. On exit, if INFO = 0, the inverse of the original matrix A.

LDA (input) INTEGER The leading dimension of the array A. LDA >= max(1,N).

IPIV (input) INTEGER array, dimension (N) The pivot indices from DGETRF; for 1<=i<=N, row i of the matrix was interchanged with row IPIV(i).

WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) On exit, if INFO=0, then WORK(1) returns the optimal LWORK.

LWORK (input) INTEGER The dimension of the array WORK. LWORK >= max(1,N). For optimal performance LWORK >= N*NB, where NB is the optimal blocksize returned by ILAENV.

If LWORK = -1, then a workspace query is assumed; the routine only calculates the optimal size of the WORK array, returns this value as the first entry of the WORK array, and no error message related to LWORK is issued by XERBLA.

C++ Return value: INFO (output) INTEGER = 0: successful exit < 0: if INFO = -i, the i-th argument had an illegal value > 0: if INFO = i, U(i,i) is exactly zero; the matrix is singular and its inverse could not be computed.


.. Parameters ..

C_DGETRI(): computes the inverse of a matrix using the LU factorization computed by DGETRF

This method inverts U and then computes inv(A) by solving the system inv(A)*L = inv(U) for inv(A).

Parameters
n= order of the matrix a. n >= 0.
a= array of dimension (n,lda). On entry, the factors L and U from the factorization A = P*L*U as computed by DGETRF. On exit, if info=0, the inverse of hte original matrix A.
lda= the leading dimension of the array a. lda >= max(1,n).
ipiv= The pivot indices from DGETRF. For 1<=i<=n, row i of the matrix was interchanged with row ipiv(i)
work= workspace of dimension max(1,lwork). On exit, if info=0, then work(0) returns the optimal lwork.
lwork= the dimension of the array work. lwork >= max(1,n). For optimal performance, lwork > n*nb, where nb is the optimal blocksize returned by ilaenv. If lwork=-1, then a workspace query is assumed; the routine only calculates the optimal size of the work array, returns this value as the first entry of the work array, and no error message related to lwork is issued by xerbla.

Returns: int info. info=0: successful exit. info<0: if info=-i, the i-th argument had an illegal value. info>0: if info=i, U(i,i) is exactly zero; the matrix is singular and its inverse could not be computed.

double psi::C_DNRM2 ( unsigned long int  length,
double *  x,
int  inc_x 
)

This function returns the square of the norm of this vector.

Parameters
lengthNumber of elements in x.
xA pointer to the beginning of the data in x. Must be of at least length (1+(N-1)*abs(inc_x).
inc_xhow many places to skip to get to next element in x
Returns
the norm squared product
int psi::C_DPOTRF ( char  uplo,
int  n,
double *  a,
int  lda 
)

Purpose

DPOTRF computes the Cholesky factorization of a real symmetric positive definite matrix A.

The factorization has the form A = U**T * U, if UPLO = 'U', or A = L * L**T, if UPLO = 'L', where U is an upper triangular matrix and L is lower triangular.

This is the block version of the algorithm, calling Level 3 BLAS.

Arguments

UPLO (input) CHARACTER*1 = 'U': Upper triangle of A is stored; = 'L': Lower triangle of A is stored.

N (input) INTEGER The order of the matrix A. N >= 0.

A (input/output) DOUBLE PRECISION array, dimension (LDA,N) On entry, the symmetric matrix A. If UPLO = 'U', the leading N-by-N upper triangular part of A contains the upper triangular part of the matrix A, and the strictly lower triangular part of A is not referenced. If UPLO = 'L', the leading N-by-N lower triangular part of A contains the lower triangular part of the matrix A, and the strictly upper triangular part of A is not referenced.

On exit, if INFO = 0, the factor U or L from the Cholesky factorization A = U**T*U or A = L*L**T.

LDA (input) INTEGER The leading dimension of the array A. LDA >= max(1,N).

C++ Return value: INFO (output) INTEGER = 0: successful exit < 0: if INFO = -i, the i-th argument had an illegal value > 0: if INFO = i, the leading minor of order i is not positive definite, and the factorization could not be completed.


.. Parameters ..

C_DPOTRF(): Compute an Cholesky factorization of a Hermitian positive definite N-by-N matrix A.

The factorization has the form A = U**T* U if uplo = 'U' or A = L*L**T if oplo = 'L'

Parameters
uplo,:uplo = 'U' upper triangle of A is stored. uplo = 'L' lower triangle of A is stored
n= number of rows and columns
A= matrix to factorize
lda= leading dimension of a, lda >= max(1,ncol)

Returns: int info. info = 0: successful exit. info < 0: if info=-i, the ith-argument had an illegal vale. info>0: if info=i, the i-th minor is not positive definite

int psi::C_DPOTRI ( char  uplo,
int  n,
double *  a,
int  lda 
)

Purpose

DPOTRI computes the inverse of a real symmetric positive definite matrix A using the Cholesky factorization A = U**T*U or A = L*L**T computed by DPOTRF.

Arguments

UPLO (input) CHARACTER*1 = 'U': Upper triangle of A is stored; = 'L': Lower triangle of A is stored.

N (input) INTEGER The order of the matrix A. N >= 0.

A (input/output) DOUBLE PRECISION array, dimension (LDA,N) On entry, the triangular factor U or L from the Cholesky factorization A = U**T*U or A = L*L**T, as computed by DPOTRF. On exit, the upper or lower triangle of the (symmetric) inverse of A, overwriting the input factor U or L.

LDA (input) INTEGER The leading dimension of the array A. LDA >= max(1,N).

C++ Return value: INFO (output) INTEGER = 0: successful exit < 0: if INFO = -i, the i-th argument had an illegal value > 0: if INFO = i, the (i,i) element of the factor U or L is zero, and the inverse could not be computed.


.. External Functions ..

C_DPOTRI(): Compute inverse of a Hermitian positive deifinite matrix A AFTER a Cholesky decomposition is computed by C_DPORF.

Parameters
uplo,:uplo = 'U' upper triangle of A is stored. uplo = 'L' lower triangle of A is stored
n= number of rows and columns
A= matrix to factorize
lda= leading dimension of a, lda >= max(1,ncol)

Returns: int info. info = 0: successful exit. info < 0: if info=-i, the ith-argument had an illegal vale. info>0: if info=i, the i-th minor is no positive definite

int psi::C_DPOTRS ( char  uplo,
int  n,
int  nrhs,
double *  a,
int  lda,
double *  b,
int  ldb 
)

Purpose

DPOTRS solves a system of linear equations A*X = B with a symmetric positive definite matrix A using the Cholesky factorization A = U**T*U or A = L*L**T computed by DPOTRF.

Arguments

UPLO (input) CHARACTER*1 = 'U': Upper triangle of A is stored; = 'L': Lower triangle of A is stored.

N (input) INTEGER The order of the matrix A. N >= 0.

NRHS (input) INTEGER The number of right hand sides, i.e., the number of columns of the matrix B. NRHS >= 0.

A (input) DOUBLE PRECISION array, dimension (LDA,N) The triangular factor U or L from the Cholesky factorization A = U**T*U or A = L*L**T, as computed by DPOTRF.

LDA (input) INTEGER The leading dimension of the array A. LDA >= max(1,N).

B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) On entry, the right hand side matrix B. On exit, the solution matrix X.

LDB (input) INTEGER The leading dimension of the array B. LDB >= max(1,N).

C++ Return value: INFO (output) INTEGER = 0: successful exit < 0: if INFO = -i, the i-th argument had an illegal value


.. Parameters ..

C_DPOTRS(): Solve a Hermitian positive definite matrix Ax = B AFTER a Cholesky decomposition is computed for A by C_DPORF.

Parameters
uplo,:uplo = 'U' upper triangle of A is stored. uplo = 'L' lower triangle of A is stored
n= number of rows and columns of A
nrhs= number of vectors to solve in B
A= matrix to solve
lda= leading dimension of a, lda >= max(1,ncol)
B= (input)forcing vector/(output)solution vector
ldb= leading dimension of b, ldb >= max(1,ncol)

Returns: int info. info = 0: successful exit. info < 0: if info=-i, the ith-argument had an illegal value.

void psi::C_DROT ( unsigned long int  length,
double *  x,
int  inc_x,
double *  y,
int  inc_y,
double  costheta,
double  sintheta 
)

Calculates a plane Givens rotation for vectors x, y and angle theta. x = x*cos + y*sin, y = -x*sin + y*cos.

Parameters
xvector x
yvector Y
lengthlength of x,y
inc_xhow many places to skip to get to the next element of x
inc_yhow many places to skip to get to the next element of y
void psi::C_DSCAL ( unsigned long int  length,
double  alpha,
double *  vec,
int  inc 
)

This function scales a vector by a real scalar.

Parameters
lengthlength of array
alphascale factor
vecvector to scale
inchow many places to skip to get to next element in vec
void psi::C_DSWAP ( unsigned long int  length,
double *  x,
int  inc_x,
double *  y,
int  inc_y 
)

Swaps a vector with another vector.

Parameters
lengthSpecifies the number of elements in vectors x and y.
xArray, DIMENSION at least (1 + (n-1)*abs(incx)).
inc_xSpecifies the increment for the elements of x.
yArray, DIMENSION at least (1 + (n-1)*abs(incy)).
inc_ySpecifies the increment for the elements of y.
int psi::C_DSYEV ( char  jobz,
char  uplo,
int  n,
double *  a,
int  lda,
double *  w,
double *  work,
int  lwork 
)

Purpose

DSYEV computes all eigenvalues and, optionally, eigenvectors of a real symmetric matrix A.

Arguments

JOBZ (input) CHARACTER*1 = 'N': Compute eigenvalues only; = 'V': Compute eigenvalues and eigenvectors.

UPLO (input) CHARACTER*1 = 'U': Upper triangle of A is stored; = 'L': Lower triangle of A is stored.

N (input) INTEGER The order of the matrix A. N >= 0.

A (input/output) DOUBLE PRECISION array, dimension (LDA, N) On entry, the symmetric matrix A. If UPLO = 'U', the leading N-by-N upper triangular part of A contains the upper triangular part of the matrix A. If UPLO = 'L', the leading N-by-N lower triangular part of A contains the lower triangular part of the matrix A. On exit, if JOBZ = 'V', then if INFO = 0, A contains the orthonormal eigenvectors of the matrix A. If JOBZ = 'N', then on exit the lower triangle (if UPLO='L') or the upper triangle (if UPLO='U') of A, including the diagonal, is destroyed.

LDA (input) INTEGER The leading dimension of the array A. LDA >= max(1,N).

W (output) DOUBLE PRECISION array, dimension (N) If INFO = 0, the eigenvalues in ascending order.

WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) On exit, if INFO = 0, WORK(1) returns the optimal LWORK.

LWORK (input) INTEGER The length of the array WORK. LWORK >= max(1,3*N-1). For optimal efficiency, LWORK >= (NB+2)*N, where NB is the blocksize for DSYTRD returned by ILAENV.

If LWORK = -1, then a workspace query is assumed; the routine only calculates the optimal size of the WORK array, returns this value as the first entry of the WORK array, and no error message related to LWORK is issued by XERBLA.

C++ Return value: INFO (output) INTEGER = 0: successful exit < 0: if INFO = -i, the i-th argument had an illegal value > 0: if INFO = i, the algorithm failed to converge; i off-diagonal elements of an intermediate tridiagonal form did not converge to zero.


.. Parameters ..

C_DSYEV(): Computes all eigenvalues and, optionally, eigenvectors of a real symmetric matrix A.

These arguments mimic their Fortran counterparts.

Parameters
jobz= 'N' or 'n' = compute eigenvalues only; 'V' or 'v' = compute both eigenvalues and eigenvectors.
uplo= 'U' or 'u' = A contains the upper triangular part of the matrix; 'L' or 'l' = A contains the lower triangular part of the matrix.
n= The order of the matrix A.
A= On entry, the two-dimensional array with dimensions n by lda. On exit, if jobz = 'V', the columns of the matrix contain the eigenvectors of A, but if jobz = 'N', the contents of the matrix are destroyed.
lda= The second dimension of A (i.e., the number of columns allocated for A).
w= The computed eigenvalues in ascending order.
work= An array of length lwork. On exit, if the return value is 0, work[0] contains the optimal value of lwork.
lwork= The length of the array work. A useful value of lwork seems to be 3*N.

Returns: 0 = successful exit <0 = the value of the i-th argument to the function was illegal >0 = the algorithm failed to converge.

Interface written by TDC, 10/2002

unsigned long int psi::C_IDAMAX ( unsigned long int  length,
double *  x,
int  inc_x 
)

This function returns the index of the largest absolute value compoment of this vector.

Parameters
lengthNumber of elements in x.
xA pointer to the beginning of the data in x. Must be of at least length (1+(N-1)*abs(inc_x).
inc_xhow many places to skip to get to next element in x
Returns
the index of the largest absolute value
int psi::cc_excited ( const char *  wfn)

cc_excited(): This function takes a WFN string and returns 1 if the WFN is an excited-state method and 0 if the WFN is a ground-state method.

Parameters
*wfn= wavefunction string

Returns: 1 if an excited state method, else 0

int psi::cc_excited ( std::string  wfn)

cc_excited(): This function takes a WFN string and returns 1 if the WFN is an excited-state method and 0 if the WFN is a ground-state method.

Parameters
wfn= wavefunction string

Returns: 1 if an excited state method, else 0

int psi::cc_wfn ( const char *  wfn)

cc_wfn(): Checks if the given wavefunction string is a coupled-cluster type and returns 1 if yes and 0 if no.

Note: "coupled-cluster type" means it is handled by PSI like the coupled-cluster codes, not necessarily that it is literally a coupled-cluster wavefunction

Parameters
*wfn= wavefunction string

Returns: 1 if the WFN is a CC method, 0 otherwise

int psi::cc_wfn ( std::string  wfn)

cc_wfn(): Checks if the given wavefunction string is a coupled-cluster type and returns 1 if yes and 0 if no.

Note: "coupled-cluster type" means it is handled by PSI like the coupled-cluster codes, not necessarily that it is literally a coupled-cluster wavefunction

Parameters
wfn= wavefunction string

Returns: 1 if the WFN is a CC method, 0 otherwise

int psi::ci_wfn ( char *  wfn)

ci_wfn(): Examine the wavefunction type and return 1 if a CI/MCSCF-type, otherwise 0

Parameters
*wfn= wavefunction string

Returns: 1 if a CI/MCSCF-type wavefunction, otherwise 0

int psi::ci_wfn ( std::string  wfn)

ci_wfn(): Examine the wavefunction type and return 1 if a CI/MCSCF-type, otherwise 0

Parameters
wfn= wavefunction string

Returns: 1 if a CI/MCSCF-type wavefunction, otherwise 0

double psi::combinations ( int  n,
int  k 
)

combinations() : Calculates the number of ways to choose k objects from n objects, or "n choose k"

Parameters:

Parameters
n= number of objects in total
k= number of objects taken at a time

Returns: number of combinations of n objects taken k at a time ("n choose k") (returned as a double).

int psi::david ( double **  A,
int  N,
int  M,
double *  eps,
double **  v,
double  cutoff,
int  print 
)

david(): Computes the lowest few eigenvalues and eigenvectors of a symmetric matrix, A, using the Davidson-Liu algorithm.

The matrix must be small enough to fit entirely in core. This algorithm is useful if one is interested in only a few roots of the matrix rather than the whole spectrum.

NB: This implementation will keep up to eight guess vectors for each root desired before collapsing to one vector per root. In addition, if smart_guess=1 (the default), guess vectors are constructed by diagonalization of a sub-matrix of A; otherwise, unit vectors are used.

TDC, July-August 2002

Parameters
A= matrix to diagonalize
N= dimension of A
M= number of roots desired
eps= eigenvalues
v= eigenvectors
cutoff= tolerance for convergence of eigenvalues
print= Boolean for printing additional information

Returns: number of converged roots

void psi::dirprd_block ( double **  A,
double **  B,
int  rows,
int  cols 
)

dirprd_block()

This function takes two block matrices A and B and multiplies each element of B by the corresponding element of A

Parameters
A= block matrix A
B= block matrix B
nrows= number of rows of A and B
ncols= number of columns of A and B

Returns: none

double psi::dot_block ( double **  A,
double **  B,
int  rows,
int  cols,
double  alpha 
)

dot_block(): Find dot product of two block matrices

Parameters
A= block matrix A
B= block matrix B
nrows= number of rows of A and B
ncols= number of columns of A and B
alpha= scale factor by which the dot product is multiplied

Returns: dot product

double psi::factorial ( int  n)

factorial(): Returns n!

Parameters:

Parameters
n= number to take factorial of

Returns: n factorial, as a double word (since n! can get very large).

void psi::fill_sym_matrix ( double **  A,
int  size 
)

fill_sym_matrix(): Fills a symmetric matrix by placing the elements of the lower triangle into the upper triangle.

Parameters
A= matrix to symmetrize
size= number of rows or columns (assume square)

Returns: none

void psi::filter ( double *  input,
double *  output,
int *  ioff,
int  norbs,
int  nfzc,
int  nfzv 
)

filter(): Filter out undesired (frozen core/virt) integrals

Given a lower-triangle array of integrals in the full space of orbitals as well as numbers of frozen core and virtual orbitals, this function returns a list of integrals involving only active orbitals.

TDC, June 2001

Note: Based on the code written by CDS in the original iwl_rd_one_all_act() function in LIBIWL.

void psi::free_3d_array ( double ***  A,
int  p,
int  q 
)

free_3d_array(): Free a (non-contiguous) 3D array

Parameters
A= triple-star pointer to the 3D array
p= size of first dimension
q= size of second dimension

Returns: none

double *** psi::init_3d_array ( int  p,
int  q,
int  r 
)

3d_array(): Initialize a (non-contiguous) 3D array

Parameters
p= size of first dimension
q= size of second dimension
r= size of third dimension

Returns: triple-star pointer to 3D array

double psi::invert_matrix ( double **  a,
double **  y,
int  N,
std::string  out 
)

INVERT_MATRIX(): The function takes the inverse of a matrix using the C routines in Numerical Recipes in C.

Matt Leininger, Summer 1994

Parameters:

Parameters
a= matrix to take the inverse of (is modified by invert_matrix())
y= the inverse matrix
N= the size of the matrices
outfile= file for error messages

Other variables: col and indx are temporary arrays d is 1 or -1

Returns: double (determinant) Note: The original matrix is modified by invert_matrix()

int psi::mat_in ( FILE *  fp,
double **  array,
int  width,
int  max_length,
int *  stat 
)

MAT_IN(): Function to read in a matrix. Simple version for now.

Parameters:

Parameters
fp= file pointer to input stream
array= matrix to hold data
width= number of columns to read
max_length= maximum number of rows to read
stat= pointer to int to hold status flag (0=read ok, 1=error)

Returns: number of rows read Also modifies stat to = error code (0 = ok, 1 = error)

void psi::mat_print ( double **  matrix,
int  rows,
int  cols,
std::string  out 
)

mat_print(): Prints a matrix to a file in a formatted style

Parameters
matrix= matrix to print
rows= number of rows
cols= number of columns
outfile= output file pointer for printing

Returns: Always returns zero...

double psi::newton ( double(*)(double)  F,
double(*)(double)  dF,
double  x,
double  tolerance,
int  maxiter,
int  printflag 
)

newton(): Find the root of a function by Newton's method. Iterations are limited to a maximum value. The algorithm stops when the difference between successive estimates of the root is less than the specified tolerance. An initial guess for the root must be given, as well as the function AND it's derivative.

Parameters
F= pointer to function we want to examine (must return double)
dF= pointer to derivative of function F
x= initial guess for root
tolerance= how close successive guesses must get before convergence
maxiter= maximum number of iterations
printflag= whether or not to print results for each iteration (1 or 0)

Returns: the value of the root

void psi::normalize ( double **  A,
int  rows,
int  cols 
)

normalize(): Normalize a set of vectors

Assume we're normalizing the ROWS

Parameters
A= matrix holding vectors to normalize
rows= number of rows in A
cols= number of columns in A

Returns: none

David Sherrill, Feb 1994

int psi::pople ( double **  A,
double *  x,
int  dimen,
int  ,
double  tolerance,
std::string  out,
int  print_lvl 
)

POPLE(): Uses Pople's method to iteratively solve linear equations Ax = b

Matt Leininger, April 1998

Parameters
A= matrix
x= initially has vector b, but returns vector x.
dimen= dimension of vector x.
num_vecs= number of vectors x to obtain.
tolerance= cutoff threshold for norm of expansion vector.

Returns: 0 for success, 1 for failure

int psi::ras_set ( int  nirreps,
int  nbfso,
int  freeze_core,
int *  orbspi,
int *  docc,
int *  socc,
int *  frdocc,
int *  fruocc,
int **  ras_opi,
int *  order,
int  ras_type 
)

ras_set(): Deprecated

This function sets up the number of orbitals per irrep for each of the RAS subspaces [frozen core, RAS I, RAS II, RAS III, RAS IV, frozen virts]. It also obtains the appropriate orbital reordering array. The reordering array takes a basis function in Pitzer ordering (orbitals grouped according to irrep) and gives the corresponding index in the RAS numbering scheme. Orbitals are numbered according to irrep within each of the subspaces.

Formerly, docc, socc, frdocc, and fruocc were read in this function. Now docc and socc will be left as-is if they are not present in input.

C. David Sherrill Center for Computational Quantum Chemistry University of Georgia, 25 June 1995

Parameters
nirreps= num of irreps in computational point group
nbfso= num of basis functions in symmetry orbitals (num MOs)
freeze_core= 1 to remove frozen core orbitals from ras_opi
orbspi= array giving num symmetry orbitals (or MOs) per irrep
docc= array of doubly occupied orbitals per irrep
socc= array of singly occupied orbitals per irrep
frdocc= array of frozen core per irrep
fruocc= array of frozen virtuals per irrep
ras_opi= matrix giving num of orbitals per irrep per ras space, addressed as ras_opi[ras_space][irrep]
order= array nbfso big which maps Pitzer to Correlated order
ras_type= if 1, put docc and socc together in same RAS space (RAS I), as appropriate for DETCI. If 0, put socc in its own RAS space (RAS II), as appropriate for CC.

Returns: 1 for success, 0 otherwise

int psi::ras_set2 ( int  nirreps,
int  nmo,
int  delete_fzdocc,
int  delete_restrdocc,
int *  orbspi,
int *  docc,
int *  socc,
int *  frdocc,
int *  fruocc,
int *  restrdocc,
int *  restruocc,
int **  ras_opi,
int *  order,
int  ras_type,
int  hoffmann,
Options &  options 
)

ras_set2()

NOTE!!!! : Codes need to be modified to provide a guess of the frozen docc and frozen uocc arrays now !!!! CDS-TODO: 9/2011

This function sets up the number of orbitals per irrep for each of the RAS subspaces [frozen core (FZC), restricted core (COR), RAS I, RAS II, RAS III, RAS IV, restricted virts (VIR), frozen virts (FZV)]. It also obtains the appropriate orbital reordering array. The reordering array takes a basis function in Pitzer ordering (orbitals grouped according to irrep) and gives the corresponding index in the RAS numbering scheme. Orbitals are numbered according to irrep within each of the subspaces.

Formerly, docc, socc, frdocc, and fruocc were read in this function. Now docc and socc will be left as-is if they are not present in input.

Assume we always want integrals (at least some of them...) involving restricted orbitals, but we may not need them for frozen orbitals unless perhaps it's a gradient. The frozen orbitals will never enter explicitly in DETCI, but restricted orbitals may or may not, depending on the type of computation (CI vs CAS vs CASPT2, etc). For conventional CI, FCI, MRCI, RASCI, CASSCF, restricted orbitals will not participate explicitly in DETCI. For CASPT2, perhaps they will. CLAG and DETCAS will still need to have some indices in the restricted (and possibly frozen) orbital subspaces?

C. David Sherrill

Updated June 2002 to distinguish between frozen and restricted spaces

Parameters
nirreps= num of irreps in computational point group
nmo= number of MO's
delete_fzdocc= 1 to remove frozen core orbitals from ras_opi[0]
delete_restrdocc= 1 to remove restricted core orbs from ras_opi[0]
orbspi= array giving num symmetry orbitals (or MOs) per irrep
docc= array of doubly occupied orbitals per irrep (guess should be provided)
socc= array of singly occupied orbitals per irrep (guess should be provided)
frdocc= array of frozen core per irrep before: (returned by function, allocate before call) now: allocate and fill with a guess
fruocc= array of frozen virtuals per irrep before: (returned by function, allocate before call) now: allocate and fill with a guess
rstrdocc= array of restricted core per irrep (returned by function, but allocate before call)
rstruocc= array of restricted core per irrep (returned by function, but allocate before call)
ras_opi= matrix giving num of orbitals per irrep per ras space, addressed as ras_opi[ras_space][irrep] (returned by function, but allocate before call)
order= array nmo big which maps Pitzer to Correlated order (returned by function, but allocate before call)
ras_type= if 1, put docc and socc together in same RAS space (RAS I), as appropriate for DETCI. If 0, put socc in its own RAS space (RAS II), as appropriate for CC.
hoffmann= if > 0, order orbitals according to Mark Hoffmann. hoffmann==1: ras1, ras2, ..., rasn, COR, FZC, VIR, FZV. hoffmann==2: VIR, ras1, ras2, ..., rasn, COR, FZC, FZV. Note odd placement of FZC in middle!

Returns: 1 for success, 0 otherwise

int psi::ras_set3 ( int  nirreps,
int  nmo,
int *  orbspi,
int *  docc,
int *  socc,
int *  frdocc,
int *  fruocc,
int *  restrdocc,
int *  restruocc,
int **  ras_opi,
int *  core_guess,
int *  order,
int  ras_type,
bool  is_mcscf,
Options &  options 
)

ras_set3()

Updated version of ras_set2() to conform with new DETCI naming of various orbital spaces, particularly to distinguish between restricted orbitals (those that are doubly occupied but can optimized in an MCSCF) and frozen orbitals (those that are doubly occupied but cannot be optimized in an MCSCF). Also remove some deprecated code supporting Mark Hoffmann ordering, etc.

This function sets up the number of orbitals per irrep for each of the RAS subspaces [frozen core, restricted core, RAS I, RAS II, RAS III, RAS IV, restricted virts, frozen virts]. It also obtains the appropriate orbital reordering array. The reordering array takes a basis function in Pitzer ordering (orbitals grouped according to irrep) and gives the corresponding index in the RAS numbering scheme. Orbitals are numbered according to irrep within each of the subspaces.

Guesses for docc and socc should be provided, and they will be left as-is if they are not present in input (maybe auto-guessed by program)

C. David Sherrill

Parameters
nirreps= num of irreps in computational point group
nmo= number of MO's
orbspi= array giving num symmetry orbitals (or MOs) per irrep
docc= array of doubly occupied orbitals per irrep (guess must be provided)
socc= array of singly occupied orbitals per irrep (guess must be provided)
frdocc= array of frozen core per irrep (returned by function, but allocate before call)
fruocc= array of frozen virtuals per irrep (returned by function, but allocate before call)
rstrdocc= array of restricted core per irrep (returned by function, but allocate before call)
rstruocc= array of restricted unoccupied per irrep (returned by function, but allocate before call)
ras_opi= matrix giving num of orbitals per irrep per ras space, addressed as ras_opi[ras_space][irrep] (returned by function, but allocate before call) RAS IV will not be deduced unless RAS III is present in user input (in which case RAS IV needs to make up any remaining orbitals)
core_guess= array of the core orbitals per irrep to drop (must be provided). This is copied into FROZEN_DOCC (if is_mcscf == false) or RESTRICTED_DOCC (if is_mcscf == true), if both of those two arrays are absent from input
order= array nmo big which maps Pitzer to Correlated order (returned by function, but allocate before call)
ras_type= if 1, put docc and socc together in same RAS space (RAS I), as appropriate for DETCI. If 0, put socc in its own RAS space (RAS II), as appropriate for CC.
is_mcscf= true if an MCSCF-type wavefunction (orbital optimization), else false. Used to determine default behavior of FROZEN_DOCC, RESTRICTED_DOCC, FROZEN_UOCC, RESTRICTED_UOCC
options= Options object used to parse user input

Rules for how spaces can be specified:

  1. DOCC and SOCC are not changed by this routine (guesses might have been auto-generated by Psi) unless explicitly given in user input, in which case the guess arrays are overwritten by the user input in this routine
  2. FROZEN_DOCC and RESTRICTED_DOCC will be as given by the user. If the user does not specify either of these keywords, then maybe they specified FREEZE_CORE = TRUE instead, and we want to support that. If neither FROZEN_DOCC nor RESTRICTED_DOCC is specified, then we will use the array core_guess[] to get them. This array is obtained from whatever routine figures out how many orbitals per irrep to freeze when FREEZE_CORE = true (passed down as an argument into this function). If the computation is an MCSCF, then we'll copy core_guess into RESTRICTED_DOCC. If it's not an MCSCF, then we'll copy it into FROZEN_DOCC.
  3. The user can give either ACTIVE (for a CAS type computation, where internally this is basically like RAS 2), or RAS keywords. Not both.
  4. By default, unused virtual orbitals go into FROZEN_UOCC unless we're told this is an MCSCF, in which case they should go by default into RESTRICTED_UOCC
  5. RAS 4 is never used unless explicitly given in input; it's a special feature not normally desired. (Note: this is a change from previous default behavior in which unused orbitals were stuffed into RAS 4)

Returns: 1 for success, 0 otherwise

void psi::reorder_qt ( int *  docc_in,
int *  socc_in,
int *  frozen_docc_in,
int *  frozen_uocc_in,
int *  order,
int *  orbs_per_irrep,
int  nirreps 
)

reorder_qt()

This function constructs a reordering array according to the "Quantum Trio" standard ordering, in which the orbitals are divided into the following sets: frozen core, then doubly occupied, then singly occupied, then virtuals, then deleted (frozen) virtuals. The reordering array takes a basis function in Pitzer ordering (orbitals grouped according to irrep) and gives the corresponding index in the Quantum Trio numbering scheme.

Should give the same reordering array as in the old libread30 routines.

C. David Sherrill Center for Computational Quantum Chemistry University of Georgia, 1995

Parameters
docc_in= doubly occupied orbitals per irrep
socc_in= singly occupied orbitals per irrep
frozen_docc_in= frozen occupied orbitals per irrep
frozen_uocc_in= frozen unoccupied orbitals per irrep
order= reordering array (Pitzer->QT order)
nirreps= number of irreducible representations
void psi::reorder_qt_uhf ( int *  docc,
int *  socc,
int *  frozen_docc,
int *  frozen_uocc,
int *  order_alpha,
int *  order_beta,
int *  orbspi,
int  nirreps 
)

reorder_qt_uhf()

Generalization of reorder_qt() for UHF case

Parameters
docc= doubly occupied orbitals per irrep
socc= singly occupied orbitals per irrep
frozen_docc= frozen occupied orbitals per irrep
frozen_uocc= frozen unoccupied orbitals per irrep
order_alpha= reordering array for alpha (Pitzer->QT order)
order_beta= reordering array for beta (Pitzer->QT order)
nirreps= number of irreducible representations
void psi::schmidt ( double **  A,
int  rows,
int  cols,
std::string   
)

SCHMIDT(): Gram-Schmidt orthogonalize a set of vectors

Assume we're orthogonalizing the ROWS, since in C a vector is usually a row more often than a column.

David Sherrill, Feb 1994

Parameters
A= matrix to orthogonalize (matrix of doubles)
rows= rows of A
cols= columns of A

Returns: none

int psi::schmidt_add ( double **  A,
int  rows,
int  cols,
double *  v 
)

SCHMIDT_ADD(): Assume A is a orthogonal matrix. This function Gram-Schmidt orthogonalizes a new vector v and adds it to matrix A. A must contain a free row pointer for a new row. Don't add orthogonalized v' if norm(v') < NORM_TOL.

David Sherrill, Feb 1994

Parameters
A= matrix to add new vector to
rows= current number of rows in A (A must have ptr for 'rows+1' row.)
cols= columns in A v = vector to add to A after it has been made orthogonal to rest of A

Returns: 1 if a vector is added to A, 0 otherwise

double psi::secant ( double(*)(double)  F,
double  x0,
double  x1,
double  tolerance,
int  maxiter,
int  printflag 
)

secant(): Find the root of a function by the Secant Method. Iterations are limited to a maximum value. The algorithm stops when the relative difference between successive guesses is less than the specified tolerance. An initial TWO guesses for the root must be given, as well as the function itself.

Parameters
F= pointer to function we want to examine (must return double)
x0= 1st guess for root
x1= 2nd guess for root
tolerance= how close successive guesses must get before convergence
maxiter= maximum number of iterations
printflag= whether or not to print results for each iteration (1 or 0)

Returns: the value of the root

void psi::slaterdetset_add ( SlaterDetSet *  sdset,
int  index,
int  alphastring,
int  betastring 
)

slaterdetset_add(): Add info for a particular Slater determinant to a SlaterDetSet.

Parameters
sdset= pointer to SlaterDetSet to add to
index= location in the set to add to
alphastring= alpha string ID for the new determinant
betastring= beta string ID for the new determinant

Returns: none

void psi::slaterdetset_delete ( SlaterDetSet *  sdset)

slaterdetset_delete(): Delete a Slater Determinant Set.

Does not free the members alphastrings and betastrings. See also: slaterdetset_delete_full() which does this.

Parameters
sdset= pointer to SlaterDetSet to be de-allocated

Returns: none

void psi::slaterdetset_delete_full ( SlaterDetSet *  sdset)

slaterdetset_delete_full(): De-allocate a Slater Determinant Set.

Frees memory including alpha and beta strings. See slaterdetset_delete() for a similar version which does not free the alpha and beta strings.

Parameters
sdset= pointer to SlaterDetSet to be de-allocated

Returns: none

void psi::slaterdetset_init ( SlaterDetSet *  sdset,
int  size,
StringSet *  alphastrings,
StringSet *  betastrings 
)

slaterdetset_init(): Initialize a Slater Determinant Set

Parameters
sdset= pointer to SlaterDetSet being initialized
size= number of SlaterDets to be held
alphastrings= pointer to StringSet of alpha strings
betastrings= pointer to StringSet of beta strings

Returns: none

void psi::slaterdetset_read ( ULI  unit,
const char *  prefix,
SlaterDetSet **  slaterdetset 
)

slaterdetset_read(): Read a Slater Determinant Set

Parameters
unit= file number of the PSIO file
prefix= prefix string to come before libpsio entry keys
sdset= pointer to SlaterDetSet to read into

Returns: none

void psi::slaterdetset_read_vect ( ULI  unit,
const char *  prefix,
double *  coeffs,
int  size,
int  vectnum 
)

slaterdetset_read_vect(): Read in the coefficients for a single vector associated with a SlaterDetSet.

This function already assumes we've already called slaterdetset_read() to read in the string and determinant information. This is only going to read in the coefficients. This has been split out because we might want to read several roots for a given determinant setup. This does not actually depend on the presence of a SlaterDetVector object and is called a SlaterDetSet function.

Parameters
unit= file number of the UNINITIALIZED PSIO file
prefix= prefix string to come before libpsio entry keys
coeffs= array to hold coefficients read
size= number of elements in coeffs array
vectnum= the vector number (for the PSIO key). Start from 0.

Returns: none

CDS 8/03

void psi::slaterdetset_write ( ULI  unit,
const char *  prefix,
SlaterDetSet *  sdset 
)

slaterdetset_write(): Write a Slater Determinant Set to disk.

Parameters
unit= file number to write to
prefix= prefix string to come before libpsio entry keys
sdset= pointer to SlaterDetSet to write

Returns: none

void psi::slaterdetset_write_vect ( ULI  unit,
const char *  prefix,
double *  coeffs,
int  size,
int  vectnum 
)

slaterdetset_write_vect(): Write to disk the coefficients for a single vector associated with a set of Slater determinants.

This function already assumes we've already called slaterdetset_write() to write out the string and determinant information. This is only going to write out the coefficients. This has been split out because we might want to write several roots for a given determinant setup. This does not actually dpend on the presence of a SlaterDetVector object so it is called a SlaterDetSet function.

Parameters
unit= file number of the UNINITIALIZED PSIO file
prefix= prefix string to come before libpsio entry keys
coeffs= array of coefficients to write
size= number of elements in coeffs array
vectnum= the vector number (to make a PSIO key). Start numbering from zero.

Returns: none

CDS 8/03

void psi::slaterdetvector_add ( SlaterDetVector *  sdvector,
int  index,
double  coeff 
)

slaterdetvector_add(): Add a coefficient to a SlaterDetVector

Parameters
sdvector= Pointer to SlaterDetVector to add to
index= location in vector for writing the coefficient
coeff= the coefficient to write to location index

Returns: none

void psi::slaterdetvector_delete ( SlaterDetVector *  sdvector)

slaterdetvector_delete(): De-allocate a SlaterDetVector

Parameters
sdvector= pointer to SlaterDetVector to de-allocate

Note: does NOT fully free the associated SlaterDetSet. For that, see function slaterdetvector_delete_full()

Returns: none

void psi::slaterdetvector_delete_full ( SlaterDetVector *  sdvector)

slaterdetvector_delete_full(): De-allocate a SlaterDetVector and its associated SlaterDetSet.

To keep the SlaterDetSet itself, use similar function slaterdetvector_delete().

Parameters
sdvector= pointer to SlaterDetVector to delete

Returns: none

void psi::slaterdetvector_init ( SlaterDetVector *  sdvector,
SlaterDetSet *  sdset 
)

slaterdetvector_init(): Initialize a vector of coefficients corresponding to a Slater Determinant set

Parameters
sdvector= pointer to SlaterDetVector to initialize (coeffs member will be allocated)
sdset= pointer to SlaterDetSet the vector is associated with

Returns: none

void psi::slaterdetvector_read ( ULI  unit,
const char *  prefix,
SlaterDetVector **  sdvector 
)

slaterdetvector_read(): Read a SlaterDetVector from disk

Use this if we only need to read a single vector. Otherwise, call slaterdetset_read(); slaterdetset_read_vect(); to allow for multiple vectors per slaterdetset to be read from disk.

Parameters
unit= file number to read from
prefix= prefix string to come before libpsio entry keys
sdvector= pointer to hold pointer to SlaterDetVector allocated by this function

Returns: none

void psi::slaterdetvector_set ( SlaterDetVector *  sdvector,
double *  coeffs 
)

slaterdetvector_set(): Set a SlaterDetVector's vector to a set of coefficients supplied by array coeffs

Parameters
sdvector= pointer to SlaterDetVector for writing coefficients
coeffs= array of coefficients to write to sdvector
void psi::slaterdetvector_write ( ULI  unit,
const char *  prefix,
SlaterDetVector *  vector 
)

slaterdetvector_write(): Write a SlaterDetVector to disk.

This writes a vector in the space of Slater determinants, along with the set of determinants itself, to a PSIO file.

Use this if we only need to write a single vector. Otherwise, call slaterdetset_write(); slaterdetset_write_vect(); to allow for multiple vectors per slaterdetset to be written to disk.

Parameters
unit= file number of the UNINITIALIZED PSIO file
prefix= prefix string to come before libpsio entry keys
vector= SlaterDetVector to write to disk

Returns: none

void psi::solve_2x2_pep ( double **  H,
double  S,
double *  evals,
double **  evecs 
)

solve_2x2_pep(): Solve a 2x2 pseudo-eigenvalue problem of the form [ H11 - E H12 - E*S ] [c1] [ H12 - E*S H22 - E ] [c2] = 0

Parameters
H= matrix to get eigenvalues of
S= overlap between states 1 & 2
evals= pointer to array to hold 2 eigenvalues
evecs= matrix to hold 2 eigenvectors

Returns: none

void psi::sort_vector ( double *  A,
int  n 
)

sort_vector(): Sort the elements of a vector into increasing order

Parameters
A= array to sort
n= length of array

Returns: none

void psi::stringset_add ( StringSet *  sset,
int  index,
unsigned char *  Occ 
)

stringset_add(): Add a string (in Pitzer order, given by Occ) to the StringSet, writing to position index.

Parameters
sset= StringSet to add to
index= location in StringSet to add to
Occ= orbital occupations (Pitzer order) of the string to add

Returns: none

void psi::stringset_delete ( StringSet *  sset)

stringset_delete(): Delete a StringSet

Parameters
sset= pointer to StringSet to delete

Returns: none

void psi::stringset_init ( StringSet *  sset,
int  size,
int  nelec,
int  ndrc,
short int *  drc_occ 
)

stringset_init(): Initialize a set of alpha/beta strings

Parameters
sset= pointer to StringSet (contains occs in Pitzer order)
size= number of strings
nelec= number of electrons
ndrc= number of dropped core orbitals
drc_occ= array of dropped occupied orbitals (Pitzer numbering!)

Returns: none

void psi::stringset_read ( ULI  unit,
const char *  prefix,
StringSet **  stringset 
)

stringset_read(): Read a StringSet from disk

Parameters
unit= file number to read from
prefix= prefix string to come before libpsio entry keys
stringset= double pointer to StringSet allocated by this function

Returns: none

void psi::stringset_reindex ( StringSet *  sset,
short int *  mo_map 
)

stringset_reindex(): Remap orbital occupations from one ordering to another.

Parameters
sset= pointer to StringSet
mo_map= mapping array from original orbital order to new order

Returns: none

void psi::stringset_write ( ULI  unit,
const char *  prefix,
StringSet *  sset 
)

stringset_write(): Write a stringset to a PSI file

Parameters
unit= file number to write to
prefix= prefix string to come before libpsio entry keys
sset= pointer to StringSet to write

Returns: none

void psi::timer_done ( void  )

timer_done(): Close down all timers and write results to timer.dat

void psi::timer_init ( void  )

timer_init(): Initialize the linked list of timers

double psi::timer_nsdiff ( struct timeval &  endt,
struct timeval &  begint 
)

timer_nsdiff(struct timeval endt, struct timeval begint): Returns the time difference between two timeval values as a double, in seconds. Takes into account the difference in nanoseconds accurately. Taken from gnu.org, supposedly the best way to do that works even on peculiar OS where tv_sec is unsigned.

Parameters
endt= Final timeval value as obtained through gettimeofday()
begint= Initial timeval value as obtained through gettimeofday()

Returns: the time difference in seconds as a double.

void psi::timer_off ( const char *  key)

timer_off(): Turn off the timer with the name given as an argument. Can be turned on and off, time will accumulate while on.

Parameters
key= Name of timer
void psi::timer_on ( const char *  key)

timer_on(): Turn on the timer with the name given as an argument. Can be turned on and off, time will accumulate while on.

Parameters
key= Name of timer
struct timer* psi::timer_scan ( const char *  key)

timer_scan(): Return a timer structure whose name matches that given by supplied string

Parameters
key= name of timer to search for

Returns: the timer structure with the given name, else NULL