Skip to content
Snippets Groups Projects
Commit 8490dcfa authored by soblin's avatar soblin
Browse files

renamed sombrero.cpp


Signed-off-by: default avatarsoblin <hilo.soblin@gmail.com>
parent bb9e692c
No related branches found
No related tags found
No related merge requests found
#include <matplotlibcpp17/pyplot.h> #include <matplotlibcpp17/pyplot.h>
#include <NumCpp.hpp> #include <NumCpp.hpp>
int main() int main() {
{
pybind11::scoped_interpreter guard{}; pybind11::scoped_interpreter guard{};
const int size = 1000; const int size = 1000;
...@@ -11,9 +10,11 @@ int main() ...@@ -11,9 +10,11 @@ int main()
const auto i = nc::arange<double>(size) - (0.5 * size); const auto i = nc::arange<double>(size) - (0.5 * size);
const auto [x, y] = nc::meshgrid<double>(i, i); const auto [x, y] = nc::meshgrid<double>(i, i);
const auto xy = (nc::power(x, 2) + nc::power(y, 2)) / (-2.0 * nc::power(sigma, 2)); const auto xy =
(nc::power(x, 2) + nc::power(y, 2)) / (-2.0 * nc::power(sigma, 2));
const auto sombrero = nc::exp(xy) * (xy + 1.0) / (std::acos(-1.0) * nc::power(sigma, 4)); const auto sombrero =
nc::exp(xy) * (xy + 1.0) / (std::acos(-1.0) * nc::power(sigma, 4));
const auto pysombrero = nc::pybindInterface::nc2pybind(sombrero); const auto pysombrero = nc::pybindInterface::nc2pybind(sombrero);
const auto min = nc::min(sombrero)[0]; const auto min = nc::min(sombrero)[0];
...@@ -21,8 +22,8 @@ int main() ...@@ -21,8 +22,8 @@ int main()
auto plt = matplotlibcpp17::pyplot::import(); auto plt = matplotlibcpp17::pyplot::import();
plt.imshow(Args(pysombrero), Kwargs( plt.imshow(Args(pysombrero),
"extent"_a = pybind11::make_tuple(-1, +1, -1, +1), Kwargs("extent"_a = pybind11::make_tuple(-1, +1, -1, +1),
"cmap"_a = "inferno")); "cmap"_a = "inferno"));
plt.colorbar(); plt.colorbar();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment