WaveSimPP 1.0
A C library for solving the wave equation and reconstructing the wave field
All Classes Namespaces Functions Modules Pages
np_to_matplot.hpp
1#ifndef NPTOMATPLOT_H_
2#define NPTOMATPLOT_H_
3
4#include <matplot/matplot.h>
5#include <thread>
6#include "boost/multi_array.hpp"
7#include "boost/array.hpp"
13namespace np
14{
16 inline matplot::vector_2d convert_to_matplot(const boost::multi_array<double, 2> &arr)
17 {
18 std::vector<double> x = matplot::linspace(0, 0, arr.shape()[0]);
19 std::vector<double> y = matplot::linspace(00, 0, arr.shape()[1]);
20 matplot::vector_2d result = std::get<0>(matplot::meshgrid(x, y));
21 // std::cout << "arr.shape()[0] = " << arr.shape()[0] << " arr.shape()[1] = " << arr.shape()[1] << std::endl;
22 for (size_t i = 0; i < arr.shape()[0]; i++)
23 {
24 for (size_t j = 0; j < arr.shape()[1]; j++)
25 {
26 result[i][j] = arr[i][j];
27 }
28 }
29 return result;
30 }
31}
32#endif
matplot::vector_2d convert_to_matplot(const boost::multi_array< double, 2 > &arr)
Convert a 2D boost::multi_array to a matplot::vector_2d.
Custom implementation of numpy in C++.
Definition: np.hpp:20