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 file is part of Psi4.
12  *
13  * Psi4 is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU Lesser General Public License as published by
15  * the Free Software Foundation, version 3.
16  *
17  * Psi4 is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License along
23  * with Psi4; if not, write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25  *
26  * @END LICENSE
27  */
28 
29 #ifndef _psi_src_bin_psimrcc_ccoperation_h
30 #define _psi_src_bin_psimrcc_ccoperation_h
31 
32 #include <string>
33 
34 namespace psi{ namespace psimrcc{
35 
36 class CCIndex;
37 class CCMatrix;
38 
40  // Used to define operations of the type:
41  // A [+ -]= ## factor B [* / @] C
42  public:
43  CCOperation(double in_factor,std::string in_assignment,
44  std::string in_reindexing,std::string in_operation,
45  CCMatrix* in_A_Matrix, CCMatrix* in_B_Matrix, CCMatrix* in_C_Matrix,double* work,double* buffer);
46  ~CCOperation();
47  double get_factor() {return(factor);}
48  std::string get_assignment(){return(assignment);}
49  std::string get_reindexing(){return(reindexing);}
50  std::string get_operation() {return(operation);}
54  void print();
55  void print_operation();
56  void compute();
57  static void print_timing();
58  private:
59  // Variable Syntax (p,q,r,s=integers)
60  double factor; // + - +p/q -p/q
61  std::string assignment; // = += >= +>=
62  std::string reindexing; // ## #pq# #pqrs#
63  std::string operation; // . @ / * X plus
64  static double* out_of_core_buffer;
65  static double* local_work;
69  private:
70  // Check that an operation can be performed
71  bool compatible_dot();
72  bool compatible_contract();
74  //
75  static double zero_timing;
76  static double numerical_timing;
77  static double contract_timing;
78  static double tensor_timing;
79  static double dot_timing;
80  static double plus_timing;
81  static double product_timing;
82  static double division_timing;
83  static double sort_timing;
84  static double PartA_timing;
85  static double PartB_timing;
86  static double PartC_timing;
87  void fail_to_compute();
88  void add_numerical_factor();
89  void contract();
90  void dot_product();
94  void different_index_contract(int A_type,double factor,int B_type,std::string& operation,int C_type,std::string& reindexing);
95  void reindex(double constant);
96  void *reindex_thread(void * my_id);
97  void *reindex_thread_right_expand(void * my_id);
98  void tensor_product();
99  void setup_contractions();
100  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);
101  void sort(CCIndex* T_left,CCIndex* T_right,double*** T_matrix,double constant);
102  void sort();
103  void check_and_zero_target();
104  void check_and_zero_target_block(int h);
105  void zero_target();
106  void zero_target_block(int h);
107  void zero_two_diagonal();
108 };
109 
110 }} /* End Namespaces */
111 
112 #endif // _psi_src_bin_psimrcc_ccoperation_h
void dot_product()
Definition: operation_compute.cc:131
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:234
void tensor_product()
Definition: operation_compute.cc:201
PsiReturnType psimrcc(SharedWavefunction, Options &)
Definition: psimrcc/main.cc:87
static double sort_timing
Definition: operation.h:83
void * reindex_thread_right_expand(void *my_id)
static double * out_of_core_buffer
Definition: operation.h:64
void zero_target()
Definition: operation_compute.cc:247
Definition: psimrcc/matrix.h:48
std::string operation
Definition: operation.h:63
~CCOperation()
Definition: operation.cc:65
static double plus_timing
Definition: operation.h:80
void fail_to_compute()
Definition: operation_compute.cc:260
Definition: operation.h:39
CCMatrix * get_C_Matrix()
Definition: operation.h:53
std::string get_assignment()
Definition: operation.h:48
std::string get_operation()
Definition: operation.h:50
static double zero_timing
Definition: operation.h:75
std::string assignment
Definition: operation.h:61
static double contract_timing
Definition: operation.h:77
Definition: index.h:67
bool compatible_element_by_element()
Definition: blas_compatibile.cc:73
CCMatrix * B_Matrix
Definition: operation.h:67
void contract()
Definition: operation_compute.cc:216
bool compatible_contract()
Definition: blas_compatibile.cc:110
void print_operation()
Definition: operation.cc:83
CCMatrix * C_Matrix
Definition: operation.h:68
CCMatrix * get_A_Matrix()
Definition: operation.h:51
static double * local_work
Definition: operation.h:65
std::string get_reindexing()
Definition: operation.h:49
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:55
void zero_target_block(int h)
Definition: operation_compute.cc:253
void zero_two_diagonal()
Definition: operation_compute.cc:230
void reindex(double constant)
static double product_timing
Definition: operation.h:81
static double dot_timing
Definition: operation.h:79
double factor
Definition: operation.h:60
static double numerical_timing
Definition: operation.h:76
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:55
void print()
Definition: operation.cc:69
void check_and_zero_target()
Definition: operation_compute.cc:235
static double PartB_timing
Definition: operation.h:85
static double division_timing
Definition: operation.h:82
static double tensor_timing
Definition: operation.h:78
void element_by_element_division()
Definition: operation_compute.cc:163
void setup_contractions()
Definition: operation_contraction.cc:49
void add_numerical_factor()
Definition: operation_compute.cc:122
bool compatible_dot()
Definition: blas_compatibile.cc:43
CCMatrix * get_B_Matrix()
Definition: operation.h:52
static double PartC_timing
Definition: operation.h:86
static double PartA_timing
Definition: operation.h:84
double get_factor()
Definition: operation.h:47
std::string reindexing
Definition: operation.h:62
void check_and_zero_target_block(int h)
Definition: operation_compute.cc:241
void element_by_element_product()
Definition: operation_compute.cc:149
void sort()
Definition: operation_sort.cc:45
static void print_timing()
Definition: operation.cc:97
CCMatrix * A_Matrix
Definition: operation.h:66
void element_by_element_addition()
Definition: operation_compute.cc:177