Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
matplotlibcpp17
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
HKHLR
matplotlibcpp17
Commits
8490dcfa
Commit
8490dcfa
authored
2 years ago
by
soblin
Browse files
Options
Downloads
Patches
Plain Diff
renamed sombrero.cpp
Signed-off-by:
soblin
<
hilo.soblin@gmail.com
>
parent
bb9e692c
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
gallery/contrib/sombrero.cpp
+8
-7
8 additions, 7 deletions
gallery/contrib/sombrero.cpp
with
8 additions
and
7 deletions
gallery/contrib/sombrero
,
cpp
→
gallery/contrib/sombrero
.
cpp
+
8
−
7
View file @
8490dcfa
#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
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment