FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
xtensor-python/test/main.cpp at master · llllllllll/xtensor-python · GitHub
llllllllll
xtensor-python
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
xtensor-python
/
test
/
main.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
56 lines (42 loc) · 1.08 KB
Breadcrumbs
xtensor-python
/
test
/
main.cpp
Copy path
File metadata and controls
56 lines (42 loc) · 1.08 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#
include
"
pybind11/pybind11.h
"
#
include
"
xtensor/xmath.hpp
"
#
include
"
xtensor/xarray.hpp
"
#
include
"
xtensor-python/pyarray.hpp
"
#
include
"
xtensor-python/pyvectorize.hpp
"
#
include
<
iostream
>
#
include
<
numeric
>
namespace
py
=
pybind11;
//
Examples
double
example1
(xt::pyarray<
double
> &m)
{
return
m
(
0
);
}
xt::pyarray<
double
>
example2
(xt::pyarray<
double
> &m)
{
return
m +
2
;
}
//
Readme Examples
double
readme_example1
(xt::pyarray<
double
> &m)
{
auto
sines =
xt::sin
(m);
return
std::accumulate
(sines.
begin
(), sines.
end
(),
0.0
);
}
double
readme_example2
(
double
i,
double
j)
{
return
std::sin
(i) -
std::cos
(j);
}
//
Vectorize Examples
int
add
(
int
i,
int
j)
{
return
i + j;
}
PYBIND11_PLUGIN
(xtensor_python_test)
{
py::
module
m
(
"
xtensor_python_test
"
,
"
Test module for xtensor python bindings
"
);
m.
def
(
"
example1
"
, example1,
"
"
);
m.
def
(
"
example2
"
, example2,
"
"
);
m.
def
(
"
readme_example1
"
, readme_example1,
"
"
);
m.
def
(
"
readme_example2
"
,
xt::pyvectorize
(readme_example2),
"
"
);
m.
def
(
"
vectorize_example1
"
,
xt::pyvectorize
(add),
"
"
);
return
m.
ptr
();
}
Back
|
FazBrowse Home
|
New Git URL