fix: manual implementation of ranges::to as this is not supported by gcc 13
This commit is contained in:
parent
d06f287a91
commit
855ac4d654
|
|
@ -6,6 +6,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
# Make flags for release compilation
|
||||
# set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall -DNDEBUG")
|
||||
|
||||
|
||||
find_package(netCDF REQUIRED)
|
||||
|
||||
add_executable(LinearInterpolate main.cpp
|
||||
|
|
@ -16,6 +20,7 @@ add_executable(LinearInterpolate main.cpp
|
|||
UVGrid.cpp
|
||||
UVGrid.h
|
||||
Vel.h
|
||||
to_vector.h
|
||||
Vel.cpp)
|
||||
|
||||
execute_process(
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#include <ranges>
|
||||
#include <print>
|
||||
|
||||
#include "UVGrid.h"
|
||||
#include "readdata.h"
|
||||
#include "to_vector.h"
|
||||
|
||||
#define sizeError2 "The sizes of the hydrodynamic data files are different"
|
||||
#define sizeError "The sizes of the hydrodynamicU or -V files does not correspond with the sizes of the grid file"
|
||||
|
|
@ -27,11 +27,12 @@ UVGrid::UVGrid() {
|
|||
throw domain_error(sizeError);
|
||||
}
|
||||
|
||||
uvData = views::zip(us, vs)
|
||||
| views::transform([](auto pair) {
|
||||
return Vel(pair);
|
||||
})
|
||||
| ranges::to<vector>();
|
||||
uvData = to_vector(views::transform(views::zip(us, vs), [](auto pair){return Vel(pair);}));
|
||||
// uvData = views::zip(us, vs)
|
||||
// | views::transform([](auto pair) {
|
||||
// return Vel(pair);
|
||||
// })
|
||||
// | ranges::to<vector>();
|
||||
}
|
||||
|
||||
const Vel &UVGrid::operator[](size_t timeIndex, size_t latIndex, size_t lonIndex) const {
|
||||
|
|
@ -55,8 +56,8 @@ void UVGrid::printSlice(size_t t) {
|
|||
for (int x = 0; x < latSize; x++) {
|
||||
for (int y = 0; y < lonSize; y++) {
|
||||
auto [u,v] = (*this)[t,x,y];
|
||||
print("({:>7.4f}, {:>7.4f}) ", u, v);
|
||||
printf("%7.4f, %7.4f", u, v);
|
||||
}
|
||||
println("");
|
||||
cout << endl;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#include <cmath>
|
||||
#include <ranges>
|
||||
#include <print>
|
||||
|
||||
#include "interpolate.h"
|
||||
#include "to_vector.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
|
@ -41,11 +41,9 @@ Vel bilinearInterpolate(const UVGrid &uvGrid, int time, double lat, double lon)
|
|||
}
|
||||
|
||||
vector<Vel> bilinearInterpolate(const UVGrid &uvGrid, vector<tuple<int, double, double>> points) {
|
||||
auto results = points
|
||||
| std::views::transform([&uvGrid](const auto &point) {
|
||||
auto results = points | std::views::transform([&uvGrid](const auto &point) {
|
||||
auto [time, lat, lon] = point;
|
||||
return bilinearInterpolate(uvGrid, time, lat, lon);
|
||||
})
|
||||
| std::ranges::to<std::vector<Vel>>();
|
||||
return results;
|
||||
});
|
||||
return to_vector(results);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "interpolate.h"
|
||||
#include "Vel.h"
|
||||
#include <print>
|
||||
#include <ranges>
|
||||
#include <chrono>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
|
@ -39,14 +39,14 @@ int main() {
|
|||
|
||||
auto duration = std::chrono::duration_cast<std::chrono::milliseconds >(stop - start);
|
||||
|
||||
println("Time taken for {} points was {} seconds", N, duration.count()/1000.);
|
||||
printf("Time taken for %d points was %lf seconds\n", N, duration.count()/1000.);
|
||||
|
||||
// Do something with result in case of optimisation
|
||||
double sum = 0;
|
||||
for (auto [u,v]: x) {
|
||||
sum += u + v;
|
||||
}
|
||||
println("Sum = {}", sum);
|
||||
printf("Sum = %lf\n", sum);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
#include <print>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <netcdf>
|
||||
|
|
|
|||
Loading…
Reference in New Issue