FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
array-python-cpp/rect.pyx at master · benjaminirving/array-python-cpp · GitHub
benjaminirving
/
array-python-cpp
Public
Notifications
You must be signed in to change notification settings
Fork
7
Star
18
Code
Issues
0
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
array-python-cpp
/
rect.pyx
Copy path
More file actions
More file actions
Latest commit
History
History
History
46 lines (42 loc) · 1.42 KB
Breadcrumbs
array-python-cpp
/
rect.pyx
Copy path
File metadata and controls
46 lines (42 loc) · 1.42 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
#
distutils: language = c++
#
distutils: sources = Rectangle.cpp
#
Cython interface file for wrapping the object
#
#
from
libcpp.vector cimport vector
#
c++ interface to cython
cdef extern
from
"
Rectangle.h
"
namespace
"
shapes
"
:
cdef cppclass Rectangle:
Rectangle(
int
,
int
,
int
,
int
)
except
+
int
x0, y0, x1, y1
int
getLength()
int
getHeight()
int
getArea()
void
move(
int
,
int
)
double
sum_vec(vector[
double
])
double
sum_mat(vector[vector[
double
]])
double
sum_mat_ref(vector[vector[
double
]]
&
)
vector[vector[
double
]] ret_mat(vector[vector[
double
]])
#
creating a cython wrapper class
cdef
class
PyRectangle:
cdef Rectangle
*
thisptr
#
hold a C++ instance which we're wrapping
def
__cinit__
(
self
, int
x0
, int
y0
, int
x1
, int
y1
):
self
.thisptr
=
new Rectangle(x0, y0, x1, y1)
def
__dealloc__
(
self
):
del
self
.thisptr
def
getLength
(
self
):
return
self
.thisptr.getLength()
def
getHeight
(
self
):
return
self
.thisptr.getHeight()
def
getArea
(
self
):
return
self
.thisptr.getArea()
def
move
(
self
,
dx
,
dy
):
self
.thisptr.move(dx, dy)
def
sum_vec
(
self
,
sv
):
return
self
.thisptr.sum_vec(sv)
def
sum_mat
(
self
,
sv
):
return
self
.thisptr.sum_mat(sv)
def
sum_mat_ref
(
self
,
sv
):
return
self
.thisptr.sum_mat_ref(sv)
def
ret_mat
(
self
,
sv
):
return
self
.thisptr.ret_mat(sv)
Back
|
FazBrowse Home
|
New Git URL