Skip to content

Commit ebfad57

Browse files
committed
removing unnnecessary .
1 parent 839552f commit ebfad57

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

contents/quantum_systems/code/c++/energy.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@
55

66
#include <fftw3.h>
77

8-
void fft(std::vector<std::complex<double>> x, int n, bool inverse) {
8+
void fft(std::vector<std::complex<double>> x, bool inverse) {
99
std::vector<std::complex<double>> y(x.size(), std::complex<double>(0.0, 0.0));
1010

1111
fftw_plan p;
1212

1313
fftw_complex *in = reinterpret_cast<fftw_complex*>(x.data());
1414
fftw_complex *out = reinterpret_cast<fftw_complex*>(y.data());
1515

16-
p = fftw_plan_dft_1d(n, in, out,
16+
p = fftw_plan_dft_1d(x.size(), in, out,
1717
(inverse ? FFTW_BACKWARD : FFTW_FORWARD), FFTW_ESTIMATE);
1818

1919

2020
fftw_execute(p);
2121
fftw_destroy_plan(p);
2222

2323
for (size_t i = 0; i < x.size(); ++i) {
24-
x[i] = y[i] / sqrt(static_cast<double>(n));
24+
x[i] = y[i] / sqrt(static_cast<double>(x.size()));
2525
}
2626
}
2727

@@ -31,7 +31,7 @@ double calculate_energy(std::vector<std::complex<double>> wfc,
3131
double dx, size_t size) {
3232
std::vector<std::complex<double>> wfc_k(wfc);
3333
std::vector<std::complex<double>> wfc_c(size);
34-
fft(wfc_k, size, false);
34+
fft(wfc_k, false);
3535

3636
for (size_t i = 0; i < size; ++i) {
3737
wfc_c[i] = conj(wfc[i]);
@@ -44,7 +44,7 @@ double calculate_energy(std::vector<std::complex<double>> wfc,
4444
energy_k[i] = wfc_k[i] * h_k[i];
4545
}
4646

47-
fft(energy_k, size, true);
47+
fft(energy_k, true);
4848

4949
for (size_t i = 0; i < size; ++i) {
5050
energy_k[i] *= wfc_c[i];

contents/split-operator_method/code/c++/split_op.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,20 @@ struct Operators {
7979
vector_complex wfc;
8080
};
8181

82-
void fft(vector_complex &x, int n, bool inverse) {
82+
void fft(vector_complex &x, bool inverse) {
8383
std::vector<std::complex<double>> y(x.size(), std::complex<double>(0.0, 0.0));
8484
fftw_plan p;
8585

8686
fftw_complex *in = reinterpret_cast<fftw_complex*>(x.data());
8787
fftw_complex *out = reinterpret_cast<fftw_complex*>(y.data());
88-
p = fftw_plan_dft_1d(n, in, out,
88+
p = fftw_plan_dft_1d(x.size(), in, out,
8989
(inverse ? FFTW_BACKWARD : FFTW_FORWARD), FFTW_ESTIMATE);
9090

9191
fftw_execute(p);
9292
fftw_destroy_plan(p);
9393

94-
for (size_t i = 0; i < n; ++i) {
95-
x[i] = y[i] / sqrt(static_cast<double>(n));
94+
for (size_t i = 0; i < x.size(); ++i) {
95+
x[i] = y[i] / sqrt(static_cast<double>(x.size()));
9696
}
9797
}
9898

@@ -104,13 +104,13 @@ void split_op(Params &par, Operators &opr) {
104104
opr.wfc[j] *= opr.pe[j];
105105
}
106106

107-
fft(opr.wfc, opr.size, false);
107+
fft(opr.wfc, false);
108108

109109
for (size_t j = 0; j < opr.size; ++j) {
110110
opr.wfc[j] *= opr.ke[j];
111111
}
112112

113-
fft(opr.wfc, opr.size, true);
113+
fft(opr.wfc, true);
114114

115115
for (size_t j = 0; j < opr.size; ++j) {
116116
opr.wfc[j] *= opr.pe[j];
@@ -159,7 +159,7 @@ double calculate_energy(Params &par, Operators &opr) {
159159
vector_complex wfc_r(opr.wfc);
160160
vector_complex wfc_k(opr.wfc);
161161
vector_complex wfc_c(opr.size);
162-
fft(wfc_k, opr.size, false);
162+
fft(wfc_k, false);
163163

164164
for (size_t i = 0; i < opr.size; ++i) {
165165
wfc_c[i] = conj(wfc_r[i]);
@@ -172,7 +172,7 @@ double calculate_energy(Params &par, Operators &opr) {
172172
energy_k[i] = wfc_k[i] * pow(complex(par.k[i], 0.0), 2);
173173
}
174174

175-
fft(energy_k, opr.size, true);
175+
fft(energy_k, true);
176176

177177
for (size_t i = 0; i < opr.size; ++i) {
178178
energy_k[i] *= 0.5 * wfc_c[i];

0 commit comments

Comments
 (0)