psi::psimrcc::CCMatrix Class Reference

#include <matrix.h>


Public Member Functions

 CCMatrix (std::string &str, CCIndex *left_index, CCIndex *right_index)
void add_scalar (double val)
void set_scalar (double val)
double get_scalar ()
bool is_out_of_core ()
bool is_out_of_core (int h) const
string & get_label ()
string & get_index_label ()
double get_memory () const
double get_memorypi (int h) const
int get_reference () const
bool is_integral () const
bool is_antisymmetric () const
bool is_chemist () const
bool is_fock () const
int get_symmetry () const
CCIndexget_left () const
CCIndexget_right () const
size_t get_left_pairpi (int h) const
size_t get_right_pairpi (int h) const
size_t get_block_sizepi (int h) const
double ** operator[] (int h) const
double *** get_matrix ()
double get_two_address_element (short p, short q)
void set_two_address_element (short p, short q, double value)
void add_two_address_element (short p, short q, double value)
double get_four_address_element (short p, short q, short r, short s)
void set_four_address_element (short p, short q, short r, short s, double value)
void add_four_address_element (short p, short q, short r, short s, double value)
void add_six_address_element (short i, short j, short k, short a, short b, short c, double value)
 Given a value $ Z_{ijk}^{abc} $ do

\[ \bar{H}_{ijk}^{[abc]} += Z_{ijk}^{[abc]} \]

.

void add_six_address_element_abc (short i, short j, short k, size_t abc, double value)
 Given a value $ Z_{ijk}^{abc} $ do

\[ \bar{H}_{ijk}^{[abc]} += Z_{ijk}^{[abc]} \]

.

void add_six_address_element_ijk (size_t ijk, short a, short b, short c, double value)
 Given a value $ Z_{ijk}^{abc} $ do

\[ \bar{H}_{[ijk]}^{abc} += Z_{[ijk]}^{abc} \]

.

double get_six_address_element (short i, short j, short k, short a, short b, short c)
 Retrieve $ Z_{ijk}^{abc} $.
void add_six_address_element_Pij (short i, short j, short k, short a, short b, short c, double value)
 Given a value $ Z_{ijk}^{abc} $ do

\[ Z_{ijk}^{abc} \rightarrow \{ \bar{H}_{ijk}^{abc}, -\bar{H}_{jik}^{abc} \]

.

void add_six_address_element_Pij_abc (short i, short j, short k, size_t abc, double value)
 Given a value $ Z_{ijk}^{abc} $ do

\[ Z_{ijk}^{abc} \rightarrow \{ \bar{H}_{ijk}^{abc}, -\bar{H}_{jik}^{abc} \]

.

void add_six_address_element_Pik (short i, short j, short k, short a, short b, short c, double value)
void add_six_address_element_Pjk (short i, short j, short k, short a, short b, short c, double value)
 Given a value $ Z_{ijk}^{abc} $ do

\[ Z_{ijk}^{abc} \rightarrow \{ \bar{H}_{ijk}^{abc}, -\bar{H}_{ikj}^{abc} \]

.

void add_six_address_element_Pjk_abc (short i, short j, short k, size_t abc, double value)
 Given a value $ Z_{ijk}^{abc} $ do

\[ Z_{ijk}^{abc} \rightarrow \{ \bar{H}_{ijk}^{abc}, -\bar{H}_{jik}^{abc} \]

.

void add_six_address_element_Pab (short i, short j, short k, short a, short b, short c, double value)
 Given a value $ Z_{ijk}^{abc} $ do

\[ Z_{ijk}^{abc} \rightarrow \{ \bar{H}_{ijk}^{abc}, -\bar{H}_{ijk}^{bac} \]

.

void add_six_address_element_Pab_ijk (size_t ijk, short a, short b, short c, double value)
 Given a value $ Z_{ijk}^{abc} $ do

\[ Z_{ijk}^{abc} \rightarrow \{ \bar{H}_{ijk}^{abc}, -\bar{H}_{ijk}^{bac} \]

.

void add_six_address_element_Pbc (short i, short j, short k, short a, short b, short c, double value)
 Given a value $ Z_{ijk}^{abc} $ do

\[ Z_{ijk}^{abc} \rightarrow \{ \bar{H}_{ijk}^{abc}, -\bar{H}_{ijk}^{acb} \]

.

void add_six_address_element_Pbc_ijk (size_t ijk, short a, short b, short c, double value)
 Given a value $ Z_{ijk}^{abc} $ do

\[ Z_{ijk}^{abc} \rightarrow \{ \bar{H}_{ijk}^{abc}, -\bar{H}_{ijk}^{acb} \]

.

void add_six_address_element_Pij_k (short i, short j, short k, size_t abc, double value)
 Given a value $ Z_{ijk}^{abc} $ do

\[ Z_{ijk}^{abc} \rightarrow \{ \bar{H}_{ijk}^{abc}, -\bar{H}_{kji}^{abc}, -\bar{H}_{ikj}^{abc} \]

.

void add_six_address_element_Pijk (short i, short j, short k, short a, short b, short c, double value)
 Given a value $ Z_{ijk}^{abc} $ do

\[ Z_{ijk}^{abc} \rightarrow \{ \bar{H}_{ijk}^{abc}, \bar{H}_{kij}^{abc}, \bar{H}_{jki}^{abc},-\bar{H}_{jik}^{abc},-\bar{H}_{kji}^{abc},-\bar{H}_{ikj}^{abc} \]

.

void add_six_address_element_Pab_c (size_t ijk, short a, short b, short c, double value)
 Given a value $ Z_{ijk}^{abc} $ do

\[ Z_{ijk}^{abc} \rightarrow \{ \bar{H}_{ijk}^{abc}, -\bar{H}_{ijk}^{cba}, -\bar{H}_{ijk}^{acb} \]

.

void add_six_address_element_Pij_Pab (short i, short j, short k, short a, short b, short c, double value)
 Given a value $ Z_{ijk}^{abc} $ do

\[ Z_{ijk}^{abc} \rightarrow \{ \bar{H}_{ijk}^{abc}, -\bar{H}_{ijk}^{bac},-\bar{H}_{jik}^{abc}, \bar{H}_{jik}^{bac} \]

.

void add_six_address_element_Pjk_Pbc (short i, short j, short k, short a, short b, short c, double value)
 Given a value $ Z_{ijk}^{abc} $ do

\[ Z_{ijk}^{abc} \rightarrow \{ \bar{H}_{ijk}^{abc}, -\bar{H}_{ijk}^{acb},-\bar{H}_{ikj}^{abc}, \bar{H}_{ikj}^{acb} \]

.

void add_six_address_element_Pij_k_Pa_bc (short i, short j, short k, short a, short b, short c, double value)
 Given a value $ Z_{ijk}^{abc} $ do

\[ Z_{ijk}^{abc} \rightarrow \left\{ \begin{array}{ccc} \bar{H}_{ijk}^{abc}, & - \bar{H}_{ijk}^{bac}, & - \bar{H}_{ijk}^{cba} \\ - \bar{H}_{kji}^{abc}, & \bar{H}_{kji}^{bac}, & \bar{H}_{kji}^{cba} \\ - \bar{H}_{ikj}^{abc}, & \bar{H}_{ikj}^{bac}, & \bar{H}_{ikj}^{cba} \end{array} \right. \]

.

void add_six_address_element_Pi_jk_Pab_c (short i, short j, short k, short a, short b, short c, double value)
 Given a value $ Z_{ijk}^{abc} $ do

\[ Z_{ijk}^{abc} \rightarrow \left\{ \begin{array}{ccc} \bar{H}_{ijk}^{abc}, & - \bar{H}_{ijk}^{cba}, & - \bar{H}_{ijk}^{acb} \\ - \bar{H}_{jik}^{abc}, & \bar{H}_{jik}^{cba}, & \bar{H}_{jik}^{acb} \\ - \bar{H}_{kji}^{abc}, & \bar{H}_{kji}^{cba}, & \bar{H}_{kji}^{acb} \end{array} \right. \]

.

void add_six_address_element_Pi_jk_Pa_bc (short i, short j, short k, short a, short b, short c, double value)
 Given a value $ Z_{ijk}^{abc} $ do

\[ Z_{ijk}^{abc} \rightarrow \left\{ \begin{array}{ccc} \bar{H}_{ijk}^{abc}, & - \bar{H}_{ijk}^{bac}, & - \bar{H}_{ijk}^{cba} \\ - \bar{H}_{jik}^{abc}, & \bar{H}_{jik}^{bac}, & \bar{H}_{jik}^{cba} \\ - \bar{H}_{kji}^{abc}, & \bar{H}_{kji}^{bac}, & \bar{H}_{kji}^{cba} \end{array} \right. \]

.

void get_two_indices (short *&pq, int irrep, int i, int j)
void get_two_indices_pitzer (short *&pq, int irrep, int i, int j)
void get_four_indices (short *&pqrs, int irrep, int i, int j)
void get_four_indices_pitzer (short *&pqrs, int irrep, int i, int j)
void add_numerical_factor (double factor)
void add_numerical_factor (double factor, int h)
void zero_matrix ()
void zero_matrix_block (int h)
void zero_two_diagonal ()
void zero_right_four_diagonal ()
void zero_left_four_diagonal ()
void zero_non_doubly_occupied ()
void zero_non_external ()
void element_by_element_product (double factor, CCMatrix *B_Matrix, CCMatrix *C_Matrix, int h)
void element_by_element_division (double factor, CCMatrix *B_Matrix, CCMatrix *C_Matrix, int h)
void element_by_element_addition (double factor, CCMatrix *B_Matrix, int h)
void tensor_product (string &reindexing, double factor, CCMatrix *B_Matrix, CCMatrix *C_Matrix)
void print ()
void print_dpdmatrix (int n, FILE *out)
bool is_allocated ()
bool is_block_allocated (int h)
void allocate_memory ()
void allocate_block (int h)
void free_memory ()
void free_block (int h)
int get_naccess ()
void load ()
void load_irrep (int h)
void dump_to_disk ()
void dump_to_disk (int first_irrep, int last_irrep)
void dump_block_to_disk (int h)
void write_block_to_disk (int h)
void read_from_disk ()
void read_from_disk (int first_irrep, int last_irrep)
void read_block_from_disk (int h)
size_t read_strip_from_disk (int h, int strip, double *buffer)

Static Public Member Functions

static double dot_product (CCMatrix *B_Matrix, CCMatrix *C_Matrix, int h)

Static Protected Attributes

static int nirreps = -1


Detailed Description

Author:
Francesco Evangelista <frank@ccc.uga.edu>

Definition at line 52 of file matrix.h.


Member Function Documentation

bool psi::psimrcc::CCMatrix::is_out_of_core (  ) 

Return true if all the blocks are written to core

Returns:

Definition at line 33 of file matrix_memory_and_io.cc.

References psi::psimrcc::MOInfo::get_nirreps().

Referenced by load().

00034 {
00035   for(int h=0;h<moinfo->get_nirreps();++h)
00036     if(!out_of_core[h] && (block_sizepi[h]>0))
00037       return(false);
00038   return(true);
00039 }

double psi::psimrcc::CCMatrix::get_two_address_element ( short  p,
short  q 
)

Get the element $ M_{pq} $ where the indices are absolute

Parameters:
p 
q 
Returns:

Definition at line 42 of file matrix_addressing.cc.

References psi::psimrcc::CCIndex::get_nelements(), psi::psimrcc::CCIndex::get_tuple_index(), and psi::psimrcc::CCIndex::get_tuple_irrep().

Referenced by psi::psimrcc::CCManyBody::generate_denominators().

00043 {
00044   if(left->get_nelements() == 2){ 
00045     // Case A
00046     return(matrix[0][left->get_tuple_index(p,q)][0]);
00047   }else if (left->get_nelements() == 0){
00048     // Case B
00049     return(matrix[0][0][right->get_tuple_index(p,q)]);
00050   }else if (left->get_nelements() == 1){
00051     // Case C
00052     return(matrix[left->get_tuple_irrep(p)][left->get_tuple_index(p)][right->get_tuple_index(q)]);
00053   }
00054   fprintf(outfile,"\n\n\tdouble CCMatrix::get_two_address_element(int p, int q) Critical Error!!!");
00055   fflush(outfile);
00056   exit(1);
00057   return(0.0);
00058 }

void psi::psimrcc::CCMatrix::set_two_address_element ( short  p,
short  q,
double  value 
)

Set the element $ M_{pq} $ where the indices are absolute

Parameters:
p 
q 
Returns:

Definition at line 66 of file matrix_addressing.cc.

References psi::psimrcc::CCIndex::get_nelements(), psi::psimrcc::CCIndex::get_tuple_index(), and psi::psimrcc::CCIndex::get_tuple_irrep().

00067 {
00068   if(left->get_nelements() == 2){ 
00069     // Case A
00070     matrix[0][left->get_tuple_index(p,q)][0]=value;
00071   }else if (left->get_nelements() == 0){
00072     // Case B
00073     matrix[0][0][right->get_tuple_index(p,q)]=value;
00074   }else if (left->get_nelements() == 1){
00075     // Case C
00076     matrix[left->get_tuple_irrep(p)][left->get_tuple_index(p)][right->get_tuple_index(q)]=value;
00077   }
00078 }

void psi::psimrcc::CCMatrix::add_two_address_element ( short  p,
short  q,
double  value 
)

Add value to the element $ M_{pq} $ where the indices p and q are absolute

Parameters:
p 
q 
value 
Returns:

Definition at line 87 of file matrix_addressing.cc.

References psi::psimrcc::CCIndex::get_nelements(), psi::psimrcc::CCIndex::get_tuple_index(), and psi::psimrcc::CCIndex::get_tuple_irrep().

00088 {
00089   if(left->get_nelements() == 2){ 
00090     // Case A
00091     matrix[0][left->get_tuple_index(p,q)][0]=value;
00092   }else if (left->get_nelements() == 0){
00093     // Case B
00094     matrix[0][0][right->get_tuple_index(p,q)]=value;
00095   }else if (left->get_nelements() == 1){
00096     // Case C
00097     matrix[left->get_tuple_irrep(p)][left->get_tuple_index(p)][right->get_tuple_index(q)]=value;
00098   }
00099 }

bool psi::psimrcc::CCMatrix::is_allocated (  ) 

Return true if all the blocks are allocated

Returns:

Definition at line 45 of file matrix_memory_and_io.cc.

References psi::psimrcc::MOInfo::get_nirreps().

Referenced by load().

00046 {
00047   for(int h=0;h<moinfo->get_nirreps();++h)
00048     if(!is_block_allocated(h) && (block_sizepi[h]>0))
00049       return(false);
00050   return(true);
00051 }

void psi::psimrcc::CCMatrix::free_memory (  ) 

Free the memory used to store the matrix elements

Definition at line 97 of file matrix_memory_and_io.cc.

00098 {
00099   for(int h=0;h<nirreps;h++)
00100     free_block(h);
00101 }

void psi::psimrcc::CCMatrix::load (  ) 

A black-box version of read_from_disk() that can be called for any matrix

Definition at line 206 of file matrix_memory_and_io.cc.

References is_allocated(), is_out_of_core(), and read_from_disk().

00207 {
00208   if(is_out_of_core()){
00209     if(!is_allocated())
00210       read_from_disk();
00211   }else
00212     if(!is_allocated())
00213       allocate_memory();
00214 }

void psi::psimrcc::CCMatrix::load_irrep ( int  h  ) 

A black-box version of read_from_disk() that can be called for any matrix

Parameters:
h irrep to read from disk

Definition at line 220 of file matrix_memory_and_io.cc.

References read_block_from_disk().

00221 {
00222   if(out_of_core[h]){
00223     if(!is_block_allocated(h))
00224       read_block_from_disk(h);
00225   }else{
00226     if(!is_block_allocated(h))
00227       allocate_block(h);
00228   }
00229 }

void psi::psimrcc::CCMatrix::dump_to_disk (  ) 

Write the matrix to disk and free the memory.

Definition at line 125 of file matrix_memory_and_io.cc.

References psi::psimrcc::MOInfo::get_nirreps().

00126 {
00127   dump_to_disk(0,moinfo->get_nirreps());
00128 }

void psi::psimrcc::CCMatrix::dump_to_disk ( int  first_irrep,
int  last_irrep 
)

Write the matrix to disk and free the memory

Definition at line 133 of file matrix_memory_and_io.cc.

References dump_block_to_disk().

00134 {
00135   for(int h=first_irrep;h<last_irrep;++h)
00136     dump_block_to_disk(h);
00137 }

void psi::psimrcc::CCMatrix::dump_block_to_disk ( int  h  ) 

Write a irrep block to disk and free the memory

Parameters:
h irrep to write to disk

Definition at line 143 of file matrix_memory_and_io.cc.

References write_block_to_disk().

Referenced by dump_to_disk().

00144 {
00145   write_block_to_disk(h);
00146   free_block(h);
00147   out_of_core[h]=true;
00148 }

void psi::psimrcc::CCMatrix::write_block_to_disk ( int  h  ) 

Write a irrep block to disk without freeing the memory

Parameters:
h irrep to write to disk

Definition at line 154 of file matrix_memory_and_io.cc.

References psio_write_entry().

Referenced by dump_block_to_disk().

00155 {
00156   if(block_sizepi[h]>0){
00157     // for generic matrices store the entire symmetry block on disk
00158     if(!is_integral()){
00159       char data_label[80];
00160       sprintf(data_label,"%s_%d",label.c_str(),h);
00161       psio_write_entry(MRCC_ON_DISK,data_label,(char*)&(matrix[h][0][0]),block_sizepi[h]*sizeof(double));
00162     }else{
00163 //       fprintf(outfile,"\n    CCMatrix::write_block_to_disk(): writing %s irrep %d to disk",label.c_str(),h);
00164 //       fprintf(outfile,"\n    This is a %d x %d block",left_pairpi[h],right_pairpi[h]);
00165       // for two electron integrals store strips of the symmetry block on disk
00166       double max_strip_size = mem->get_integral_strip_size();
00167       int    strip          = 0;
00168       size_t last_row       = 0;
00169       // Determine the size of the strip and write the strip to disk
00170       while(last_row < left_pairpi[h]){
00171         // Determine the size of the strip
00172         size_t first_row      = last_row;
00173         double strip_size     = 0.0; // Mb
00174         size_t strip_length   = 0;
00175         while((strip_size<max_strip_size) && (last_row < left_pairpi[h]) ){        
00176           last_row++;
00177           strip_length = last_row - first_row;
00178           strip_size = to_MB(strip_length*right_pairpi[h]);
00179         }
00180 //         fprintf(outfile,"\n    Writing strip %d of lenght %d (%d -> %d)",strip,strip_length,first_row,last_row);
00181         // Write the size of the strip
00182         char size_label[80];
00183         sprintf(size_label ,"%s_%d_%d_size",label.c_str(),h,strip);
00184         psio_write_entry(MRCC_ON_DISK,size_label,(char*)&(strip_length),sizeof(size_t));
00185 
00186         // Write the strip
00187         char data_label[80];
00188         sprintf(data_label,"%s_%d_%d",label.c_str(),h,strip);
00189         psio_write_entry(MRCC_ON_DISK,data_label,(char*)&(matrix[h][first_row][0]),
00190                          strip_length*right_pairpi[h]* sizeof(double));
00191         strip++;
00192       }
00193 
00194 //       fprintf(outfile,"\n    Written %d strip%s",strip,strip>1 ? "" : "s");
00195       // Write the number of strips
00196       char nstrips_label[80];
00197       sprintf(nstrips_label ,"%s_%d_nstrips",label.c_str(),h);
00198       psio_write_entry(MRCC_ON_DISK,nstrips_label,(char*)&(strip),sizeof(int));
00199     }
00200   }
00201 }

void psi::psimrcc::CCMatrix::read_from_disk (  ) 

Read a matrix from disk.

Definition at line 234 of file matrix_memory_and_io.cc.

References psi::psimrcc::MOInfo::get_nirreps().

Referenced by load().

00235 {
00236   read_from_disk(0,moinfo->get_nirreps());
00237 }

void psi::psimrcc::CCMatrix::read_from_disk ( int  first_irrep,
int  last_irrep 
)

Read irrep blocks from disk

Parameters:
h irrep to write to disk

Definition at line 243 of file matrix_memory_and_io.cc.

References read_block_from_disk().

00244 {
00245   for(int h=first_irrep;h<last_irrep;++h)
00246     read_block_from_disk(h);
00247 }

void psi::psimrcc::CCMatrix::read_block_from_disk ( int  h  ) 

Read an irrep block from disk

Parameters:
h irrep to write to disk

Definition at line 253 of file matrix_memory_and_io.cc.

References psio_read_entry().

Referenced by load_irrep(), and read_from_disk().

00254 {
00255   if(block_sizepi[h]>0){
00256     if(!is_block_allocated(h))
00257       allocate_block(h);
00258     // for generic matrices read the entire symmetry block on disk
00259     if(!is_integral()){
00260       char data_label[80];
00261       sprintf(data_label,"%s_%d",label.c_str(),h);
00262       psio_read_entry(MRCC_ON_DISK,data_label,(char*)&(matrix[h][0][0]),block_sizepi[h]*sizeof(double));
00263     }else{
00264       // Read the number of strips
00265       int nstrips = 0;
00266       char nstrips_label[80];
00267       sprintf(nstrips_label ,"%s_%d_nstrips",label.c_str(),h);
00268       psio_read_entry(MRCC_ON_DISK,nstrips_label,(char*)&(nstrips),sizeof(int));
00269       size_t first_row =0;
00270       for(int strip = 0;strip!=nstrips;++strip){
00271         // Read the size of the strip
00272         size_t strip_length =  0;
00273         char size_label[80];
00274         sprintf(size_label ,"%s_%d_%d_size",label.c_str(),h,strip);
00275         psio_read_entry(MRCC_ON_DISK,size_label,(char*)&(strip_length),sizeof(size_t));
00276 
00277         // Read the strip
00278         char data_label[80];
00279         sprintf(data_label,"%s_%d_%d",label.c_str(),h,strip);
00280         psio_read_entry(MRCC_ON_DISK,data_label,(char*)&(matrix[h][first_row][0]),
00281                          strip_length*right_pairpi[h]*sizeof(double));
00282 
00283         first_row += strip_length;
00284       }
00285     }
00286   }
00287 }

size_t psi::psimrcc::CCMatrix::read_strip_from_disk ( int  h,
int  strip,
double *  buffer 
)

Read an irrep strip from disk and return a boolean that is true if there is strip

Parameters:
h irrep to write to disk

Definition at line 293 of file matrix_memory_and_io.cc.

References psio_read_entry().

00294 {
00295   size_t strip_length =  0;
00296   if(block_sizepi[h]>0){
00297     // for generic matrices read the entire symmetry block on disk
00298     if(!is_integral()){
00299       fprintf(outfile,"\nMatrix %s is not stored in strips!!!",label.c_str());
00300       fflush(outfile);
00301       exit(EXIT_FAILURE);
00302     }else{
00303       // Read the number of strips
00304       int nstrips = 0;
00305       char nstrips_label[80];
00306       sprintf(nstrips_label ,"%s_%d_nstrips",label.c_str(),h);
00307       psio_read_entry(MRCC_ON_DISK,nstrips_label,(char*)&(nstrips),sizeof(int));
00308       if(strip < nstrips){
00309         // Read the size of the strip
00310         char size_label[80];
00311         sprintf(size_label ,"%s_%d_%d_size",label.c_str(),h,strip);
00312         psio_read_entry(MRCC_ON_DISK,size_label,(char*)&(strip_length),sizeof(size_t));
00313 
00314         // Read the strip
00315         char data_label[80];
00316         sprintf(data_label,"%s_%d_%d",label.c_str(),h,strip);
00317         psio_read_entry(MRCC_ON_DISK,data_label,(char*)buffer,
00318                           strip_length*right_pairpi[h]*sizeof(double));
00319       }
00320     }
00321   }
00322   return(strip_length);
00323 }


The documentation for this class was generated from the following files:
Generated on Wed Feb 13 16:36:16 2008 for PSI by  doxygen 1.5.4