Commit eb9c2796 authored by Jan Oliver Oelerich's avatar Jan Oliver Oelerich

Fixed an embarrassing bug in the wave multiplication function

parent ae81beb9
......@@ -371,9 +371,7 @@ void Simulation::calculatePixel(ScanPoint &point, const double defocus) {
}
}
for(float calculated_intensity: detector_intensities) {
adf_intensities.push_back(calculated_intensity);
}
adf_intensities.insert(adf_intensities.end(), detector_intensities.begin(), detector_intensities.end());
}
if(point.cbed && _gridman->cbedStoreSlice(slice->id())) {
......
......@@ -147,7 +147,8 @@ namespace stemsalabim { namespace atomic {
double factor = pi / (2 * _cutoff * 0.15);
double tapering_radius = 0.85 * _cutoff;
for(unsigned int i = 0; i < cache_len; ++i) {
v[0] = feKirklandReal(0.5 / _grating, element);
for(unsigned int i = 1; i < cache_len; ++i) {
double distance = i / _grating;
v[i] = feKirklandReal(distance, element);
......
......@@ -281,9 +281,11 @@ namespace stemsalabim {
// the builtin product of std::complex is not
// vectorized by gcc, so we're doing it manually
// here.
float tmp = 0;
for(unsigned int i = 0; i < _lx * _ly; i++) {
tmp = _data[i].real();
_data[i].real(_data[i].real() * m._data[i].real() - _data[i].imag() * m._data[i].imag());
_data[i].imag(_data[i].real() * m._data[i].imag() + _data[i].imag() * m._data[i].real());
_data[i].imag(tmp * m._data[i].imag() + _data[i].imag() * m._data[i].real());
}
return *this;
......
......@@ -26,12 +26,21 @@
#include "../src/utilities/Wave.hpp"
TEST_CASE("Fourier Transforms", "[fft]") {
stemsalabim::Wave test;
test.init(10, 10, std::complex<float>(1.0, 1.0));
REQUIRE(test[1].real() == 1.0);
REQUIRE(test[1].imag() == 1.0);
stemsalabim::Wave test1, test2;
test1.init(10, 10, std::complex<float>(3.0, 2.0));
test2.init(10, 10, std::complex<float>(2.0, 1.0));
REQUIRE(test1[1].real() == 3.0);
REQUIRE(test1[1].imag() == 2.0);
test1[1] = std::complex<float>(5.0, 4.0);
REQUIRE(test1[1].real() == 5.0);
REQUIRE(test1[1].imag() == 4.0);
test2 *= test1;
auto res = std::complex<float>(5.0, 4.0) * std::complex<float>(2.0, 1.0);
REQUIRE(test2[1].real() == res.real());
REQUIRE(test2[1].imag() == res.imag());
test[1] = std::complex<float>(5.0, 1.0);
REQUIRE(test[1].real() == 5.0);
REQUIRE(test[1].imag() == 1.0);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment