00001 #ifndef _psi_src_bin_psimrcc_ccblas_h
00002 #define _psi_src_bin_psimrcc_ccblas_h
00003
00009 #include <deque>
00010 #include <string>
00011 #include <vector>
00012 #include <map>
00013 #include <utility>
00014
00015 #include "matrixtmp.h"
00016 #include "operation.h"
00017
00018 #include "index_types.h"
00019 #include "matrix_types.h"
00020 #include "types.h"
00021
00022 namespace psi{ namespace psimrcc{
00023
00024 class CCIndex;
00025 class CCMatrix;
00026
00027 enum DiisType {DiisEachCycle,DiisCC};
00028
00032 class CCBLAS{
00033 public:
00034 typedef std::vector<std::string> strvec;
00035 typedef std::vector<int> intvec;
00036 typedef std::vector<std::pair<int,int> > intpairvec;
00037 typedef std::deque<CCOperation> OpDeque;
00038
00039 CCBLAS();
00040 ~CCBLAS();
00041
00042 void add_Matrix(const char* cstr);
00043 void add_Matrix(std::string str);
00044 void add_index(const char* cstr);
00045
00046 void solve(const char* cstr);
00047 void solve(std::string str);
00048 void solve_zero_two_diagonal(const char* cstr);
00049 void zero_right_four_diagonal(const char* cstr);
00050 void zero_left_four_diagonal(const char* cstr);
00051 void zero_non_doubly_occupied(const char* cstr);
00052 void zero_non_external(const char* cstr);
00053 void zero(const char* cstr);
00054 void reduce_spaces(const char* out,const char* in);
00055 void expand_spaces(const char* out,const char* in);
00056 void append(const char* cstr);
00057 void append(std::string str);
00058 void append_zero_two_diagonal(const char* cstr);
00059 void compute();
00060 int compute_storage_strategy();
00061 void show_storage();
00062
00063 void diis_add(std::string amps, std::string delta_amps);
00064 void diis_save_t_amps(int cycle);
00065 void diis(int cycle, double delta, DiisType diis_type);
00066
00067 void print(const char* cstr);
00068 void print_ref(std::string& str);
00069 void print_memory();
00070
00071 CCIndex* get_index(const char* cstr);
00072 CCIndex* get_index(std::string& str);
00073 CCMatTmp get_MatTmp(std::string str, int reference, DiskOpt disk_option);
00074 CCMatTmp get_MatTmp(std::string str, DiskOpt disk_option);
00075 CCMatTmp get_MatTmp(CCMatrix* Matrix, DiskOpt disk_option);
00076 CCMatIrTmp get_MatIrTmp(std::string str, int reference, int irrep, DiskOpt disk_option);
00077 CCMatIrTmp get_MatIrTmp(std::string str, int irrep, DiskOpt disk_option);
00078 CCMatIrTmp get_MatIrTmp(CCMatrix* Matrix, int irrep, DiskOpt disk_option);
00079
00080 double get_scalar(std::string str);
00081 double get_scalar(const char* cstr,int reference);
00082 double get_scalar(std::string& str,int reference);
00083 void set_scalar(const char* cstr,int reference,double value);
00084 void set_scalar(std::string& str,int reference,double value);
00085
00086
00087 MatrixMap& get_MatrixMap() {return(matrices);}
00088 private:
00089 bool full_in_core;
00090 size_t work_size;
00091 size_t buffer_size;
00092 MatrixMap matrices;
00093 IndexMap indices;
00094 OpDeque operations;
00095 ArrayVec work;
00096 ArrayVec buffer;
00097 MatCnt matrices_in_deque;
00098 MatCnt matrices_in_deque_target;
00099 MatCnt matrices_in_deque_source;
00100 SortMap sortmap;
00101 private:
00102
00103 IndexMap& get_IndexMap() {return(indices);}
00104 CCMatrix* get_Matrix(std::string& str);
00105 CCMatrix* get_Matrix(const char* cstr);
00106 CCMatrix* get_Matrix(const char* cstr, int reference);
00107 CCMatrix* get_Matrix(std::string& str,std::string& expression);
00108 double* get_work(int n) {return(work[n]);}
00109
00110
00111 void allocate_matrices_in_core();
00112 void load(CCMatrix* Matrix);
00113 void load_irrep(CCMatrix* Matrix,int h);
00115
00117 void add_Matrix_ref(std::string& str);
00118 void add_indices();
00119 void add_matrix_ref(std::string& str);
00120 void solve_ref(std::string& str);
00121 int parse(std::string& str);
00122 void process_operations();
00123 void process_reduce_spaces(CCMatrix* out_Matrix,CCMatrix* in_Matrix);
00124 void process_expand_spaces(CCMatrix* out_Matrix,CCMatrix* in_Matrix);
00125 bool get_factor(const std::string& str,double& factor);
00126
00127
00128 void make_space(size_t memory_required);
00129
00130 void init();
00131 void cleanup();
00132 void allocate_work();
00133 void allocate_buffer();
00134 void free_sortmap();
00135 void free_work();
00136 void free_indices();
00137 void free_matrices();
00138 void free_buffer();
00139 };
00140
00141 extern CCBLAS *blas;
00142
00143 }}
00144
00145 #endif // _psi_src_bin_psimrcc_ccblas_h