-
Notifications
You must be signed in to change notification settings - Fork 1
/
Translation_Function.hpp
59 lines (46 loc) · 1.31 KB
/
Translation_Function.hpp
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
#ifndef TRANSLATION_FUNCTION_H
#define TRANSLATION_FUNCTION_H
#include "Quadrature.hpp"
#include "NFunction.hpp"
class Translation_Function : public NFunction
{
public:
// Precomputes the Translation function for vector r
Translation_Function(Quadrature* quad, const Vec3& r)
: NFunction(quad)
{
//cout << "r = " << r << endl;
Quadrature& q = *quad;
double kappa = q.kappa;
int K = q.size();
for( int k = 0; k < K; ++k ) {
const Vec3& s = q.getPoint(k).s;
C[k] = exp( CI * kappa * r.dot(s) );
}
}
// B += psi * A(r)
inline void static add( const Vec3& r, const complex psi, NFunction& B )
{
//cout << "r = " << r << endl;
Quadrature& quad = B.getQuad();
double kappa = quad.kappa;
int K = quad.size();
for( int k = 0; k < K; ++k ) {
const double krs = kappa * r.dot( quad.getPoint(k).s );
B.C[k] += psi * complex( cos(krs), sin(krs) );
}
}
// B = C .* A(r)
inline void static times( const NFunction& C, const Vec3& r, NFunction& B )
{
//cout << "r = " << r << endl;
Quadrature& quad = B.getQuad();
double kappa = quad.kappa;
int K = quad.size();
for( int k = 0; k < K; ++k ) {
const double krs = kappa * r.dot( quad.getPoint(k).s );
B.C[k] = C.C[k] * complex( cos(krs), sin(krs) );
}
}
};
#endif