00001
00002
00003
00004
00005
00006
00007 #include "blas.h"
00008 #include "debugging.h"
00009 #include "error.h"
00010 #include "moinfo.h"
00011 #include "memory_manager.h"
00012 #include "utilities.h"
00013
00014 extern FILE *infile, *outfile;
00015
00016 namespace psi{ namespace psimrcc{
00017
00018 using namespace std;
00019
00020 void CCBLAS::zero_right_four_diagonal(char* cstr)
00021 {
00022 string str(cstr);
00023
00024 vector<string> names = moinfo->get_matrix_names(str);
00025 for(int n=0;n<names.size();n++){
00026 CCMatrix* Matrix = get_Matrix(names[n]);
00027 Matrix->zero_right_four_diagonal();
00028 DEBUGGING(5,
00029 fprintf(outfile,"\n...setting the right diagonal terms of %s to zero",names[n].c_str());
00030 );
00031 }
00032 }
00033
00034 void CCBLAS::zero_non_doubly_occupied(char* cstr)
00035 {
00036 string str(cstr);
00037
00038 vector<string> names = moinfo->get_matrix_names(str);
00039 for(int n=0;n<names.size();n++){
00040 CCMatrix* Matrix = get_Matrix(names[n]);
00041 Matrix->zero_non_doubly_occupied();
00042 DEBUGGING(5,
00043 fprintf(outfile,"\n...setting the right diagonal terms of %s to zero",names[n].c_str());
00044 );
00045 }
00046 }
00047
00048 void CCBLAS::zero_non_external(char* cstr)
00049 {
00050 string str(cstr);
00051
00052 vector<string> names = moinfo->get_matrix_names(str);
00053 for(int n=0;n<names.size();n++){
00054 CCMatrix* Matrix = get_Matrix(names[n]);
00055 Matrix->zero_non_external();
00056 DEBUGGING(5,
00057 fprintf(outfile,"\n...setting the right diagonal terms of %s to zero",names[n].c_str());
00058 );
00059 }
00060 }
00061
00062 void CCBLAS::reduce_spaces(char* out,char* in)
00063 {
00064 string in_str(in);
00065 string out_str(out);
00066
00067 vector<string> in_names = moinfo->get_matrix_names(in_str);
00068 vector<string> out_names = moinfo->get_matrix_names(out_str);
00069 if(in_names.size()!=out_names.size())
00070 print_error("CCBLAS::map_spaces, number of references mismatch",__FILE__,__LINE__);
00071 for(int n=0;n<in_names.size();n++){
00072 CCMatrix* in_Matrix = get_Matrix(in_names[n]);
00073 CCMatrix* out_Matrix = get_Matrix(out_names[n]);
00074 process_reduce_spaces(out_Matrix,in_Matrix);
00075 }
00076 }
00077
00078 void CCBLAS::process_reduce_spaces(CCMatrix* out_Matrix,CCMatrix* in_Matrix)
00079 {
00080 double*** out_matrix = out_Matrix->get_matrix();
00081 int* act_to_occ = moinfo->get_actv_to_occ();
00082 int* act_to_vir = moinfo->get_actv_to_vir();
00083
00084 string& out_index_label = out_Matrix->get_index_label();
00085 string& in_index_label = in_Matrix->get_index_label();
00086
00087 int index_label_size = out_index_label.size();
00088
00089 int** map;
00090 allocate2(int,map,index_label_size,moinfo->get_nmo());
00091
00092 for(int k=0;k<index_label_size;k++){
00093 if(out_index_label[k]=='a' && in_index_label[k]=='o'){
00094 for(int l=0;l<moinfo->get_nactv();l++){
00095 map[k][l] = act_to_occ[l];
00096 }
00097 }else if(out_index_label[k]=='a' && in_index_label[k]=='v'){
00098 for(int l=0;l<moinfo->get_nactv();l++){
00099 map[k][l] = act_to_vir[l];
00100 }
00101 } else {
00102 for(int l=0;l<moinfo->get_nmo();l++){
00103 map[k][l] = l;
00104 }
00105 }
00106 }
00107
00108 if(index_label_size==2){
00109 short* pq = new short[2];
00110
00111 for(int h=0;h<moinfo->get_nirreps();h++){
00112 for(int i=0;i<out_Matrix->get_left_pairpi(h);i++){
00113 for(int j=0;j<out_Matrix->get_right_pairpi(h);j++){
00114 out_Matrix->get_two_indices(pq,h,i,j);
00115 out_matrix[h][i][j] = in_Matrix->get_two_address_element(map[0][pq[0]],map[1][pq[1]]);
00116 }
00117 }
00118 }
00119
00120 delete[] pq;
00121 }else if(index_label_size==4){
00122 short* pqrs = new short[4];
00123 for(int h=0;h<moinfo->get_nirreps();h++){
00124 for(int i=0;i<out_Matrix->get_left_pairpi(h);i++){
00125 for(int j=0;j<out_Matrix->get_right_pairpi(h);j++){
00126 out_Matrix->get_four_indices(pqrs,h,i,j);
00127 out_matrix[h][i][j] = in_Matrix->get_four_address_element(map[0][pqrs[0]],map[1][pqrs[1]],map[2][pqrs[2]],map[3][pqrs[3]]);
00128 }
00129 }
00130 }
00131 delete[] pqrs;
00132 }
00133 release2(map);
00134 }
00135
00136 }}