blas.h

Go to the documentation of this file.
00001 #ifndef _psi_src_bin_psimrcc_ccblas_h
00002 #define _psi_src_bin_psimrcc_ccblas_h
00003 /***************************************************************************
00004  *  PSIMRCC : Copyright (C) 2007 by Francesco Evangelista and Andrew Simmonett
00005  *  frank@ccc.uga.edu   andysim@ccc.uga.edu
00006  *  A multireference coupled cluster code
00007  ***************************************************************************/
00008 
00015 #include "index.h"
00016 #include "matrix.h"
00017 #include "matrixtmp.h"
00018 #include "operation.h"
00019 
00020 #include <deque>
00021 #include <string>
00022 #include <vector>
00023 #include <map>
00024 #include <utility>
00025 
00026 namespace psi{ namespace psimrcc{
00027 
00028 typedef std::map<CCMatrix*,int> MatCnt;
00029 typedef std::map<std::string,CCMatrix*> MatrixMap;
00030 typedef std::map<std::string,CCMatrix*>::iterator MatMapIt;
00031 typedef std::map<std::string,CCIndex*>  IndexMap;
00032 typedef std::vector<double*>            ArrayVec;
00033 typedef std::map<std::string,double***> SortMap;
00034 
00038 class CCBLAS{
00039 public: 
00040   typedef std::vector<std::string>            strvec;
00041   typedef std::vector<int>                    intvec;
00042   typedef std::vector<std::pair<int,int> >    intpairvec;
00043   typedef std::deque<CCOperation>             OpDeque;
00044 
00045   CCBLAS();
00046   ~CCBLAS();
00047   // Add routines
00048   void       add_Matrix(char* cstr);
00049   void       add_Matrix(std::string str);
00050   void       add_index(char* cstr);
00051   // Solve and sort
00052   void       solve(char* cstr);
00053   void       solve(std::string str);
00054   void       solve_zero_two_diagonal(char* cstr);
00055   void       zero_right_four_diagonal(char* cstr);
00056   void       zero_left_four_diagonal(char* cstr);
00057   void       zero_non_doubly_occupied(char* cstr);
00058   void       zero_non_external(char* cstr);
00059   void       reduce_spaces(char* out,char* in);
00060   void       append(char* cstr);
00061   void       append(std::string str);
00062   void       append_zero_two_diagonal(char* cstr);
00063   void       compute();
00064   int        compute_storage_strategy();
00065   void       show_storage();
00066   // DIIS
00067   void       diis_add(std::string amps, std::string delta_amps);
00068   void       diis_save_t_amps(int cycle);
00069   void       diis(int cycle);
00070   // Printing
00071   void       print(char* cstr);
00072   void       print_ref(string& str);
00073   void       print_memory();
00074   // Safe get and set
00075   CCIndex*   get_index(char* cstr);
00076   CCIndex*   get_index(std::string& str);
00077   CCMatTmp   get_MatTmp(std::string str, int reference, DiskOpt disk_option);
00078   CCMatTmp   get_MatTmp(std::string str, DiskOpt disk_option);
00079   CCMatTmp   get_MatTmp(CCMatrix* Matrix, DiskOpt disk_option);
00080   CCMatIrTmp get_MatIrTmp(std::string str, int reference, int irrep,  DiskOpt disk_option);
00081   CCMatIrTmp get_MatIrTmp(std::string str, int irrep, DiskOpt disk_option);
00082   CCMatIrTmp get_MatIrTmp(CCMatrix* Matrix, int irrep, DiskOpt disk_option);
00083 
00084   double     get_scalar(std::string str);
00085   double     get_scalar(char* cstr,int reference);
00086   double     get_scalar(std::string& str,int reference);
00087   void       set_scalar(char* cstr,int reference,double value);
00088   void       set_scalar(std::string& str,int reference,double value);
00089 
00090   // These have to be improved
00091   MatrixMap& get_MatrixMap() {return(matrices);}
00092 private:
00093   size_t     work_size;
00094   size_t     buffer_size;
00095   bool       full_in_core;
00096   MatrixMap  matrices;
00097   IndexMap   indices;
00098   OpDeque    operations;
00099   ArrayVec   work;
00100   ArrayVec   buffer;
00101   MatCnt     matrices_in_deque;
00102   MatCnt     matrices_in_deque_target;
00103   MatCnt     matrices_in_deque_source;
00104   SortMap    sortmap;
00105 private:
00106 
00107   IndexMap&  get_IndexMap()  {return(indices);}
00108   CCMatrix*  get_Matrix(std::string& str);
00109   CCMatrix*  get_Matrix(char* cstr);
00110   CCMatrix*  get_Matrix(char* cstr, int reference);
00111   CCMatrix*  get_Matrix(std::string& str,std::string& expression); // Prints a clear error message
00112   double*    get_work(int n)   {return(work[n]);}
00113 //   double***  get_sortmap(CCIndex* T_left,CCIndex* T_right,int thread);
00114 
00115   void       allocate_matrices_in_core();
00116   void       load(CCMatrix* Matrix);
00117   void       load_irrep(CCMatrix* Matrix,int h);
00119   // Class private functions
00121   void       add_Matrix_ref(std::string& str);
00122   void       add_indices();
00123   void       add_matrix_ref(std::string& str);
00124   void       solve_ref(string& str);
00125   int        parse(std::string& str);
00126   void       process_operations();
00127   void       process_reduce_spaces(CCMatrix* out_Matrix,CCMatrix* in_Matrix);
00128   bool       get_factor(const std::string& str,double& factor);
00129   // General routines
00130 
00131   void       make_space(double memory_required);
00132   // Low level memory routines
00133   void       init();
00134   void       cleanup();
00135   void       allocate_work();
00136   void       allocate_buffer();
00137   void       free_sortmap();
00138   void       free_work();
00139   void       free_indices();
00140   void       free_matrices();
00141   void       free_buffer();
00142 };
00143 
00144 extern CCBLAS *blas;
00145 
00146 }} /* End Namespaces */
00147 
00148 #endif // _psi_src_bin_psimrcc_ccblas_h

Generated on Wed Feb 13 16:35:39 2008 for PSI by  doxygen 1.5.4