-
Notifications
You must be signed in to change notification settings - Fork 12
/
operatorfunctions.h
143 lines (96 loc) · 10.6 KB
/
operatorfunctions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
Developed by Sandeep Sharma and Garnet K.-L. Chan, 2012
Copyright (c) 2012, Garnet K.-L. Chan
This program is integrated in Molpro with the permission of
Sandeep Sharma and Garnet K.-L. Chan
*/
#ifndef SPIN_OPERATORFUNCTIONS_HEADER_H
#define SPIN_OPERATORFUNCTIONS_HEADER_H
#define TINY 1.e-20
class DiagonalMatrix;
namespace SpinAdapted{
class StackSpinBlock;
class StackSparseMatrix;
class StateInfo;
class StackMatrix;
class StackWavefunction;
class SpinQuantum;
namespace operatorfunctions
{
//TENSOR TRACE A x I -> C
void TensorTraceElement(const StackSpinBlock *ablock, const StackSparseMatrix& a, const StackSpinBlock *cblock, const StateInfo *cstateinfo, StackSparseMatrix& c, StackMatrix& cel, int cq, int cqprime, double scale);
//TENSOR TRACE A x I -> C
void TensorTrace(const StackSpinBlock *ablock, const StackSparseMatrix& a, const StackSpinBlock *cblock, const StateInfo *cstateinfo, StackSparseMatrix& c, double scale= 1.0, int num_thrds = 1) ;
//***********************************************************
//TENSOR TRACE A x I -> cD
void TensorTrace (const StackSpinBlock *ablock, const StackSparseMatrix& a, const StackSpinBlock* cblock, const StateInfo* cstateinfo, DiagonalMatrix* cDiagonal, double scale);
void TensorProduct (const StackSpinBlock *ablock, const StackSparseMatrix& a, const StackSparseMatrix& b, const StackSpinBlock* cblock, const StateInfo* cstateinfo, DiagonalMatrix* cDiagonal, double scale);
//*****************************************************
//TENSOR PRODUCT A x B -> C
void TensorProductElement(const StackSpinBlock *ablock, const StackSparseMatrix& a, const StackSparseMatrix& b, const StackSpinBlock *cblock, const StateInfo *cstateinfo, StackSparseMatrix& c, StackMatrix& cel, int cq, int cqprime, double scale);
//TENSOR PRODUCT A x B -> C
void TensorProduct (const StackSpinBlock *ablock, const StackSparseMatrix& a, const StackSparseMatrix& b, const StackSpinBlock *cblock, const StateInfo *cstateinfo, StackSparseMatrix& c, double scale, int num_thrds=1);
//************************************************
void TensorMultiply(const StackSpinBlock *ablock, const StackSparseMatrix& a, const StackSpinBlock *cblock, StackWavefunction& c, StackWavefunction& v, const SpinQuantum dQ, double scale, int num_thrds=1);
void TensorMultiply(const StackSpinBlock *ablock, const StackSparseMatrix& a, const StackSparseMatrix& b, const StackSpinBlock *cblock, StackWavefunction& c, StackWavefunction* v, const SpinQuantum opQ, double scale);
//***************************************
//*****************WHEN LOOP BLOCK IS SPLIT*************
double getScaling(const StackSparseMatrix& LEFTOP, const StackSparseMatrix& leftOp, const StackSparseMatrix& ldotOp,
const StackSparseMatrix& RIGHTOP, const StackSparseMatrix& rightOp, const StackSparseMatrix& rdotOp,
const SpinQuantum& luncollectedQ, const SpinQuantum& lQ, const SpinQuantum& ldotQ,
const SpinQuantum& luncollectedQPrime, const SpinQuantum& lQPrime, const SpinQuantum& ldotQPrime,
const SpinQuantum& runcollectedQ, const SpinQuantum& rQ, const SpinQuantum& rdotQ,
const SpinQuantum& runcollectedQPrime, const SpinQuantum& rQPrime, const SpinQuantum& rdotQPrime);
void TensorMultiplysplitLeftsplitRight(const StackSparseMatrix& LeftO, const StackSparseMatrix& RightO,
const StackSparseMatrix& leftOp, const StackSparseMatrix& ldotOp,
const StackSparseMatrix& rightOp, const StackSparseMatrix& rdotOp,
const StackSpinBlock *cblock, StackWavefunction& ropCmat, StackWavefunction* v,
double scale);
void TensorMultiplysplitLeftsplitRight00(const StackSparseMatrix& LeftO, const StackSparseMatrix& RightO,
const StackSparseMatrix& leftOp, const StackSparseMatrix& ldotOp,
const StackSparseMatrix& rightOp, const StackSparseMatrix& rdotOp,
const StackSpinBlock *cblock, StackWavefunction& ropCmat, StackWavefunction* v,
double scale);
void TensorMultiplyleftdot(const StackSparseMatrix& leftOp, StateInfo *cstate, StackWavefunction& c, StackWavefunction* v, const SpinQuantum opQ, double scale);
void TensorMultiplydotop(const StackSparseMatrix& dotOp, StateInfo *cstate, StackWavefunction& c, StackWavefunction* v, const SpinQuantum opQ, double scale);
void TensorMultiplysplitLeft(const StackSparseMatrix& RightO, const StackSparseMatrix& LeftO, const StackSparseMatrix& DotO, const StackSparseMatrix& LEFTOP, const StackSpinBlock *cblock, StackWavefunction& c, StackWavefunction* v, const SpinQuantum opQ, double scale);
void TensorMultiplysplitLeftElement(const StackSparseMatrix& rightOp, const StackSparseMatrix& leftOp, const StackSparseMatrix& dotOp, const StackSparseMatrix& LEFTOP, const StackSpinBlock *cblock, StackWavefunction& c, StackWavefunction* v, const SpinQuantum opQ, int index, double scale);
void TensorMultiplyCDxCDsplitLeftElement(const StackSparseMatrix& rightOp, const StackSparseMatrix& leftOp, const StackSparseMatrix& dotOp, const StackSparseMatrix& LEFTOP, const StackSpinBlock *cblock, StackWavefunction& c, StackWavefunction* v, const SpinQuantum opQ, int rQPrime, double scale);
void TensorMultiplyCDxCDsplitLeftElementcopy(const StackSparseMatrix& rightOp, const StackSparseMatrix& leftOp, const StackSparseMatrix& dotOp, const StackSparseMatrix& LEFTOP, const StackSpinBlock *cblock, StackWavefunction& c, StackWavefunction* v, const SpinQuantum opQ, int rQPrime, double scale);
void TensorMultiplysplitRight(const StackSparseMatrix& LeftO, const StackSparseMatrix& RightO, const StackSparseMatrix& DotO, const StackSparseMatrix& RIGHTOP, const StackSpinBlock *cblock, StackWavefunction& c, StackWavefunction* v, const SpinQuantum opQ, double scale);
void TensorMultiplysplitRightElement(const StackSparseMatrix& LeftO, const StackSparseMatrix& RightO, const StackSparseMatrix& DotO, const StackSparseMatrix& RIGHTOP, const StackSpinBlock *cblock, StackWavefunction& c, StackWavefunction* v, const SpinQuantum opQ, int lQPrime, double scale);
void TensorMultiplyCDxCDsplitRightElement(const StackSparseMatrix& LeftO, const StackSparseMatrix& RightO, const StackSparseMatrix& DotO, const StackSparseMatrix& RIGHTOP, const StackSpinBlock *cblock, StackWavefunction& c, StackWavefunction* v, const SpinQuantum opQ, int lQPrime, double scale, bool doTranspose);
void TensorMultiplyCDxCDsplitRightElementcopy(const StackSparseMatrix& LeftO, const StackSparseMatrix& RightO, const StackSparseMatrix& DotO, const StackSparseMatrix& RIGHTOP, const StackSpinBlock *cblock, StackWavefunction& c, StackWavefunction* v, const SpinQuantum opQ, int lQPrime, double scale, bool doTranspose);
//****************************************************
//***************the order of contraction is different, but the loopblock is still split********************
void multiplyDotRightElement(const StackSparseMatrix& LEFTOP, const StackSparseMatrix& leftOp, const StackSparseMatrix& dotOp, const StackSparseMatrix& rightOp,
const StackMatrix& cMat, const StackMatrix& rightOpmat, StackMatrix& v,
const SpinQuantum& luncollectedQ, const SpinQuantum& lQ, const SpinQuantum& dotQ, const SpinQuantum& rightQ,
const SpinQuantum& luncollectedQPrime, const SpinQuantum& lQPrime, const SpinQuantum& dotQPrime, const SpinQuantum& rightQPrime,
double scale);
void multiplyDotRight(const StackSparseMatrix& LEFTOP, const StackSparseMatrix& leftOp, const StackSparseMatrix& dotop,
StackSparseMatrix& rightop, std::vector<StackMatrix>& lopCmat,
StackWavefunction* v, const StackSpinBlock* cblock, int luncollectedQPrime, int rQPrime, double scale);
void multiplyDotLeftElement(const StackSparseMatrix& RIGHTOP, const StackSparseMatrix& rightOp, const StackSparseMatrix& dotOp, const StackSparseMatrix& leftOp,
const StackMatrix& cMat, const StackMatrix& leftOpmat, StackMatrix& v,
const SpinQuantum& lQ, const SpinQuantum& runcollectedQ, const SpinQuantum& dotQ, const SpinQuantum& leftQ,
const SpinQuantum& lQPrime, const SpinQuantum& runcollectedQPrime, const SpinQuantum& dotQPrime, const SpinQuantum& leftQPrime,
double scale);
void multiplyDotLeft(const StackSparseMatrix& RIGHTOP, const StackSparseMatrix& rightop, const StackSparseMatrix& dotop,
StackSparseMatrix& leftop, std::vector<StackMatrix>& ropCmat,
StackWavefunction* v, const StackSpinBlock* cblock, int lQPrime, int luncollectedQPrime, double scale);
//***********************************************
void TensorMultiplyLeftLeft(const StackSparseMatrix& a, const StackSpinBlock *cblock, StackWavefunction& c, StackWavefunction& v, const SpinQuantum dQ, double scale);
void TensorMultiplyRight(const StackSparseMatrix& rightOp, const StackSparseMatrix& leftOp, const StackSparseMatrix& dotOp, const StackSparseMatrix& LEFTOP, const StackSpinBlock *cblock, StackWavefunction& c, StackWavefunction* v, const SpinQuantum opQ, double scale);
void TensorMultiplyRightLeft(const StackSparseMatrix& a, const StackSpinBlock *cblock, StackWavefunction& c, StackWavefunction& v, const SpinQuantum dQ, double scale);
void TensorMultiplyLeft(const StackSparseMatrix& rightOp, const StackSparseMatrix& leftOp, const StackSparseMatrix& dotOp, const StackSparseMatrix& LEFTOP, const StackSpinBlock *cblock, StackWavefunction& c, StackWavefunction* v, const SpinQuantum opQ, double scale);
void Product (const StackSpinBlock *ablock, const StackSparseMatrix& a, const StackSparseMatrix& b, StackSparseMatrix& c, double scale);
void OperatorScaleAdd(double scaleV, const StackSpinBlock& b, const StackSparseMatrix& op1, StackSparseMatrix& op2);
void OperatorScaleAdd(double scaleV, const StackSpinBlock& b, const StackSparseMatrix& op1, StackSparseMatrix& op2, const std::vector<int>& rows, const std::vector<int>& cols);
void MultiplyWithOwnTranspose(const StackSparseMatrix& a, StackSparseMatrix& c, double scale);
void braTensorMultiply(const StackSpinBlock *ablock, const StackSparseMatrix &a, const StackSpinBlock *cblock, StackWavefunction &c, StackWavefunction &v, double scale, int num_thrds=1);
void TensorMultiply(const StackSparseMatrix& a, const StackSparseMatrix& b, const StateInfo *brastateinfo, const StateInfo *ketstateinfo, const StackWavefunction& c, StackWavefunction* v, const SpinQuantum opQ, bool aIsLeft, double scale);
void TensorMultiply(const StackSparseMatrix a, const StateInfo *brastateinfo, const StateInfo *ketstateinfo, const StackWavefunction& c, StackWavefunction& v, const SpinQuantum dQ, bool left, double scale);
}
}
#endif