Psi4
operation.h
Go to the documentation of this file.
1 /*
2  * @BEGIN LICENSE
3  *
4  * Psi4: an open-source quantum chemistry software package
5  *
6  * Copyright (c) 2007-2017 The Psi4 Developers.
7  *
8  * The copyrights for code used from other parties are included in
9  * the corresponding files.
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  *
25  * @END LICENSE
26  */
27 
28 #ifndef _psi_src_bin_psimrcc_ccoperation_h
29 #define _psi_src_bin_psimrcc_ccoperation_h
30 
31 #include <string>
32 
33 namespace psi{ namespace psimrcc{
34 
35 class CCIndex;
36 class CCMatrix;
37 
39  // Used to define operations of the type:
40  // A [+ -]= ## factor B [* / @] C
41  public:
42  CCOperation(double in_factor,std::string in_assignment,
43  std::string in_reindexing,std::string in_operation,
44  CCMatrix* in_A_Matrix, CCMatrix* in_B_Matrix, CCMatrix* in_C_Matrix,double* work,double* buffer);
45  ~CCOperation();
46  double get_factor() {return(factor);}
47  std::string get_assignment(){return(assignment);}
48  std::string get_reindexing(){return(reindexing);}
49  std::string get_operation() {return(operation);}
53  void print();
54  void print_operation();
55  void compute();
56  static void print_timing();
57  private:
58  // Variable Syntax (p,q,r,s=integers)
59  double factor; // + - +p/q -p/q
60  std::string assignment; // = += >= +>=
61  std::string reindexing; // ## #pq# #pqrs#
62  std::string operation; // . @ / * X plus
63  static double* out_of_core_buffer;
64  static double* local_work;
68  private:
69  // Check that an operation can be performed
70  bool compatible_dot();
71  bool compatible_contract();
73  //
74  static double zero_timing;
75  static double numerical_timing;
76  static double contract_timing;
77  static double tensor_timing;
78  static double dot_timing;
79  static double plus_timing;
80  static double product_timing;
81  static double division_timing;
82  static double sort_timing;
83  static double PartA_timing;
84  static double PartB_timing;
85  static double PartC_timing;
86  void fail_to_compute();
87  void add_numerical_factor();
88  void contract();
89  void dot_product();
93  void different_index_contract(int A_type,double factor,int B_type,std::string& operation,int C_type,std::string& reindexing);
94  void reindex(double constant);
95  void *reindex_thread(void * my_id);
96  void *reindex_thread_right_expand(void * my_id);
97  void tensor_product();
98  void setup_contractions();
99  void contract_in_core(double** A_matrix,double** B_matrix,double** C_matrix,bool B_on_disk,bool C_on_disk,int rows_A,int rows_B,int rows_C,int cols_A,int cols_B,int cols_C,int offset);
100  void sort(CCIndex* T_left,CCIndex* T_right,double*** T_matrix,double constant);
101  void sort();
102  void check_and_zero_target();
103  void check_and_zero_target_block(int h);
104  void zero_target();
105  void zero_target_block(int h);
106  void zero_two_diagonal();
107 };
108 
109 }} /* End Namespaces */
110 
111 #endif // _psi_src_bin_psimrcc_ccoperation_h
void dot_product()
Definition: operation_compute.cc:132
void contract_in_core(double **A_matrix, double **B_matrix, double **C_matrix, bool B_on_disk, bool C_on_disk, int rows_A, int rows_B, int rows_C, int cols_A, int cols_B, int cols_C, int offset)
Definition: operation_contraction.cc:235
void tensor_product()
Definition: operation_compute.cc:202
PsiReturnType psimrcc(SharedWavefunction, Options &)
Definition: psimrcc/main.cc:86
static double sort_timing
Definition: operation.h:82
void * reindex_thread_right_expand(void *my_id)
static double * out_of_core_buffer
Definition: operation.h:63
void zero_target()
Definition: operation_compute.cc:248
Definition: psimrcc/matrix.h:47
std::string operation
Definition: operation.h:62
~CCOperation()
Definition: operation.cc:64
static double plus_timing
Definition: operation.h:79
void fail_to_compute()
Definition: operation_compute.cc:261
Definition: operation.h:38
CCMatrix * get_C_Matrix()
Definition: operation.h:52
std::string get_assignment()
Definition: operation.h:47
std::string get_operation()
Definition: operation.h:49
static double zero_timing
Definition: operation.h:74
std::string assignment
Definition: operation.h:60
static double contract_timing
Definition: operation.h:76
Definition: index.h:66
bool compatible_element_by_element()
Definition: blas_compatibile.cc:74
CCMatrix * B_Matrix
Definition: operation.h:66
void contract()
Definition: operation_compute.cc:217
bool compatible_contract()
Definition: blas_compatibile.cc:111
void print_operation()
Definition: operation.cc:82
CCMatrix * C_Matrix
Definition: operation.h:67
CCMatrix * get_A_Matrix()
Definition: operation.h:50
static double * local_work
Definition: operation.h:64
std::string get_reindexing()
Definition: operation.h:48
void different_index_contract(int A_type, double factor, int B_type, std::string &operation, int C_type, std::string &reindexing)
void * reindex_thread(void *my_id)
void compute()
Definition: operation_compute.cc:56
void zero_target_block(int h)
Definition: operation_compute.cc:254
void zero_two_diagonal()
Definition: operation_compute.cc:231
void reindex(double constant)
static double product_timing
Definition: operation.h:80
static double dot_timing
Definition: operation.h:78
double factor
Definition: operation.h:59
static double numerical_timing
Definition: operation.h:75
CCOperation(double in_factor, std::string in_assignment, std::string in_reindexing, std::string in_operation, CCMatrix *in_A_Matrix, CCMatrix *in_B_Matrix, CCMatrix *in_C_Matrix, double *work, double *buffer)
Definition: operation.cc:54
void print()
Definition: operation.cc:68
void check_and_zero_target()
Definition: operation_compute.cc:236
static double PartB_timing
Definition: operation.h:84
static double division_timing
Definition: operation.h:81
static double tensor_timing
Definition: operation.h:77
void element_by_element_division()
Definition: operation_compute.cc:164
void setup_contractions()
Definition: operation_contraction.cc:50
void add_numerical_factor()
Definition: operation_compute.cc:123
bool compatible_dot()
Definition: blas_compatibile.cc:44
CCMatrix * get_B_Matrix()
Definition: operation.h:51
static double PartC_timing
Definition: operation.h:85
static double PartA_timing
Definition: operation.h:83
double get_factor()
Definition: operation.h:46
std::string reindexing
Definition: operation.h:61
void check_and_zero_target_block(int h)
Definition: operation_compute.cc:242
void element_by_element_product()
Definition: operation_compute.cc:150
void sort()
Definition: operation_sort.cc:46
static void print_timing()
Definition: operation.cc:96
CCMatrix * A_Matrix
Definition: operation.h:65
void element_by_element_addition()
Definition: operation_compute.cc:178