Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython_plus_experiments
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Julien Jerphanion
cython_plus_experiments
Commits
03f51b3f
Commit
03f51b3f
authored
Apr 26, 2021
by
Julien Jerphanion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename points to data
parent
91ea698f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
14 deletions
+16
-14
kdtree/kdtree.pyx
kdtree/kdtree.pyx
+16
-14
No files found.
kdtree/kdtree.pyx
View file @
03f51b3f
...
...
@@ -79,7 +79,7 @@ cdef cypclass Node activable:
void
build_node
(
self
,
D_t
*
points
,
D_t
*
data
,
I_t
*
indices
,
I_t
depth
,
I_t
n_dims
,
...
...
@@ -96,18 +96,18 @@ cdef cypclass Node activable:
if
(
depth
<
0
)
or
(
end
-
start
<=
1
):
return
partition_node_indices
(
points
,
indices
,
start
,
mid
,
end
,
dim
,
n_dims
)
self
.
point
=
points
+
mid
partition_node_indices
(
data
,
indices
,
start
,
mid
,
end
,
dim
,
n_dims
)
self
.
point
=
data
+
mid
self
.
left
=
consume
Node
()
self
.
right
=
consume
Node
()
self
.
left
.
build_node
(
NULL
,
points
,
indices
,
data
,
indices
,
depth
-
1
,
n_dims
,
next_dim
,
start
,
mid
)
self
.
right
.
build_node
(
NULL
,
points
,
indices
,
data
,
indices
,
depth
-
1
,
n_dims
,
next_dim
,
mid
,
end
)
...
...
@@ -124,16 +124,18 @@ cdef cypclass KDTree:
This relies on a Cython+ runtime using actors.
"""
I_t
n
# number of
points
I_t
n
# number of
data
I_t
d
# number of dimensions / features
I_t
depth
# max_depth of the tree (to be unified with leaf_size)
np
.
ndarray
data_arr
np
.
ndarray
idx_array_arr
active
Node
root
D_t
*
points
D_t
*
data
I_t
*
indices
__init__
(
self
,
...
...
@@ -151,13 +153,13 @@ cdef cypclass KDTree:
# TODO: define it on the front-end
# Use Golden Spiral for the layout
cdef
D_t
golden_ratio
=
(
1
+
5
**
0.5
)
/
2
self
.
points
=
<
D_t
*>
malloc
(
n
*
d
*
sizeof
(
D_t
))
self
.
data
=
<
D_t
*>
malloc
(
n
*
d
*
sizeof
(
D_t
))
self
.
indices
=
<
I_t
*>
malloc
(
n
*
sizeof
(
I_t
))
for
i
in
range
(
n
):
self
.
indices
[
i
]
=
i
self
.
points
[
i
*
d
]
=
(
i
/
golden_ratio
)
%
1
self
.
points
[
i
*
d
+
1
]
=
i
/
n
self
.
data
[
i
*
d
]
=
(
i
/
golden_ratio
)
%
1
self
.
data
[
i
*
d
+
1
]
=
i
/
n
# TODO: end
...
...
@@ -182,7 +184,7 @@ cdef cypclass KDTree:
# a new argument is prepredend for the Promise,
# which we aren't using using here, hence the extra NULL.
self
.
root
.
build_node
(
NULL
,
self
.
points
,
self
.
data
,
self
.
indices
,
depth
,
n_dims
=
d
,
dim
=
0
,
start
=
0
,
end
=
n
)
...
...
@@ -191,12 +193,12 @@ cdef cypclass KDTree:
for
i
in
range
(
n
):
printf
(
"X[indices[%d] = %d]= %f %f
\
n
"
,
i
,
self
.
indices
[
i
]
self
.
points
[
self
.
indices
[
i
]
*
d
],
self
.
points
[
self
.
indices
[
i
]
*
d
+
1
])
self
.
data
[
self
.
indices
[
i
]
*
d
],
self
.
data
[
self
.
indices
[
i
]
*
d
+
1
])
void
__dealloc__
(
self
):
printf
(
"Deallocating KDTree datastructures
\
n
"
)
free
(
self
.
points
)
free
(
self
.
data
)
free
(
self
.
indices
)
printf
(
"Done deallocating KDTree datastructures
\
n
"
)
# XXX It sometimes blocks over here and then segfaults
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment