pyscf/lib/shciscf/libSHCITools.c
/* This function is the basic reader for second order spatialRDM files and
	should return arrays that can be iterated over. The switching of the
	idices is intentional when saving the elements of the 2RDM and arises
	from a difference in notation between pyscf and SHCI.
  */
This function is the basic reader for second order spatialRDM files and
should return arrays that can be iterated over. The switching of the
idices is intentional when saving the elements of the 2RDM and arises
from a difference in notation between pyscf and SHCI.
This function is the basic reader for second order spatialRDM files and should return arrays that can be iterated over . The switching of the idices is intentional when saving the elements of the 2RDM and arises from a difference in notation between pyscf and SHCI .
void r2RDM( double * twoRDM, size_t norb,  char * fIn ){
  char line[255];
  FILE *fp = fopen( fIn, "r" );
  fgets(line, sizeof(line), fp);
  int norbs = atoi( strtok(line, " ,\t\n") );
  assert( norbs == norb );
  int norbs2 = norbs*norbs;
  int norbs3 = norbs2*norbs;
  while ( fgets(line, sizeof(line), fp) != NULL ) {
    int i = atoi( strtok(line, " ,\t\n") );
    int k = atoi( strtok(NULL, " ,\t\n") );
    int j = atoi( strtok(NULL, " ,\t\n") );
    int l = atoi( strtok(NULL, " ,\t\n") );
    float val = atof( strtok(NULL, " ,\t\n") );
    int indx = i*norbs3 + j*norbs2 + k*norbs + l;
    twoRDM[indx] = val;
  }
  fclose(fp);
}
void r2RDM ( double * twoRDM , size_t norb , char * fIn ) { char line [ 255 ] ; FILE * fp = fopen ( fIn , " " ) ; fgets ( line , sizeof ( line ) , fp ) ; int norbs = atoi ( strtok ( line , " \t \n " ) ) ; assert ( norbs == norb ) ; int norbs2 = norbs * norbs ; int norbs3 = norbs2 * norbs ; while ( fgets ( line , sizeof ( line ) , fp ) != NULL ) { int i = atoi ( strtok ( line , " \t \n " ) ) ; int k = atoi ( strtok ( NULL , " \t \n " ) ) ; int j = atoi ( strtok ( NULL , " \t \n " ) ) ; int l = atoi ( strtok ( NULL , " \t \n " ) ) ; float val = atof ( strtok ( NULL , " \t \n " ) ) ; int indx = i * norbs3 + j * norbs2 + k * norbs + l ; twoRDM [ indx ] = val ; } fclose ( fp ) ; }
This function is the basic reader for second order spatialRDM files and
should return arrays that can be iterated over.
This function is the basic reader for second order spatialRDM files and should return arrays that can be iterated over .