-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstapleclass.cc
52 lines (45 loc) · 1.4 KB
/
stapleclass.cc
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
/*
* stapleclass.cc
*
* Created on: 4 Apr 2017
* Author: John
*/
#include "stapleclass.h"
#include "indexing.h"
#include <cstddef>
staple::staple() { //index passed by value
staple::dir = 0;
for (int i=0; i<3; i++) {
staple::_links[i] = NULL;
}
}
void staple::initstaple(int x, double _lattice[n],std::array<int, 4> _index, int lambda) { //index passed by value
staple::dir = x;
int mu = _index[0];
if (staple::dir == 1) {
_index[0] = lambda;
staple::_links[2] = &_lattice[getindex(_index)]; //set pointer to point to appropriate link
_index[mu+1] += 1; //increment the mu-staple::dir coordinate by one
staple::_links[0] = &_lattice[getindex(_index)];
_index[0] = mu;
_index[mu+1] -= 1;
_index[lambda+1] += 1;
staple::_links[1] = &_lattice[getindex(_index)];
} else { if (staple::dir == -1) {
_index[lambda+1] -= 1;
staple::_links[1] = &_lattice[getindex(_index)];
_index[0] = lambda;
staple::_links[2] = &_lattice[getindex(_index)];
_index[mu+1] += 1;
staple::_links[0] = &_lattice[getindex(_index)];
}
}
}
double **staple::getvalues(){ //double derefernce, pointer to array of pointers
return staple::_links;
}
double staple::getvalue() {
if (staple::dir == 1) {
return *staple::_links[0] - *staple::_links[1] - *staple::_links[2]; //deref each of the three pointers to get staple
} else {return *staple::_links[2] - *staple::_links[0] - *staple::_links[1]; }
}