Files | |
| file | add_arr.cc |
| Add two arrays. | |
| file | add_mat.cc |
| Add two matrices. | |
| file | libciomr/block_matrix.cc |
| Allocate a blocked (memory-contiguous) 2D matrix of doubles. | |
| file | dot.cc |
| Take dot product between two matrices. | |
| file | eigout.cc |
| Print eigenvectors and eigenvalues. | |
| file | eigsort.cc |
| Sort eigenvalues and eigenvectors in ascending or descending order. | |
| file | eivout.cc |
| Print eigenvectors and eigenvalues to output file. | |
| file | ffile.cc |
| Open PSI ASCII or small local binary (non-libpsio) files for reading/writing. | |
| file | flin.cc |
| Linear equation solver for A * x = b. | |
| file | fndcor.cc |
| Get the amount of core memory available from input. | |
| file | init_matrix.cc |
| Initialize a matrix of doubles. | |
| file | int_array.cc |
| This file includes the integer versions of several psi routines for handling arrays and matrices of doubles. | |
| file | mmult.cc |
| Multiply two matrices (superceded by C_DGEMM). | |
| file | mxmb.cc |
| Wrapper for the mmult function. | |
| file | print_array.cc |
| Print a lower-triangle array of doubles. | |
| file | print_mat.cc |
| Print a matrix of doubles. | |
| file | psi_start.cc |
| Initialize input, output, file prefix, etc. | |
| file | psi_stop.cc |
| Close input and output, stop input parser. | |
| file | rsp.cc |
| Diagonalize a symmetric matrix in packed (lower triangular) form. | |
| file | sq_rsp.cc |
| Diagnoalize a symmetrix square matrix. | |
| file | sq_to_tri.cc |
| Convert square matrix to lower triangle packing. | |
| file | tqli.cc |
| Diagonalizes a tridiagonal matrix output by tred2. | |
| file | tred2.cc |
| Converts a symmetric matrix to tridiagonal form for use in tqli. | |
| file | tri_to_sq.cc |
| Converts lower triangle to square matrix. | |
| file | tstart.cc |
| Controls starting and stopping of timers. | |
| file | zero.cc |
| Zero arrays or matrices of doubles. | |
Functions | |
| void | add_arr (double *a, double *b, double *c, int n) |
| void | add_mat (double **a, double **b, double **c, int n, int m) |
| double ** | block_matrix (unsigned long int n, unsigned long int m) |
| void | free_block (double **array) |
| double | dot_mat (double **a, double **b, int n) |
| void | dot_arr (double *a, double *b, int n, double *value) |
| void | eigout (double **a, double *b, double *c, int m, int n, FILE *out) |
| void | eigsort (double *d, double **v, int n) |
| void | mosort (double *d, double **v, int *sym, int nso, int nmo) |
| void | eivout (double **a, double *b, int m, int n, FILE *out) |
| void | ffile (FILE **fptr, char *suffix, int code) |
| void | ffile_noexit (FILE **fptr, char *suffix, int code) |
| void | ffileb (FILE **fptr, char *suffix, int code) |
| void | ffileb_noexit (FILE **fptr, char *suffix, int code) |
| void | flin (double **a, double *b, int in, int im, double *det) |
| void | fndcor (long int *maxcrb, FILE *infile, FILE *outfile) |
| double * | init_array (unsigned long int size) |
| double ** | init_matrix (unsigned long int n, unsigned long int m) |
| void | free_matrix (double **array, unsigned long int size) |
| int * | init_int_array (int size) |
| void | zero_int_array (int *a, int size) |
| int ** | init_int_matrix (int rows, int cols) |
| void | free_int_matrix (int **array) |
| void | zero_int_matrix (int **array, int rows, int cols) |
| void | print_int_mat (int **a, int m, int n, FILE *out) |
| void | mmult (double **AF, int ta, double **BF, int tb, double **CF, int tc, int nr, int nl, int nc, int add) |
| void | mxmb (double **a, int ia, int ja, double **b, int ib, int jb, double **c, int ic, int jc, int nrow, int nlnk, int ncol) |
| void | print_array (double *a, int m, FILE *out) |
| void | print_mat (double **a, int m, int n, FILE *out) |
| int | psi_start (FILE **infile, FILE **outfile, char **psi_file_prefix, int argc, char *argv[], int overwrite_output) |
| char * | psi_ifname () |
| char * | psi_ofname () |
| char * | psi_fprefix () |
| int | psi_stop (FILE *infile, FILE *outfile, char *psi_file_prefix) |
| void | rsp (int nm, int n, int nv, double *array, double *e_vals, int matz, double **e_vecs, double toler) |
| void | sq_rsp (int nm, int n, double **array, double *e_vals, int matz, double **e_vecs, double toler) |
| void | sq_to_tri (double **bmat, double *amat, int size) |
| void | tqli (int n, double *d, double **z, double *e, int matz, double toler) |
| void | tred2 (int n, double **a, double *d, double *e, int matz) |
| void | tri_to_sq (double *amat, double **bmat, int size) |
| void | tstop (FILE *outfile) |
| void | zero_arr (double *a, int size) |
| void | zero_mat (double **a, int n, int m) |
| void add_arr | ( | double * | a, | |
| double * | b, | |||
| double * | c, | |||
| int | n | |||
| ) |
add_arr(): Add arrays a and b and put the result in array c. Adds the first n elements
| a | = first array to add | |
| b | = second array to add | |
| c | = array to hold the result of a+b | |
| n | = number of elements to add |
Definition at line 23 of file add_arr.cc.
00024 { 00025 register int i; 00026 00027 for (i=0; i < n; i++) { 00028 c[i] = a[i]+b[i]; 00029 } 00030 }
| void add_mat | ( | double ** | a, | |
| double ** | b, | |||
| double ** | c, | |||
| int | n, | |||
| int | m | |||
| ) |
add_mat(): Add matrices a and b into c for n rows and m columns
| a | = double star pointer to first matrix to add | |
| b | = double star pointer to second matrix to add | |
| c | = double star pointer to matrix to hold the result of a+b | |
| n | = number of rows in a,b,c | |
| m | = number of columns in a,b,c |
Definition at line 20 of file add_mat.cc.
00021 { 00022 register int i,j; 00023 00024 if (n != m) { 00025 for (i=0; i < n ; i++) { 00026 for (j=0; j < m ; j++) { 00027 c[i][j] = a[i][j]+b[i][j]; 00028 } 00029 } 00030 } 00031 else { 00032 for (i=0; i < n; i++) { 00033 for (j=0; j < i; j++) { 00034 c[i][j] = a[i][j]+b[i][j]; 00035 c[j][i] = a[j][i]+b[j][i]; 00036 } 00037 c[i][i] = a[i][i]+b[i][i]; 00038 } 00039 } 00040 }
| double** block_matrix | ( | unsigned long int | n, | |
| unsigned long int | m | |||
| ) |
block_matrix(): Allocate a 2D array of doubles using contiguous memory
Allocates a contiguous block of memory for an array of doubles, allocates an array of pointers to the beginning of each row and returns the pointer to the first row pointer. This allows transparent 2d-array style access, but keeps memory together such that the matrix could be used in conjunction with FORTRAN matrix routines.
Allocates memory for an n x m matrix and returns a pointer to the first row.
| n | = number of rows (unsigned long to allow large matrices) | |
| m | = number of columns (unsigned long to allow large matrices) |
T. Daniel Crawford Sometime in 1994
Based on init_matrix() from libciomr
Definition at line 39 of file libciomr/block_matrix.cc.
Referenced by ael(), psi::detcas::bfgs_hessian(), psi::detcas::calc_gradient(), psi::detcas::calc_hessian(), david(), eri(), pople(), psi::extrema::zmat::write_chkpt(), and psi::extrema::coord_base_carts::write_chkpt().
00040 { 00041 double **A=NULL; 00042 double *B=NULL; 00043 unsigned long int i; 00044 00045 if(!m || !n) return((double **) NULL); 00046 00047 if ((A = (double **) malloc(n * (unsigned long int)sizeof(double *)))==NULL) { 00048 fprintf(stderr,"block_matrix: trouble allocating memory \n"); 00049 fprintf(stderr,"n = %ld\n",n); 00050 exit(PSI_RETURN_FAILURE); 00051 } 00052 00053 if ((B = (double *) malloc(m*n * (unsigned long int)sizeof(double)))==NULL) { 00054 fprintf(stderr,"block_matrix: trouble allocating memory \n"); 00055 fprintf(stderr,"m = %ld\n",m); 00056 exit(PSI_RETURN_FAILURE); 00057 } 00058 00059 bzero(B, m*n*(unsigned long int)sizeof(double)); 00060 00061 for (i = 0; i < n; i++) { 00062 A[i] = &(B[i*m]); 00063 } 00064 00065 return(A); 00066 }
| void dot_arr | ( | double * | a, | |
| double * | b, | |||
| int | n, | |||
| double * | value | |||
| ) |
dot_arr(): Take the dot product of the first n elements of two arrays a and b and return the result
| a | = first array to take dot product of | |
| b | = second array to take dot product of | |
| n | = number of elements in array | |
| value | = pointer to hold dot product result |
Definition at line 51 of file dot.cc.
Referenced by normalize(), pople(), schmidt(), and schmidt_add().
00052 { 00053 register int i; 00054 double tval; 00055 00056 tval = 0.0; 00057 for (i=0; i < n; i++) { 00058 tval += a[i]*b[i]; 00059 } 00060 *value = tval; 00061 }
| double dot_mat | ( | double ** | a, | |
| double ** | b, | |||
| int | n | |||
| ) |
dot_mat(): Takes the dot product between two 2D matrices a and b with dimensions n x n and returns the value
| a | = first matrix for dot product | |
| b | = second matrix for dot product | |
| n | = number of rows/columns for matrices a and b |
Definition at line 21 of file dot.cc.
00022 { 00023 register int i,j; 00024 double *ta, *tb, tval; 00025 00026 tval = 0.0; 00027 for (i=0; i < n; i++) { 00028 ta = a[i]; 00029 tb = b[i]; 00030 for (j=0; j < n; j++,ta++,tb++) { 00031 tval += (*ta) * (*tb); 00032 } 00033 } 00034 return(tval); 00035 }
| void eigout | ( | double ** | a, | |
| double * | b, | |||
| double * | c, | |||
| int | m, | |||
| int | n, | |||
| FILE * | out | |||
| ) |
eigout(): Print out eigenvectors and eigenvalues.
Prints an n x m matrix of eigenvectors. Under each eigenvector, the corresponding elements of two arrays, b and c, will also be printed. This is useful for printing, for example, the SCF eigenvectors with their associated eigenvalues (orbital energies) and also the population.
| a | = matrix of eigenvectors (eigenvectors are columns) | |
| b | = first array to print under eigenvectors (e.g., eigenvalues) | |
| c | = second array to print under eigenvectors (e.g., populations) | |
| m | = number of rows in matrix a | |
| n | = number of columns in matrix a (and length of b and c) | |
| out | = file pointer for output |
Definition at line 30 of file eigout.cc.
00031 { 00032 int ii,jj,kk,nn; 00033 int i,j; 00034 00035 ii=0;jj=0; 00036 L200: 00037 ii++; 00038 jj++; 00039 kk=10*jj; 00040 nn=n; 00041 if (nn > kk) nn=kk; 00042 fprintf (out,"\n"); 00043 for (i=ii; i <= nn; i++) fprintf(out," %5d",i); 00044 fprintf (out,"\n"); 00045 for (i=0; i < m; i++) { 00046 fprintf (out,"\n%5d",i+1); 00047 for (j=ii-1; j < nn; j++) { 00048 fprintf (out,"%12.7f",a[i][j]); 00049 } 00050 } 00051 fprintf (out,"\n"); 00052 fprintf (out,"\n "); 00053 for (j=ii-1; j < nn; j++) { 00054 fprintf(out,"%12.7f",b[j]); 00055 } 00056 fprintf (out,"\n"); 00057 fprintf (out,"\n "); 00058 for (j=ii-1; j < nn; j++) { 00059 fprintf(out,"%12.7f",c[j]); 00060 } 00061 fprintf (out,"\n"); 00062 if (n <= kk) { 00063 fflush(out); 00064 return; 00065 } 00066 ii=kk; goto L200; 00067 }
| void eigsort | ( | double * | d, | |
| double ** | v, | |||
| int | n | |||
| ) |
eigsort(): Sort the eigenvalues in d and eigenvectors in v in ascending (n>0) or descending (n<0) order. abs(n) is the number of eigenvalues.
| d | = array of eigenvalues | |
| v | = matrix of eigenvectors (each column is an eigenvector) Note: seems to assume v is a square matrix, could be a problem if, e.g., nmo != nso. | |
| n | = abs(n) is the number of eigenvalues/cols of v. Use n>0 to sort in ascending order, n<0 to sort in descending order |
Definition at line 28 of file eigsort.cc.
Referenced by rsp(), and sq_rsp().
00029 { 00030 int i,j,k; 00031 double p; 00032 00033 /* Modified by Ed Valeev - if n is negative, 00034 sort eigenvalues in descending order */ 00035 00036 if (n >= 0) { 00037 for (i=0; i < n-1 ; i++) { 00038 k=i; 00039 p=d[i]; 00040 for (j=i+1; j < n; j++) { 00041 if (d[j] < p) { 00042 k=j; 00043 p=d[j]; 00044 } 00045 } 00046 if (k != i) { 00047 d[k]=d[i]; 00048 d[i]=p; 00049 for (j=0; j < n; j++) { 00050 p=v[j][i]; 00051 v[j][i]=v[j][k]; 00052 v[j][k]=p; 00053 } 00054 } 00055 } 00056 } 00057 else { 00058 n = abs(n); 00059 for (i=0; i < n-1 ; i++) { 00060 k=i; 00061 p=d[i]; 00062 for (j=i+1; j < n; j++) { 00063 if (d[j] > p) { 00064 k=j; 00065 p=d[j]; 00066 } 00067 } 00068 if (k != i) { 00069 d[k]=d[i]; 00070 d[i]=p; 00071 for (j=0; j < n; j++) { 00072 p=v[j][i]; 00073 v[j][i]=v[j][k]; 00074 v[j][k]=p; 00075 } 00076 } 00077 } 00078 } 00079 }
| void eivout | ( | double ** | a, | |
| double * | b, | |||
| int | m, | |||
| int | n, | |||
| FILE * | out | |||
| ) |
eivout: Print out eigenvectors and eigenvalues to the output file
| a | = eigenvectors | |
| b | = eigenvalues | |
| m | = rows of a | |
| n | = columns of a | |
| out | = output file pointer |
Definition at line 24 of file eivout.cc.
00025 { 00026 int ii,jj,kk,nn; 00027 int i,j; 00028 00029 ii=0;jj=0; 00030 L200: 00031 ii++; 00032 jj++; 00033 kk=10*jj; 00034 nn=n; 00035 if (nn > kk) nn=kk; 00036 fprintf (out,"\n"); 00037 for (i=ii; i <= nn; i++) fprintf(out," %5d",i); 00038 fprintf (out,"\n"); 00039 for (i=0; i < m; i++) { 00040 fprintf (out,"\n%5d",i+1); 00041 for (j=ii-1; j < nn; j++) { 00042 fprintf (out,"%12.7f",a[i][j]); 00043 } 00044 } 00045 fprintf (out,"\n"); 00046 fprintf (out,"\n "); 00047 for (j=ii-1; j < nn; j++) { 00048 fprintf(out,"%12.7f",b[j]); 00049 } 00050 fprintf (out,"\n"); 00051 if (n <= kk) { 00052 fflush(out); 00053 return; 00054 } 00055 ii=kk; goto L200; 00056 }
| void ffile | ( | FILE ** | fptr, | |
| char * | suffix, | |||
| int | code | |||
| ) |
ffile(): Open a PSI3 ASCII file for reading/writing. Returns a pointer to the new file.
| suffix | = name of the file, not including automatic prefix | |
| code | = 0 (write), 1 (write/append), 2 (read) |
Definition at line 28 of file ffile.cc.
Referenced by main(), psi::extrema::coord_base_carts::read_file11(), timer_done(), and psi::extrema::coord_base::write_opt().
00029 { 00030 char name[100]; 00031 00032 /* build the standard file name */ 00033 sprintf(name, "%s.%s", psi_file_prefix, suffix); 00034 00035 switch (code) { 00036 case 0: 00037 *fptr = fopen(name,"w+"); 00038 break; 00039 case 1: 00040 *fptr = fopen(name,"a+"); 00041 break; 00042 case 2: 00043 *fptr = fopen(name,"r+"); 00044 break; 00045 default: 00046 fprintf(stderr,"error in ffile: invalid code %d\n",code); 00047 } 00048 if (*fptr == NULL) { 00049 fprintf(stderr,"error in ffile: cannot open file %s\n", suffix); 00050 exit(PSI_RETURN_FAILURE); 00051 } 00052 }
| void ffile_noexit | ( | FILE ** | fptr, | |
| char * | suffix, | |||
| int | code | |||
| ) |
ffile_noexit(): Open a PSI3 ASCII file for reading/writing. Returns a pointer to the new file via an argument. This function is the same as ffile(), but will not exit if fopen() fails.
| suffix | = name of the file, not including automatic prefix | |
| code | = 0 (write), 1 (write/append), 2 (read) |
Definition at line 67 of file ffile.cc.
Referenced by psi::detcas::check_conv(), psi::extrema::deloc::deloc(), and psi::extrema::coord_base::read_opt().
00068 { 00069 char name[100]; 00070 00071 /* build the standard file name */ 00072 sprintf(name, "%s.%s", psi_file_prefix, suffix); 00073 00074 switch (code) { 00075 case 0: 00076 *fptr = fopen(name,"w+"); 00077 break; 00078 case 1: 00079 *fptr = fopen(name,"a+"); 00080 break; 00081 case 2: 00082 *fptr = fopen(name,"r+"); 00083 break; 00084 default: 00085 fprintf(stderr,"error in ffile_noexit: invalid code %d\n",code); 00086 } 00087 }
| void ffileb | ( | FILE ** | fptr, | |
| char * | suffix, | |||
| int | code | |||
| ) |
ffileb(): Open a PSI3 binary file for reading/writing. Returns a pointer to the new file.
| suffix | = name of the file, not including automatic prefix | |
| code | = 0 (write), 1 (write/append), 2 (read) |
Definition at line 101 of file ffile.cc.
00102 { 00103 char* name = (char*) malloc( (strlen(psi_file_prefix) + 00104 strlen(suffix) + 2)*sizeof(char) ); 00105 00106 /* build the standard file name */ 00107 sprintf(name, "%s.%s", psi_file_prefix, suffix); 00108 00109 switch (code) { 00110 case 0: 00111 *fptr = fopen(name,"wb"); 00112 break; 00113 case 1: 00114 *fptr = fopen(name,"ab"); 00115 break; 00116 case 2: 00117 *fptr = fopen(name,"rb"); 00118 break; 00119 default: 00120 fprintf(stderr,"error in ffileb: invalid code %d\n",code); 00121 } 00122 free(name); 00123 00124 if (*fptr == NULL) { 00125 fprintf(stderr,"error in ffileb: cannot open file %s\n", suffix); 00126 exit(PSI_RETURN_FAILURE); 00127 } 00128 }
| void ffileb_noexit | ( | FILE ** | fptr, | |
| char * | suffix, | |||
| int | code | |||
| ) |
ffileb_noexit(): Open a PSI3 binary file for reading/writing. Returns a pointer to the new file via an argument. This function is the same as ffileb(), but will not exit if fopen() fails.
| suffix | = name of the file, not including automatic prefix | |
| code | = 0 (write), 1 (write/append), 2 (read) |
Definition at line 143 of file ffile.cc.
00144 { 00145 char* name = (char*) malloc( (strlen(psi_file_prefix) + 00146 strlen(suffix) + 2)*sizeof(char) ); 00147 00148 /* build the standard file name */ 00149 sprintf(name, "%s.%s", psi_file_prefix, suffix); 00150 00151 switch (code) { 00152 case 0: 00153 *fptr = fopen(name,"wb"); 00154 break; 00155 case 1: 00156 *fptr = fopen(name,"ab"); 00157 break; 00158 case 2: 00159 *fptr = fopen(name,"rb"); 00160 break; 00161 default: 00162 fprintf(stderr,"error in ffileb_noexit: invalid code %d\n",code); 00163 } 00164 free(name); 00165 }
| void flin | ( | double ** | a, | |
| double * | b, | |||
| int | in, | |||
| int | im, | |||
| double * | det | |||
| ) |
flin(): solves linear equations A * x = b.
| a | = coefficient matrix | |
| b | = known vectors | |
| in | = dimension of a(in*in) | |
| im | = number of b vectors | |
| det | = pointer to hold determinant of matrix a |
Definition at line 29 of file flin.cc.
References init_array().
Referenced by pople().
00030 { 00031 int i,j,k,*indx; 00032 00033 indx = (int *) init_array(in); 00034 00035 ludcmp(a,in,indx,det); 00036 00037 for (i=0; i < in ; i++) *det *= a[i][i]; 00038 00039 for (j=0; j<im; j++) 00040 lubksb(a,in,indx,b+j*in); 00041 00042 free(indx); 00043 }
| void fndcor | ( | long int * | maxcrb, | |
| FILE * | infile, | |||
| FILE * | outfile | |||
| ) |
fndcor(): C translation of the Fortran version, to remove the need to link the library alloc, which also requires the linking of libparse, etc, etc...
This routine looks for the MEMORY keyword from input
| maxcrb | = long int ptr to hold size of maxcore in bytes | |
| infile | = file pointer to input file (eg input.dat) | |
| outfile | = file pointer to output file (eg output.dat) |
David Sherrill, February 1994 Revised to handle more than 2GB of memory by Ed Valeev, October 2000
Revised to return the default if memory keyword is missing and raised the default to 256 MB. TDC, January 2003
Definition at line 43 of file fndcor.cc.
References ip_count(), ip_data(), ip_exist(), and ip_string().
Referenced by main().
00044 { 00045 char type[20]; 00046 char *s; 00047 int count; 00048 long int maxcrr; /* maxcor in real words */ 00049 char *maxcrr_str; /* string representation of maxcrr */ 00050 double size; 00051 int errcod; 00052 00053 maxcrr = DEF_MAXCRR; /* set maxcor to default first */ 00054 00055 if(ip_exist("MEMORY",0)) { /* check if the keyword exists */ 00056 errcod = ip_count("MEMORY", &count, 0); 00057 if (errcod != IPE_OK) fndcor_abort(infile, outfile); 00058 else if (errcod == IPE_NOT_AN_ARRAY) { /* Scalar specification of MEMORY */ 00059 errcod = ip_string("MEMORY", &maxcrr_str, 0); 00060 if (errcod != IPE_OK) fndcor_abort(infile, outfile); 00061 maxcrr = atol(maxcrr_str); 00062 } 00063 /* Array specification of MEMORY */ 00064 else if (count == 1) { 00065 errcod = ip_string("MEMORY", &maxcrr_str, 0); 00066 if (errcod != IPE_OK) fndcor_abort(infile, outfile) ; 00067 maxcrr = atol(maxcrr_str); 00068 } 00069 else if (count == 2) { 00070 errcod = ip_data("MEMORY", "%lf", &size, 1, 0); 00071 if (errcod != IPE_OK) fndcor_abort(infile, outfile); 00072 errcod = ip_data("MEMORY", "%s", type, 1, 1); 00073 if (errcod != IPE_OK) fndcor_abort(infile, outfile); 00074 /* convert string to uppercase */ 00075 for (s=type; *s!='\0'; s++) { 00076 if (*s>='a' && *s <='z') *s = *s + 'A' - 'a'; 00077 } 00078 if ((strcmp(type, "R")==0) || (strcmp(type, "REAL")==0)) 00079 maxcrr = (long int) size; 00080 else if ((strcmp(type, "I")==0) || (strcmp(type, "INTEGER")==0)) 00081 maxcrr = (long int) (size * sizeof(int) / sizeof(double)); 00082 else if ((strcmp(type, "B")==0) || (strcmp(type, "BYTES")==0)) 00083 maxcrr = (long int) (size / sizeof(double)); 00084 else if ((strcmp(type, "KB")==0) || (strcmp(type, "KBYTES")==0)) 00085 maxcrr = (long int) (1000.0 * size / sizeof(double)); 00086 else if ((strcmp(type, "MB")==0) || (strcmp(type, "MBYTES")==0)) 00087 maxcrr = (long int) (1000000.0 * size / sizeof(double)); 00088 else if ((strcmp(type, "GB")==0) || (strcmp(type, "GBYTES")==0)) 00089 maxcrr = (long int) (1000000000.0 * size / sizeof(double)); 00090 else { 00091 fprintf(outfile, "bad data type, specify one of: \n") ; 00092 fprintf(outfile, "REAL, INTEGER, BYTES, KBYTES, MBYTES, or GBYTES\n"); 00093 fndcor_abort(infile, outfile); 00094 } 00095 } 00096 } 00097 00098 *maxcrb = maxcrr * sizeof(double); 00099 00100 return; 00101 }
| void free_block | ( | double ** | array | ) |
free_block(): Free a block matrix
| array | = pointer to matrix to be freed |
Definition at line 78 of file libciomr/block_matrix.cc.
| void free_int_matrix | ( | int ** | array | ) |
free_int_matrix(): Free a matrix of integers. Pass a pointer to the matrix.
| array | = pointer to integer matrix |
Definition at line 111 of file int_array.cc.
Referenced by ras_set(), ras_set2(), and psi::extrema::deloc::~deloc().
| void free_matrix | ( | double ** | array, | |
| unsigned long int | size | |||
| ) |
free_matrix(): Free a 2D matrix allocated with init_matrix().
| array | = matrix to free | |
| size | = number of rows (unsigned long to allow large matrices) |
Definition at line 61 of file init_matrix.cc.
Referenced by psi::cscf::check_rot(), psi::extrema::internals::compute_A(), psi::extrema::internals::compute_G(), psi::extrema::deloc::deloc(), psi::extrema::internals::grad_trans(), psi::extrema::coord_base::H_test(), mmult(), psi::extrema::zmat::print_c_grads(), psi::extrema::coord_base_carts::print_c_grads(), psi::extrema::zmat::print_carts(), psi::extrema::coord_base_carts::print_carts(), psi::extrema::coord_base::print_H(), sq_rsp(), psi::extrema::math_tools::update_bfgs(), psi::extrema::math_tools::update_ms(), psi::extrema::zmat::zmat(), psi::extrema::coord_base::~coord_base(), and psi::extrema::internals::~internals().
00062 { 00063 unsigned long int i; 00064 00065 for (i=0; i < size ; i++) { 00066 free(array[i]); 00067 } 00068 00069 free(array); 00070 }
| double* init_array | ( | unsigned long int | size | ) |
init_array(): This function initializes an array of doubles of length 'size' and returns a pointer to the first element
| size | = length of array (unsigned long to allow large arrays) |
Definition at line 24 of file init_array.cc.
Referenced by ael(), psi::extrema::internals::B_row_angle(), psi::extrema::internals::B_row_bond(), psi::extrema::internals::B_row_tors(), psi::extrema::zmat::back_transform(), psi::extrema::internals::back_transform(), psi::detcas::bfgs_hessian(), psi::detcas::calc_gradient(), psi::detcas::calc_hessian(), psi::extrema::coord_base_carts::coord_base_carts(), david(), psi::extrema::deloc::deloc(), psi::detcas::ds_hessian(), eri(), flin(), psi::extrema::coord_base::H_test(), invert_matrix(), psi::extrema::internals::mem_alloc(), psi::extrema::coord_base::mem_alloc(), psi::extrema::zmat::newton_step(), psi::extrema::math_tools::newton_step(), norm_const(), psi::extrema::math_tools::orthogonalize(), pople(), psi::detcas::rotate_orbs(), rsp(), psi::detcas::scale_gradient(), schmidt(), schmidt_add(), slaterdetvector_init(), sq_rsp(), psi::extrema::coord_base::update_Hi(), psi::extrema::math_tools::update_ms(), and psi::extrema::zmat::zmat().
00025 { 00026 double *array; 00027 00028 if ((array = (double *) malloc(size*(unsigned long int)sizeof(double))) 00029 == NULL) { 00030 fprintf(stderr,"init_array: trouble allocating memory \n"); 00031 fprintf(stderr,"size = %ld\n",size); 00032 exit(PSI_RETURN_FAILURE); 00033 } 00034 bzero(array,size*(unsigned long int)sizeof(double)); 00035 return(array); 00036 }
| int* init_int_array | ( | int | size | ) |
init_int_array(): Allocates memory for one-D array of ints of dimension 'size' and returns pointer to 1st element. Zeroes all elements.
Just modified the init_array() routine to do int's instead. This will avoid the temptation to allocate 5 integers by p = (int *) init_array(5/2), which is bad.
| size | = length of array to allocate |
C. David Sherrill
Definition at line 34 of file int_array.cc.
Referenced by psi::detcas::bfgs_hessian(), david(), psi::extrema::deloc::deloc(), get_frzcpi(), get_frzvpi(), invert_matrix(), main(), ras_set(), ras_set2(), reorder_qt(), reorder_qt_uhf(), and psi::extrema::zmat::zmat().
00035 { 00036 int *array; 00037 00038 if ((array = (int *) malloc(sizeof(int)*size))==NULL) { 00039 fprintf(stderr,"init_array: trouble allocating memory \n"); 00040 fprintf(stderr,"size = %d\n",size); 00041 exit(PSI_RETURN_FAILURE); 00042 } 00043 bzero(array,sizeof(int)*size); 00044 return(array); 00045 }
| int** init_int_matrix | ( | int | rows, | |
| int | cols | |||
| ) |
init_int_matrix(): Function initializes (allocates and clears) a matrix of integers with dimensions 'rows' by 'cols' and returns a pointer to it (ptr to first row ptr). The matrix layout is blocked, i.e. like produced by block_matrix()
| rows | = number of rows | |
| cols | = number of columns |
Definition at line 78 of file int_array.cc.
Referenced by ras_set(), and ras_set2().
00079 { 00080 int **array=NULL; 00081 int i; 00082 00083 if ((array = (int **) malloc(sizeof(int *)*rows))==NULL) { 00084 fprintf(stderr,"init_int_matrix: trouble allocating memory \n"); 00085 fprintf(stderr,"rows = %d\n", rows); 00086 exit(PSI_RETURN_FAILURE); 00087 } 00088 00089 if ((array[0] = (int *) malloc (sizeof(int)*cols*rows))==NULL) { 00090 fprintf(stderr,"init_int_matrix: trouble allocating memory \n"); 00091 fprintf(stderr,"rows = %d, cols = %d", rows, cols); 00092 exit(PSI_RETURN_FAILURE) ; 00093 } 00094 for (i=1; i<rows; i++) { 00095 array[i] = array[i-1] + cols; 00096 } 00097 bzero(array[0], sizeof(int)*cols*rows); 00098 00099 return array; 00100 }
| double** init_matrix | ( | unsigned long int | n, | |
| unsigned long int | m | |||
| ) |
init_matrix(): Initialize an nxm matrix of doubles and return a pointer to the first row. Note that this does not form a matrix which is necessarily contiguous in memory. Use block_matrix() for that.
| n | = number of rows (unsigned long to allow large matrices) | |
| m | = number of columns (unsigned long to allow large matrices) |
Definition at line 26 of file init_matrix.cc.
Referenced by psi::cscf::check_rot(), psi::extrema::internals::compute_A(), psi::extrema::internals::compute_G(), psi::extrema::deloc::deloc(), psi::extrema::internals::grad_trans(), psi::extrema::coord_base::H_test(), psi::extrema::internals::mem_alloc(), psi::extrema::coord_base::mem_alloc(), mmult(), psi::extrema::math_tools::orthogonalize(), psi::extrema::zmat::print_c_grads(), psi::extrema::coord_base_carts::print_c_grads(), psi::extrema::zmat::print_carts(), psi::extrema::coord_base_carts::print_carts(), psi::extrema::math_tools::rep_project(), psi::extrema::math_tools::rep_reduce(), sq_rsp(), psi::extrema::math_tools::update_bfgs(), and psi::extrema::math_tools::update_ms().
00027 { 00028 double **array=NULL; 00029 unsigned long int i; 00030 00031 if ((array = (double **) malloc(n*(unsigned long int)sizeof(double *))) 00032 ==NULL) { 00033 fprintf(stderr,"init_matrix: trouble allocating memory \n"); 00034 fprintf(stderr,"n = %ld\n",n); 00035 exit(PSI_RETURN_FAILURE); 00036 } 00037 00038 for (i = 0; i < n; i++) { 00039 if ((array[i] = (double *) malloc(m*(unsigned long int)sizeof(double))) 00040 ==NULL) { 00041 fprintf(stderr,"init_matrix: trouble allocating memory \n"); 00042 fprintf(stderr,"i = %ld m = %ld\n",i,m); 00043 exit(PSI_RETURN_FAILURE); 00044 } 00045 bzero(array[i],m*(unsigned long int)sizeof(double)); 00046 } 00047 return(array); 00048 }
| void mmult | ( | double ** | AF, | |
| int | ta, | |||
| double ** | BF, | |||
| int | tb, | |||
| double ** | CF, | |||
| int | tc, | |||
| int | nr, | |||
| int | nl, | |||
| int | nc, | |||
| int | add | |||
| ) |
mmult(): a reasonably fast matrix multiply (at least on the DEC3100) written by ETS
| AF | = first matrix to multiply | |
| ta | = if 1, transpose AF before multiplying; otherwise, 0 | |
| BF | = second matrix to multiply | |
| tb | = if 1, transpose BF before multiplying; otherwise 0 | |
| CF | = matrix to hold result of AF*BF | |
| tc | = if 1, transpose CF after the multiplication; otherwise 0 | |
| nr | = number of rows of AF | |
| nl | = number of cols of AF and rows of BF | |
| nc | = number of cols of BF | |
| add | = if 1, add AF*BF to the matrix passed in as CF; else 0 |
nr,nl,nc are the number of rows,links,and columns in the final matrices to be multiplied together if ta=0 AF should have the dimensions nr x nl if ta=1 AF should have the dimensions nl x nr if tb=0 BF should have the dimensions nl x nc if tb=1 BF should have the dimensions nc x nl if tc=0 CF should have the dimensions nr x nc if tc=1 CF should have the dimensions nc x nr
Definition at line 46 of file mmult.cc.
References free_matrix(), and init_matrix().
Referenced by psi::cscf::check_rot(), psi::extrema::internals::compute_A(), psi::extrema::internals::compute_G(), psi::extrema::deloc::deloc(), psi::extrema::internals::grad_trans(), mxmb(), and psi::extrema::math_tools::update_bfgs().
00048 { 00049 int odd_nr,odd_nc,odd_nl; 00050 int i,j,k,ij; 00051 double t00,t01,t10,t11; 00052 double **a,**b; 00053 double *att,*bt; 00054 double *at1,*bt1; 00055 00056 if(!aa) { 00057 aa = (double **) init_matrix(nr,nl); 00058 bb = (double **) init_matrix(nc,nl); 00059 keep_nr = nr; 00060 keep_nl = nl; 00061 keep_nc = nc; 00062 } 00063 00064 if(nl > keep_nl) { 00065 free_matrix(aa,keep_nr); 00066 free_matrix(bb,keep_nc); 00067 keep_nl = nl; 00068 keep_nr = (nr > keep_nr) ? nr : keep_nr; 00069 keep_nc = (nc > keep_nc) ? nc : keep_nc; 00070 aa = (double **) init_matrix(keep_nr,keep_nl); 00071 bb = (double **) init_matrix(keep_nc,keep_nl); 00072 } 00073 if(nr > keep_nr) { 00074 free_matrix(aa,keep_nr); 00075 keep_nr = nr; 00076 aa = (double **) init_matrix(keep_nr,keep_nl); 00077 } 00078 if(nc > keep_nc) { 00079 free_matrix(bb,keep_nc); 00080 keep_nc = nc; 00081 bb = (double **) init_matrix(keep_nc,keep_nl); 00082 } 00083 00084 odd_nr = (nr)%2; 00085 odd_nc = (nc)%2; 00086 odd_nl = (nl)%2; 00087 00088 a=aa; 00089 if(ta) 00090 for(i=0; i < nr ; i++) 00091 for(j=0; j < nl ; j++) 00092 a[i][j] = AF[j][i]; 00093 else 00094 a=AF; 00095 00096 b=bb; 00097 if(tb) 00098 b=BF; 00099 else 00100 for(i=0; i < nc ; i++) 00101 for(j=0; j < nl ; j++) 00102 b[i][j] = BF[j][i]; 00103 00104 for(j=0; j < nc-1 ; j+=2) { 00105 for(i=0; i < nr-1 ; i+=2) { 00106 att=a[i]; bt=b[j]; 00107 at1=a[i+1]; bt1=b[j+1]; 00108 if(add) { 00109 if(tc) { 00110 t00 = CF[j][i]; 00111 t01 = CF[j+1][i]; 00112 t10 = CF[j][i+1]; 00113 t11 = CF[j+1][i+1]; 00114 } 00115 else { 00116 t00 = CF[i][j]; 00117 t01 = CF[i][j+1]; 00118 t10 = CF[i+1][j]; 00119 t11 = CF[i+1][j+1]; 00120 } 00121 } 00122 else t00=t01=t10=t11=0.0; 00123 for(k=nl; k ; k--,att++,bt++,at1++,bt1++) { 00124 t00 += *att * *bt; 00125 t01 += *att * *bt1; 00126 t10 += *at1 * *bt; 00127 t11 += *at1 * *bt1; 00128 } 00129 if(tc) { 00130 CF[j][i]=t00; 00131 CF[j+1][i]=t01; 00132 CF[j][i+1]=t10; 00133 CF[j+1][i+1]=t11; 00134 } 00135 else { 00136 CF[i][j]=t00; 00137 CF[i][j+1]=t01; 00138 CF[i+1][j]=t10; 00139 CF[i+1][j+1]=t11; 00140 } 00141 } 00142 if(odd_nr) { 00143 att=a[i]; bt=b[j]; 00144 bt1=b[j+1]; 00145 if(add) { 00146 if(tc) { 00147 t00 = CF[j][i]; 00148 t01 = CF[j+1][i]; 00149 } 00150 else { 00151 t00 = CF[i][j]; 00152 t01 = CF[i][j+1]; 00153 } 00154 } 00155 else t00=t01=0.0; 00156 for(k= nl; k ; k--,att++,bt++,bt1++) { 00157 t00 += *att * *bt; 00158 t01 += *att * *bt1; 00159 } 00160 if(tc) { 00161 CF[j][i]=t00; 00162 CF[j+1][i]=t01; 00163 } 00164 else { 00165 CF[i][j]=t00; 00166 CF[i][j+1]=t01; 00167 } 00168 } 00169 } 00170 if(odd_nc) { 00171 for(i=0; i < nr-1 ; i+=2) { 00172 att=a[i]; bt=b[j]; 00173 at1=a[i+1]; 00174 if(add) { 00175 if(tc) { 00176 t00 = CF[j][i]; 00177 t10 = CF[j][i+1]; 00178 } 00179 else { 00180 t00 = CF[i][j]; 00181 t10 = CF[i+1][j]; 00182 } 00183 } 00184 else t00=t10=0.0; 00185 for(k= nl; k ; k--,att++,bt++,at1++) { 00186 t00 += *att * *bt; 00187 t10 += *at1 * *bt; 00188 } 00189 if(tc) { 00190 CF[j][i]=t00; 00191 CF[j][i+1]=t10; 00192 } 00193 else { 00194 CF[i][j]=t00; 00195 CF[i+1][j]=t10; 00196 } 00197 } 00198 if(odd_nr) { 00199 att=a[i]; bt=b[j]; 00200 if(add) 00201 t00 = (tc) ? CF[j][i] : CF[i][j]; 00202 else t00=0.0; 00203 for(k=nl; k ; k--,att++,bt++) 00204 t00 += *att * *bt; 00205 if(tc) CF[j][i]=t00; 00206 else CF[i][j]=t00; 00207 } 00208 } 00209 }
| void mosort | ( | double * | d, | |
| double ** | v, | |||
| int * | sym, | |||
| int | nso, | |||
| int | nmo | |||
| ) |
mosort(): Minor modification of eigsort() to also sort a series of irrep labels.
| d | = array of eigenvalues | |
| v | = matrix of eigenvectors (each column is an eigenvector) | |
| sym | = array of symmetry ID's (irreps) | |
| nso | = number of rows in v | |
| nmo | = abs(nmo) is the number of eigenvalues/cols of v. Use nmo>0 to sort in ascending order, nmo<0 to sort in descending order |
TDC, 6/03
Definition at line 99 of file eigsort.cc.
00100 { 00101 int i, j, k, l; 00102 double p; 00103 00104 if(nmo > 0) { 00105 for (i=0; i < nmo-1 ; i++) { 00106 k=i; 00107 p=d[i]; 00108 for (j=i+1; j < nmo; j++) { 00109 if (d[j] < p) { 00110 k=j; 00111 p=d[j]; 00112 } 00113 } 00114 if (k != i) { 00115 d[k]=d[i]; 00116 d[i]=p; 00117 00118 l = sym[i]; 00119 sym[i] = sym[k]; 00120 sym[k] = l; 00121 00122 for (j=0; j < nso; j++) { 00123 p=v[j][i]; 00124 v[j][i]=v[j][k]; 00125 v[j][k]=p; 00126 } 00127 } 00128 } 00129 } 00130 else if(nmo < 0) { 00131 nmo = abs(nmo); 00132 for (i=0; i < nmo-1 ; i++) { 00133 k=i; 00134 p=d[i]; 00135 for (j=i+1; j < nmo; j++) { 00136 if (d[j] > p) { 00137 k=j; 00138 p=d[j]; 00139 } 00140 } 00141 if (k != i) { 00142 d[k]=d[i]; 00143 d[i]=p; 00144 00145 l = sym[i]; 00146 sym[i] = sym[k]; 00147 sym[k] = l; 00148 00149 for (j=0; j < nso; j++) { 00150 p=v[j][i]; 00151 v[j][i]=v[j][k]; 00152 v[j][k]=p; 00153 } 00154 } 00155 } 00156 } 00157 }
| void mxmb | ( | double ** | a, | |
| int | ia, | |||
| int | ja, | |||
| double ** | b, | |||
| int | ib, | |||
| int | jb, | |||
| double ** | c, | |||
| int | ic, | |||
| int | jc, | |||
| int | nrow, | |||
| int | nlnk, | |||
| int | ncol | |||
| ) |
mxmb: multiplies two rectangular matrices together (wrapper for mmult). Deprecated; use C_DGEMM instead.
| a | = first matrix to multiply | |
| ia | = if 1, normal multiplication of a | |
| ja | = if 1, transpose a before multiplication | |
| b | = second matrix to multiply | |
| ib | = if 1, normal multiplication of b | |
| jb | = if 1, transpose b before multiplication | |
| c | = matrix to store the result | |
| ic | = if 1, normal multiplication into c | |
| jb | = if 1, transpose c after multiplication | |
| nrow | = number of rows of a | |
| nlnk | = number of columns of a and rows of b | |
| ncol | = number of columns of b |
Definition at line 41 of file mxmb.cc.
References mmult().
00043 { 00044 if (ic == 1) { 00045 if (ia == 1) { 00046 if (ib == 1) { 00047 mmult(a,0,b,0,c,0,nrow,nlnk,ncol,0); 00048 } 00049 else { 00050 if (jb == 1) { 00051 mmult(a,0,b,1,c,0,nrow,nlnk,ncol,0); 00052 } 00053 else { 00054 mxmbol(a,ia,ja,b,ib,jb,c,ic,jc,nrow,nlnk,ncol); 00055 } 00056 } 00057 } 00058 else { 00059 if (ja == 1) { 00060 if (ib == 1) { 00061 mmult(a,1,b,0,c,0,nrow,nlnk,ncol,0); 00062 } 00063 else { 00064 if (jb == 1) { 00065 mmult(a,1,b,1,c,0,nrow,nlnk,ncol,0); 00066 } 00067 else { 00068 mxmbol(a,ia,ja,b,ib,jb,c,ic,jc,nrow,nlnk,ncol); 00069 } 00070 } 00071 } 00072 else { 00073 mxmbol(a,ia,ja,b,ib,jb,c,ic,jc,nrow,nlnk,ncol); 00074 } 00075 } 00076 } 00077 else { 00078 if (jc == 1) { 00079 if (ia == 1) { 00080 if (ib == 1) { 00081 mmult(a,0,b,0,c,1,nrow,nlnk,ncol,0); 00082 } 00083 else { 00084 if (jb == 1) { 00085 mmult(a,0,b,1,c,1,nrow,nlnk,ncol,0); 00086 } 00087 else { 00088 mxmbol(a,ia,ja,b,ib,jb,c,ic,jc,nrow,nlnk,ncol); 00089 } 00090 } 00091 } 00092 else { 00093 if (ja == 1) { 00094 if (ib == 1) { 00095 mmult(a,1,b,0,c,1,nrow,nlnk,ncol,0); 00096 } 00097 else { 00098 if (jb == 1) { 00099 mmult(a,1,b,1,c,1,nrow,nlnk,ncol,0); 00100 } 00101 else { 00102 mxmbol(a,ia,ja,b,ib,jb,c,ic,jc,nrow,nlnk,ncol); 00103 } 00104 } 00105 } 00106 else { 00107 mxmbol(a,ia,ja,b,ib,jb,c,ic,jc,nrow,nlnk,ncol); 00108 } 00109 } 00110 } 00111 else { 00112 mxmbol(a,ia,ja,b,ib,jb,c,ic,jc,nrow,nlnk,ncol); 00113 } 00114 } 00115 }
| void print_array | ( | double * | a, | |
| int | m, | |||
| FILE * | out | |||
| ) |
print_array(): Prints a lower-triangle of a symmetric matrix packed as an array of doubles.
| a | = array (packed lower triangle of matrix) to print | |
| m | = dimension of matrix (mxm) | |
| out | = file pointer for output |
Definition at line 23 of file print_array.cc.
Referenced by iwl_rdone().
00024 { 00025 int ii,jj,kk,mm,nn,ll; 00026 int i,j,k,i1,i2; 00027 00028 ii=0;jj=0; 00029 L200: 00030 ii++; 00031 jj++; 00032 kk=10*jj; 00033 nn = kk + kk*(kk-1)/2; 00034 mm=m; 00035 if (m > kk) mm=kk; 00036 ll = 2*(mm-ii+1)+1; 00037 fprintf (out,"\n"); 00038 for (i=ii; i <= mm; i++) fprintf(out," %5d",i); 00039 fprintf (out,"\n"); 00040 for (i=ii; i <= m; i++) { 00041 i1=i*(i-1)/2+ii; 00042 i2=i+i*(i-1)/2; 00043 if (i2 > nn) i2 = i1+9; 00044 fprintf (out,"\n%5d",i); 00045 for (j=i1; j <= i2; j++) { 00046 fprintf (out,"%12.7f",a[j-1]); 00047 } 00048 } 00049 if (m <= kk) { 00050 fprintf(out,"\n"); 00051 fflush(out); 00052 return; 00053 } 00054 ii=kk; goto L200; 00055 }
| void print_int_mat | ( | int ** | a, | |
| int | m, | |||
| int | n, | |||
| FILE * | out | |||
| ) |
print_int_mat(): Print a matrix of integers. Pass the matrix, the number of rows and columns, and the output file pointer.
| a | = integer matrix to print | |
| m | = number of rows in matrix | |
| n | = number of columns in matrix | |
| out | = FILE pointer to output file |
Definition at line 151 of file int_array.cc.
00152 { 00153 int ii,jj,kk,nn,ll; 00154 int i,j,k; 00155 00156 ii=0;jj=0; 00157 L200: 00158 ii++; 00159 jj++; 00160 kk=10*jj; 00161 nn=n; 00162 if (nn > kk) nn=kk; 00163 ll = 2*(nn-ii+1)+1; 00164 fprintf (out,"\n "); 00165 for (i=ii; i <= nn; i++) fprintf(out," %5d",i); 00166 fprintf (out,"\n"); 00167 for (i=0; i < m; i++) { 00168 fprintf (out,"\n%5d",i+1); 00169 for (j=ii-1; j < nn; j++) { 00170 fprintf (out,"%8d",a[i][j]); 00171 } 00172 } 00173 fprintf (out,"\n"); 00174 if (n <= kk) { 00175 fflush(out); 00176 return; 00177 } 00178 ii=kk; goto L200; 00179 }
| void print_mat | ( | double ** | a, | |
| int | m, | |||
| int | n, | |||
| FILE * | out | |||
| ) |
print_mat: Print a matrix a of dimensions mxn to file pointer out.
| a | = matrix to print | |
| m | = number of rows in matrix | |
| n | = number of columns in matrix | |
| out | = file pointer for output |
Definition at line 23 of file print_mat.cc.
00024 { 00025 int ii,jj,kk,nn,ll; 00026 int i,j,k; 00027 00028 ii=0;jj=0; 00029 L200: 00030 ii++; 00031 jj++; 00032 kk=10*jj; 00033 nn=n; 00034 if (nn > kk) nn=kk; 00035 ll = 2*(nn-ii+1)+1; 00036 fprintf (out,"\n"); 00037 for (i=ii; i <= nn; i++) fprintf(out," %5d",i); 00038 fprintf (out,"\n"); 00039 for (i=0; i < m; i++) { 00040 fprintf (out,"\n%5d",i+1); 00041 for (j=ii-1; j < nn; j++) { 00042 fprintf (out,"%12.7f",a[i][j]); 00043 } 00044 } 00045 fprintf (out,"\n"); 00046 if (n <= kk) { 00047 fflush(out); 00048 return; 00049 } 00050 ii=kk; goto L200; 00051 }
| char* psi_fprefix | ( | ) |
This function returns the PSI file prefix
Arguments: none
Returns: the pointer to the string containing the PSI file prefix if it has been determined, NULL otherwise
Definition at line 291 of file psi_start.cc.
| char* psi_ifname | ( | ) |
This function returns the input file name
Arguments: none
Returns: the pointer to the string containing the input file name if it has been determined, NULL otherwise
Definition at line 257 of file psi_start.cc.
| char* psi_ofname | ( | ) |
This function returns the output file name
Arguments: none
Returns: the pointer to the string containing the output file name if it has been determined, NULL otherwise
Definition at line 274 of file psi_start.cc.
| int psi_start | ( | FILE ** | infile, | |
| FILE ** | outfile, | |||
| char ** | psi_file_prefix, | |||
| int | argc, | |||
| char * | argv[], | |||
| int | overwrite_output | |||
| ) |
psi_start(): This function initializes the input, output files, file prefix, etc., by checking command line arguments and environmental variables. It also initializes the Input Parsing library.
| argc | = number of command-line arguments passed | |
| argv | = command-line arguments | |
| overwrite | = whether to overwrite output file (1) or append to it (0). Most PSI modules will want to append. |
Definition at line 38 of file psi_start.cc.
References ip_string().
00040 { 00041 int i, errcod; 00042 /* state flags */ 00043 int found_if_np = 0; /* found input file name without -f */ 00044 int found_of_np = 0; /* found output file name without -o */ 00045 int found_fp_np = 0; /* found file prefix name without -p */ 00046 int found_if_p = 0; /* found input file name with -f */ 00047 int found_of_p = 0; /* found output file name with -o */ 00048 int found_fp_p = 0; /* found file prefix name with -p */ 00049 char *cfname = NULL; 00050 char *userhome; 00051 FILE *psirc; 00052 char *arg; 00053 char *tmpstr1; 00054 00055 /* process command-line arguments in sequence */ 00056 for(i=0; i<argc; i++) { 00057 arg = argv[i]; 00058 if (!strcmp(arg,"-f") && !found_if_p) { 00059 ifname = argv[++i]; 00060 found_if_p = 1; 00061 } 00062 else if (!strcmp(arg,"-o") && !found_of_p) { 00063 ofname = argv[++i]; 00064 found_of_p = 1; 00065 } 00066 else if (!strcmp(arg,"-p") && !found_fp_p) { 00067 fprefix = argv[++i]; 00068 found_fp_p = 1; 00069 } 00070 else if (arg[0] == '-') { 00071 fprintf(stderr, "Error: unrecognized command-line argument %s\n", arg); 00072 return(PSI_RETURN_FAILURE); 00073 } 00074 else if (!found_if_np) { 00075 ifname = arg; 00076 found_if_np = 1; 00077 } 00078 else if (!found_of_np) { 00079 ofname = arg; 00080 found_of_np = 1; 00081 } 00082 else if (!found_fp_np) { 00083 fprefix = arg; 00084 found_fp_np = 1; 00085 } 00086 else { 00087 fprintf(stderr, "Error: too many command-line arguments given\n"); 00088 return(PSI_RETURN_FAILURE); 00089 } 00090 } 00091 00092 00093 /* check if some args were specified in both prefixed and nonprefixed form */ 00094 if (found_if_p && found_if_np) { 00095 fprintf(stderr, 00096 "Error: input file name specified both with and without -f\n"); 00097 fprintf(stderr, 00098 "Usage: (module) [options] -f input -o output [-p prefix] OR\n"); 00099 fprintf(stderr, " (module) [options] input output [prefix]\n"); 00100 return(PSI_RETURN_FAILURE); 00101 } 00102 if (found_of_p && found_of_np) { 00103 fprintf(stderr, 00104 "Error: output file name specified both with and without -o\n"); 00105 fprintf(stderr, 00106 "Usage: (module) [options] -f input -o output [-p prefix] OR\n"); 00107 fprintf(stderr, " (module) [options] input output [prefix]\n"); 00108 return(PSI_RETURN_FAILURE); 00109 } 00110 if (found_fp_p && found_fp_np) { 00111 fprintf(stderr, 00112 "Error: file prefix specified both with and without -p\n"); 00113 fprintf(stderr, 00114 "Usage: (module) [options] -f input -o output -p prefix OR\n"); 00115 fprintf(stderr, " (module) [options] input output prefix\n"); 00116 return(PSI_RETURN_FAILURE); 00117 } 00118 00119 00120 /* if some args were not specified on command-line - check the environment */ 00121 if (ifname == NULL) 00122 ifname = getenv("PSI_INPUT"); 00123 if (ofname == NULL) 00124 ofname = getenv("PSI_OUTPUT"); 00125 if (fprefix == NULL) 00126 fprefix = getenv("PSI_PREFIX"); 00127 00128 /* if some arguments still not defined - assign default values */ 00129 if (ifname == NULL) 00130 ifname = strdup("input.dat"); 00131 if (ofname == NULL) 00132 ofname = strdup("output.dat"); 00133 /* default prefix is not assigned here yet because need to check 00134 input file first */ 00135 00136 /* open input and output files */ 00137 if(ifname[0]=='-' && ifname[1]=='\x0') 00138 *infile=stdin; 00139 else 00140 *infile = fopen(ifname, "r"); 00141 if (*infile == NULL) { 00142 fprintf(stderr, "Error: could not open input file %s\n",ifname); 00143 return(PSI_RETURN_FAILURE); 00144 } 00145 if (overwrite_output) 00146 { 00147 if(ofname[0]=='-' && ofname[1]=='\x0') 00148 *outfile=stdout; 00149 else 00150 *outfile = fopen(ofname, "w"); 00151 } 00152 else 00153 { 00154 if(ofname[0]=='-' && ofname[1]=='\x0') 00155 *outfile=stdout; 00156 else 00157 *outfile = fopen(ofname, "a"); 00158 } 00159 if (*outfile == NULL) { 00160 fprintf(stderr, "Error: could not open output file %s\n",ofname); 00161 return(PSI_RETURN_FAILURE); 00162 } 00163 00164 /* initialize libipv1 */ 00165 ip_set_uppercase(1); 00166 ip_initialize(*infile, *outfile); 00167 ip_cwk_clear(); 00168 00169 /* open user's PSI configuration file (default, $HOME/.psirc) */ 00170 cfname = getenv("PSI_RC"); 00171 if (cfname == NULL) { 00172 userhome = getenv("HOME"); 00173 cfname = (char *) malloc((10+strlen(userhome))*sizeof(char)); 00174 sprintf(cfname, "%s%s", userhome, "/.psirc"); 00175 psirc = fopen(cfname, "r"); 00176 free(cfname); 00177 } 00178 else psirc = fopen(cfname, "r"); 00179 if(psirc != NULL) { 00180 ip_append(psirc, stderr); 00181 fclose(psirc); 00182 } 00183 00184 /* lastly, everybody needs DEFAULT and PSI sections */ 00185 ip_cwk_add(":DEFAULT"); 00186 ip_cwk_add(":PSI"); 00187 00188 /* if prefix still NULL - check input file */ 00189 if (fprefix == NULL) 00190 errcod = ip_string(":DEFAULT:FILES:DEFAULT:NAME",&fprefix,0); 00191 if (fprefix == NULL) 00192 errcod = ip_string(":DEFAULT:NAME",&fprefix,0); 00193 if (fprefix == NULL) 00194 errcod = ip_string(":PSI:FILES:DEFAULT:NAME",&fprefix,0); 00195 if (fprefix == NULL) 00196 errcod = ip_string(":PSI:NAME",&fprefix,0); 00197 00198 /* copy over file prefix, etc. into their appropriate variables */ 00199 if (fprefix == NULL) { 00200 fprefix = strdup(PSI_DEFAULT_FILE_PREFIX); 00201 } 00202 *psi_file_prefix = strdup(fprefix); 00203 00204 /* other Psi modules called by this module should read from the same input 00205 file set the value of PSI_INPUT for the duration of this run */ 00206 #if HAVE_PUTENV 00207 tmpstr1 = (char *) malloc(11+strlen(ifname)); 00208 sprintf(tmpstr1, "PSI_INPUT=%s", ifname); 00209 putenv(tmpstr1); /* note potential memory leak */ 00210 #elif HAVE_SETENV 00211 setenv("PSI_OUTPUT",ifname,1); 00212 #else 00213 #error "Have neither putenv nor setenv. Something must be very broken on this system." 00214 #endif 00215 00216 /* By default, other Psi modules called by this module should write to 00217 the same output file set the value of PSI_OUTPUT for the duration of 00218 this run */ 00219 #if HAVE_PUTENV 00220 tmpstr1 = (char *) malloc(12+strlen(ofname)); 00221 sprintf(tmpstr1, "PSI_OUTPUT=%s", ofname); 00222 putenv(tmpstr1); /* note potential memory leak */ 00223 #elif HAVE_SETENV 00224 setenv("PSI_OUTPUT",ofname,1); 00225 #else 00226 #error "Have neither putenv nor setenv. Something must be very broken on this system." 00227 #endif 00228 00229 /* By default, other Psi modules called by this module should use the same 00230 prefix too set the value of PSI_PREFIX for the duration of this run */ 00231 #if HAVE_PUTENV 00232 tmpstr1 = (char *) malloc(12+strlen(fprefix)); 00233 sprintf(tmpstr1, "PSI_PREFIX=%s", fprefix); 00234 putenv(tmpstr1); /* note potential memory leak */ 00235 #elif HAVE_SETENV 00236 setenv("PSI_PREFIX",fprefix,1); 00237 #else 00238 #error "Have neither putenv nor setenv. Something must be very broken on this system." 00239 #endif 00240 00241 return(PSI_RETURN_SUCCESS); 00242 }
| int psi_stop | ( | FILE * | infile, | |
| FILE * | outfile, | |||
| char * | psi_file_prefix | |||
| ) |
psi_stop(): This function closes input and output files and deinitializes Input Parsing library.
Arguments: none
Returns: one of standard PSI error codes
Definition at line 26 of file psi_stop.cc.
00027 { 00028 ip_done(); 00029 free(psi_file_prefix); 00030 fclose(outfile); 00031 fclose(infile); 00032 00033 return(PSI_RETURN_SUCCESS); 00034 }
| void rsp | ( | int | nm, | |
| int | n, | |||
| int | nv, | |||
| double * | array, | |||
| double * | e_vals, | |||
| int | matz, | |||
| double ** | e_vecs, | |||
| double | toler | |||
| ) |
rsp(): diagonalize a symmetric matrix in packed (lower triangular) form in 'array'. For square symmetric matrices, see sq_rsp().
| nm | = rows of matrix | |
| n | = columns of matrix | |
| nv | = number of elements in lower triangle (n*(n+1)/2) | |
| array | = matrix to diagonalize (packed as linear array) | |
| e_vals | = array to hold eigenvalues | |
| matz | = 0 (no eigenvectors, eigenvals in ascending order) = 1 (eigenvectors and eigenvalues in ascending order) = 2 (no eigenvectors, eigenvalues in descending order) = 3 (eigenvectors and eigenvalues in descending order) | |
| e_vecs | = matrix of eigenvectors (one column for each eigvector) | |
| toler | = tolerance for eigenvalues? Often 1.0E-14. |
Definition at line 40 of file rsp.cc.
References eigsort(), init_array(), tqli(), and tred2().
00042 { 00043 int i, j, ii, ij, ierr; 00044 int ascend_order; 00045 double *fv1=NULL; 00046 /*double **temp=NULL;*/ 00047 double zero = 0.0; 00048 double one = 1.0; 00049 double sw; 00050 00051 /* Modified by Ed - matz can have values 0 through 3 */ 00052 00053 if ((matz > 3) || (matz < 0)) { 00054 matz = 0; 00055 ascend_order = 1; 00056 } 00057 else 00058 if (matz < 2) 00059 ascend_order = 1; /* Eigenvalues in ascending order */ 00060 else { 00061 matz -= 2; 00062 ascend_order = 0; /* Eigenvalues in descending order */ 00063 } 00064 00065 fv1 = (double *) init_array(n); 00066 /*temp = (double **) init_matrix(n,n);*/ 00067 00068 if (n > nm) { 00069 ierr = 10*n; 00070 fprintf(stderr,"n = %d is greater than nm = %d in rsp\n",n,nm); 00071 exit(PSI_RETURN_FAILURE); 00072 } 00073 00074 if (nv < (n*(n+1)/2)) { 00075 int num = n*(n+1)/2; 00076 ierr = 20*n; 00077 fprintf(stderr,"nv = %d is less than n*(n+1)/2 = %d in rsp\n",nv,num); 00078 exit(PSI_RETURN_FAILURE); 00079 } 00080 00081 for (i=0,ij=0; i < n; i++) { 00082 for (j=0; j <= i; j++,ij++) { 00083 e_vecs[i][j] = array[ij]; 00084 e_vecs[j][i] = array[ij]; 00085 } 00086 } 00087 00088 tred2(n,e_vecs,e_vals,fv1,matz); 00089 00090 for (i=0; i < n; i++) 00091 for (j=0; j < i; j++){ 00092 sw = e_vecs[i][j]; 00093 e_vecs[i][j] = e_vecs[j][i]; 00094 e_vecs[j][i] = sw; 00095 /*temp[i][j]=e_vecs[j][i];*/ 00096 } 00097 00098 tqli(n,e_vals,e_vecs,fv1,matz,toler); 00099 /*tqli(n,e_vals,temp,fv1,matz,toler);*/ 00100 00101 for (i=0; i < n; i++) 00102 for (j=0; j < i; j++){ 00103 sw = e_vecs[i][j]; 00104 e_vecs[i][j] = e_vecs[j][i]; 00105 e_vecs[j][i] = sw; 00106 /*e_vecs[i][j]=temp[j][i];*/ 00107 } 00108 00109 if (ascend_order) 00110 eigsort(e_vals,e_vecs,n); 00111 else 00112 eigsort(e_vals,e_vecs,-n); 00113 00114 free(fv1); 00115 /*free_matrix(temp,n);*/ 00116 }
| void sq_rsp | ( | int | nm, | |
| int | n, | |||
| double ** | array, | |||
| double * | e_vals, | |||
| int | matz, | |||
| double ** | e_vecs, | |||
| double | toler | |||
| ) |
sq_rsp(): diagomalize a symmetric square matrix ('array').
| nm | = rows of matrix | |
| n | = columns of matrix | |
| nv | = number of elements in lower triangle (n*(n+1)/2) | |
| array | = matrix to diagonalize | |
| e_vals | = array to hold eigenvalues | |
| matz | = 0 (no eigenvectors, eigenvals in ascending order) = 1 (eigenvectors and eigenvalues in ascending order) = 2 (no eigenvectors, eigenvalues in descending order) = 3 (eigenvectors and eigenvalues in descending order) | |
| e_vecs | = matrix of eigenvectors (one column for each eigvector) | |
| toler | = tolerance for eigenvalues? Often 1.0E-14. |
Definition at line 37 of file sq_rsp.cc.
References eigsort(), free_matrix(), init_array(), init_matrix(), tqli(), and tred2().
Referenced by ael(), david(), psi::extrema::deloc::deloc(), and psi::extrema::coord_base::H_test().
00039 { 00040 int i, j, ii, ij, ierr; 00041 int ascend_order; 00042 double *fv1, **temp; 00043 double zero = 0.0; 00044 double one = 1.0; 00045 00046 /* Modified by Ed - matz can have the values 0 through 3 */ 00047 00048 if ((matz > 3) || (matz < 0)) { 00049 matz = 0; 00050 ascend_order = 1; 00051 } 00052 else 00053 if (matz < 2) 00054 ascend_order = 1; /* Eigenvalues in ascending order */ 00055 else { 00056 matz -= 2; 00057 ascend_order = 0; /* Eigenvalues in descending order */ 00058 } 00059 00060 fv1 = (double *) init_array(n); 00061 temp = (double **) init_matrix(n,n); 00062 00063 if (n > nm) { 00064 ierr = 10*n; 00065 fprintf(stderr,"n = %d is greater than nm = %d in rsp\n",n,nm); 00066 exit(PSI_RETURN_FAILURE); 00067 } 00068 00069 for (i=0; i < n; i++) { 00070 for (j=0; j < n; j++) { 00071 e_vecs[i][j] = array[i][j]; 00072 } 00073 } 00074 00075 tred2(n,e_vecs,e_vals,fv1,matz); 00076 00077 for (i=0; i < n; i++) 00078 for (j=0; j < n; j++) 00079 temp[i][j]=e_vecs[j][i]; 00080 00081 tqli(n,e_vals,temp,fv1,matz,toler); 00082 00083 for (i=0; i < n; i++) 00084 for (j=0; j < n; j++) 00085 e_vecs[i][j]=temp[j][i]; 00086 00087 if (ascend_order) 00088 eigsort(e_vals,e_vecs,n); 00089 else 00090 eigsort(e_vals,e_vecs,(-1)*n); 00091 00092 free(fv1); 00093 free_matrix(temp,n); 00094 00095 }
| void sq_to_tri | ( | double ** | bmat, | |
| double * | amat, | |||
| int | size | |||
| ) |
sq_to_tri(): converts square matrix to lower triangle
| bmat | = matrix to convert | |
| amat | = array to put lower triangle of bmat into | |
| size | = number of rows/columns of bmat |
Definition at line 20 of file sq_to_tri.cc.
00021 { 00022 int i, j, ij; 00023 00024 ij=0; 00025 for(i=0; i < size; i++) { 00026 for(j=0 ; j <= i; j++) { 00027 amat[ij++] = bmat[i][j]; 00028 } 00029 } 00030 00031 }
| void tqli | ( | int | n, | |
| double * | d, | |||
| double ** | z, | |||
| double * | e, | |||
| int | matz, | |||
| double | toler | |||
| ) |
tqli(): diagonalizes tridiagonal matrix output by tred2. Gives only eigenvalues if matz=0, both eigenvalues and eigenvectors if matz=1
Definition at line 21 of file tqli.cc.
Referenced by rsp(), and sq_rsp().
00022 { 00023 register int k; 00024 int i,j,l,m,iter; 00025 double dd,g,r,s,c,p,f,b,h; 00026 double azi; 00027 00028 f=0.0; 00029 if (n == 1) { 00030 d[0]=z[0][0]; 00031 z[0][0] = 1.0; 00032 return; 00033 } 00034 00035 for (i=1; i < n ; i++) { 00036 e[i-1] = e[i]; 00037 } 00038 e[n-1] = 0.0; 00039 for (l=0; l < n; l++) { 00040 iter = 0; 00041 L1: 00042 for (m=l; m < n-1;m++) { 00043 dd = fabs(d[m]) + fabs(d[m+1]); 00044 #if 0 00045 if (fabs(e[m])+dd == dd) goto L2; 00046 #else 00047 if (fabs(e[m]) < toler) goto L2; 00048 #endif 00049 } 00050 m=n-1; 00051 L2: 00052 if (m != l) { 00053 if (iter++ == 30) { 00054 fprintf (stderr,"tqli not converging\n"); 00055 continue; 00056 #if 0 00057 exit(PSI_RETURN_FAILURE); 00058 #endif 00059 } 00060 00061 g = (d[l+1]-d[l])/(2.0*e[l]); 00062 r = sqrt(g*g + 1.0); 00063 g = d[m] - d[l] + e[l]/((g + DSIGN(r,g))); 00064 s=1.0; 00065 c=1.0; 00066 p=0.0; 00067 for (i=m-1; i >= l; i--) { 00068 f = s*e[i]; 00069 b = c*e[i]; 00070 if (fabs(f) >= fabs(g)) { 00071 c = g/f; 00072 r = sqrt(c*c + 1.0); 00073 e[i+1] = f*r; 00074 s=1.0/r; 00075 c *= s; 00076 } 00077 else { 00078 s = f/g; 00079 r = sqrt(s*s + 1.0); 00080 e[i+1] = g*r; 00081 c = 1.0/r; 00082 s *= c; 00083 } 00084 g = d[i+1] - p; 00085 r = (d[i]-g)*s + 2.0*c*b; 00086 p = s*r; 00087 d[i+1] = g+p; 00088 g = c*r-b; 00089 00090 if (matz) { 00091 double *zi = z[i]; 00092 double *zi1 = z[i+1]; 00093 for (k=n; k ; k--,zi++,zi1++) { 00094 azi = *zi; 00095 f = *zi1; 00096 *zi1 = azi*s + c*f; 00097 *zi = azi*c - s*f; 00098 } 00099 } 00100 } 00101 00102 d[l] -= p; 00103 e[l] = g; 00104 e[m] = 0.0; 00105 goto L1; 00106 } 00107 } 00108 }
| void tred2 | ( | int | n, | |
| double ** | a, | |||
| double * | d, | |||
| double * | e, | |||
| int | matz | |||
| ) |
tred2(): converts symmetric matrix to a tridagonal form for use in tqli
if matz = 0, only find eigenvalues, else find both eigenvalues and eigenvectors
Returns: none
Definition at line 22 of file tred2.cc.
Referenced by rsp(), and sq_rsp().
00022 { 00023 int i, j, k, l, il, ik, jk, kj; 00024 double f, g, h, hh, scale, scale_inv, h_inv; 00025 double temp; 00026 00027 if (n == 1) 00028 return; 00029 00030 for (i=n-1; i > 0; i--) { 00031 l = i-1; 00032 h = 0.0; 00033 scale = 0.0; 00034 if (l) { 00035 for (k=0; k <= l; k++) { 00036 scale += fabs(a[i][k]); 00037 } 00038 if (scale == 0.0) { 00039 e[i] = a[i][l]; 00040 } else { 00041 scale_inv=1.0/scale; 00042 for (k=0; k <= l; k++) { 00043 a[i][k] *= scale_inv; 00044 h += a[i][k]*a[i][k]; 00045 } 00046 f=a[i][l]; 00047 g= -(DSIGN(sqrt(h),f)); 00048 e[i] = scale*g; 00049 h -= f*g; 00050 a[i][l] = f-g; 00051 f = 0.0; 00052 h_inv=1.0/h; 00053 for (j=0; j <= l; j++) { 00054 if (matz) 00055 a[j][i] = a[i][j]*h_inv; 00056 g = 0.0; 00057 for (k=0; k <= j; k++) { 00058 g += a[j][k]*a[i][k]; 00059 } 00060 if (l > j) { 00061 for (k=j+1; k <= l; k++) { 00062 g += a[k][j]*a[i][k]; 00063 } 00064 } 00065 e[j] = g*h_inv; 00066 f += e[j]*a[i][j]; 00067 } 00068 hh = f/(h+h); 00069 for (j=0; j <= l; j++) { 00070 f = a[i][j]; 00071 g = e[j] - hh*f; 00072 e[j] = g; 00073 for (k=0; k <= j; k++) { 00074 a[j][k] -= (f*e[k]+ g*a[i][k]); 00075 } 00076 } 00077 } 00078 } else { 00079 e[i] = a[i][l]; 00080 } 00081 d[i] = h; 00082 } 00083 if (matz) 00084 d[0] = 0.0; 00085 e[0] = 0.0; 00086 00087 for (i=0; i < n; i++) { 00088 l = i-1; 00089 if (matz) { 00090 if (d[i]) { 00091 for (j=0; j <= l; j++) { 00092 g = 0.0; 00093 for (k=0; k <= l; k++) { 00094 g += a[i][k]*a[k][j]; 00095 } 00096 for (k=0; k <= l; k++) { 00097 a[k][j] -= g*a[k][i]; 00098 } 00099 } 00100 } 00101 } 00102 d[i] = a[i][i]; 00103 if (matz) { 00104 a[i][i] = 1.0; 00105 if (l >= 0) { 00106 for (j=0; j<= l; j++) { 00107 a[i][j] = 0.0; 00108 a[j][i] = 0.0; 00109 } 00110 } 00111 } 00112 } 00113 }
| void tri_to_sq | ( | double * | amat, | |
| double ** | bmat, | |||
| int | size | |||
| ) |
tri_to_sq(): converts lower triangle to square matrix
| amat | = lower triangle matrix | |
| bmat | = square matrix | |
| size | = number of rows/cols of matrix |
Definition at line 20 of file tri_to_sq.cc.
Referenced by psi::cscf::check_rot().
00021 { 00022 int i, j, ij; 00023 00024 ij=0; 00025 for(i = 0 ; i < size ; i++) { 00026 for(j = 0 ; j <= i ; j++) { 00027 bmat[i][j] = amat[ij]; 00028 bmat[j][i] = amat[ij++]; 00029 } 00030 } 00031 }
| void tstop | ( | FILE * | outfile | ) |
tstop(): Stop timer
| outfile | = output file pointer. |
Definition at line 55 of file tstart.cc.
00056 { 00057 int i; 00058 int error; 00059 time_t total_time; 00060 struct tms total_tmstime; 00061 char *name; 00062 double user_s, sys_s; 00063 00064 name = (char *) malloc(40 * sizeof(char)); 00065 error = gethostname(name, 40); 00066 if(error != 0) strncpy(name,"nohostname", 11); 00067 00068 time_end = time(NULL); 00069 total_time = time_end - time_start; 00070 00071 times(&total_tmstime); 00072 const long clk_tck = sysconf(_SC_CLK_TCK); 00073 user_s = ((double) total_tmstime.tms_utime)/clk_tck; 00074 sys_s = ((double) total_tmstime.tms_stime)/clk_tck; 00075 00076 for (i=0; i < 78 ; i++) { 00077 fprintf(outfile,"*"); 00078 } 00079 fprintf(outfile,"\n"); 00080 fprintf(outfile,"tstop called on %s\n", name); 00081 fprintf(outfile,"%s\n",ctime(&time_end)); 00082 fprintf(outfile,"user time = %10.2f seconds = %10.2f minutes\n", 00083 user_s, user_s/60.0); 00084 fprintf(outfile,"system time = %10.2f seconds = %10.2f minutes\n", 00085 sys_s, sys_s/60.0); 00086 fprintf(outfile,"total time = %10d seconds = %10.2f minutes\n", 00087 total_time, ((double) total_time)/60.0); 00088 00089 free(name); 00090 00091 }
| void zero_arr | ( | double * | a, | |
| int | size | |||
| ) |
zero_arr(): zero out an array of length 'size'
| a | = array to zero out | |
| size | = how many elements of a to zero |
Definition at line 21 of file zero.cc.
Referenced by pople(), and psi::detci::s1_block_fci().
| void zero_int_array | ( | int * | a, | |
| int | size | |||
| ) |
zero_int_array() Zeroes out an array of integers 'size' integers long
| a | = integer array to zero out | |
| size | = number of elements in a to zero |
Definition at line 59 of file int_array.cc.
Referenced by david(), ras_set(), ras_set2(), and zero_int_matrix().
| void zero_int_matrix | ( | int ** | array, | |
| int | rows, | |||
| int | cols | |||
| ) |
zero_int_matrix(): Zero a matrix of integers. Pass the matrix, the number of rows, and the number of columns.
| array | = pointer to integer matrix | |
| rows | = number of rows in matrix | |
| cols | = number of columns in matrix |
Definition at line 131 of file int_array.cc.
References zero_int_array().
00132 { 00133 zero_int_array(array[0], rows*cols); 00134 }
| void zero_mat | ( | double ** | a, | |
| int | n, | |||
| int | m | |||
| ) |
zero_mat(): zero out a matrix 'a' with n rows and m columns
| a | = matrix of doubles to zero out | |
| n | = number of rows in a | |
| m | = number of columns in a |
Definition at line 35 of file zero.cc.
Referenced by pople().
00036 { 00037 register int i; 00038 00039 for (i=0; i < n; i++) { 00040 bzero(a[i],sizeof(double)*m); 00041 } 00042 }
1.5.4