Skip to content

Commit c42d912

Browse files
committed
Change export to save as layout-right. Verified the recorded moments change is only transposed
1 parent bb806fc commit c42d912

File tree

700 files changed

+13
-22
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

700 files changed

+13
-22
lines changed

cpp/lib/Exporter.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@ void Exporter::exportTo(fs::path const &filename, Grid::View::C_XY cView) {
2121
}
2222

2323
void Exporter::exportTo(fs::path const &filename, Grid::View::R_XY rView) {
24-
// TODO Copy the data to a layout-right buffer
25-
// stdex::mdarray<Real, stdex::dextents<size_t, 2u>> rArray{rView.extents()};
26-
// grid.for_each_xy([&](Dim x, Dim y) { rArray(x, y) = rView(x, y); });
27-
// cnpy::npy_save(prefix_dir / filename, rArray.data(), {grid.X, grid.Y}, "w");
24+
// Copy the data to a layout-right buffer
25+
stdex::mdarray<Real, stdex::dextents<size_t, 2u>> rArray{rView.extents()};
26+
grid.for_each_xy([&](Dim x, Dim y) { rArray(x, y) = rView(x, y); });
2827

29-
// Dimensions are switched because we use layout_left
3028
auto const path = filename.is_absolute() ? filename : prefix_dir / filename;
31-
cnpy::npy_save(path, rView.data_handle(), {grid.Y, grid.X}, "w");
29+
cnpy::npy_save(path, rArray.data(), {grid.X, grid.Y}, "w");
3230
}
3331

3432
NpyMdspan

cpp/lib/NpyMdspan.hpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,9 @@ class NpyMdspan {
1919
using ViewXY = stdex::mdspan<Real, stdex::dextents<size_t, 2u>>;
2020

2121
// TODO(luka) const view
22-
Grid::View::R_XY view() {
23-
// Reverse the dimensions
24-
auto shape = array_.shape;
25-
std::reverse(shape.begin(), shape.end());
26-
std::span<size_t, 2> const extents{shape.data(), 2};
27-
28-
// Return a layout_left view
29-
return Grid::View::R_XY{array_.data<Real>(), extents};
22+
ViewXY view() {
23+
std::span<size_t, 2> const extents{array_.shape.data(), 2};
24+
return ViewXY{array_.data<Real>(), extents};
3025
}
3126

3227
[[nodiscard]] bool valid() const { return array_.word_size == sizeof(Real); }

cpp/lib/Transformer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Transformer {
1515
/// Forward FFT
1616
void fft(Grid::View::R_XY in, Grid::View::C_XY out) const;
1717

18-
/// Backwards FFT (unnormalized)
18+
/// Backwards FFT (unnormalized, destructive)
1919
void bfft(Grid::View::C_XY in, Grid::View::R_XY out) const;
2020

2121
/// Normalize a complex buffer (can be in-place)
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)