FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
arrayfire-python/tests/simple/algorithm.py at master · arrayfire/arrayfire-python · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
arrayfire
/
arrayfire-python
Public
Notifications
You must be signed in to change notification settings
Fork
64
Star
422
Code
Issues
57
Pull requests
3
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
arrayfire-python
/
tests
/
simple
/
algorithm.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
120 lines (87 loc) · 3.28 KB
Breadcrumbs
arrayfire-python
/
tests
/
simple
/
algorithm.py
Copy path
File metadata and controls
120 lines (87 loc) · 3.28 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/env python
#######################################################
# Copyright (c) 2015, ArrayFire
# All rights reserved.
#
# This file is distributed under 3-clause BSD license.
# The complete license agreement can be obtained at:
# http://arrayfire.com/licenses/BSD-3-Clause
########################################################
import
arrayfire
as
af
from
.
import
_util
def
simple_algorithm
(
verbose
=
False
):
display_func
=
_util
.
display_func
(
verbose
)
print_func
=
_util
.
print_func
(
verbose
)
a
=
af
.
randu
(
3
,
3
)
k
=
af
.
constant
(
1
,
3
,
3
,
dtype
=
af
.
Dtype
.
u32
)
af
.
eval
(
k
)
print_func
(
af
.
sum
(
a
),
af
.
product
(
a
),
af
.
min
(
a
),
af
.
max
(
a
),
af
.
count
(
a
),
af
.
any_true
(
a
),
af
.
all_true
(
a
))
display_func
(
af
.
sum
(
a
,
0
))
display_func
(
af
.
sum
(
a
,
1
))
rk
=
af
.
constant
(
1
,
3
,
dtype
=
af
.
Dtype
.
u32
)
rk
[
2
]
=
0
af
.
eval
(
rk
)
display_func
(
af
.
sumByKey
(
rk
,
a
,
dim
=
0
))
display_func
(
af
.
sumByKey
(
rk
,
a
,
dim
=
1
))
display_func
(
af
.
productByKey
(
rk
,
a
,
dim
=
0
))
display_func
(
af
.
productByKey
(
rk
,
a
,
dim
=
1
))
display_func
(
af
.
minByKey
(
rk
,
a
,
dim
=
0
))
display_func
(
af
.
minByKey
(
rk
,
a
,
dim
=
1
))
display_func
(
af
.
maxByKey
(
rk
,
a
,
dim
=
0
))
display_func
(
af
.
maxByKey
(
rk
,
a
,
dim
=
1
))
display_func
(
af
.
anyTrueByKey
(
rk
,
a
,
dim
=
0
))
display_func
(
af
.
anyTrueByKey
(
rk
,
a
,
dim
=
1
))
display_func
(
af
.
allTrueByKey
(
rk
,
a
,
dim
=
0
))
display_func
(
af
.
allTrueByKey
(
rk
,
a
,
dim
=
1
))
display_func
(
af
.
countByKey
(
rk
,
a
,
dim
=
0
))
display_func
(
af
.
countByKey
(
rk
,
a
,
dim
=
1
))
display_func
(
af
.
product
(
a
,
0
))
display_func
(
af
.
product
(
a
,
1
))
display_func
(
af
.
min
(
a
,
0
))
display_func
(
af
.
min
(
a
,
1
))
display_func
(
af
.
max
(
a
,
0
))
display_func
(
af
.
max
(
a
,
1
))
display_func
(
af
.
count
(
a
,
0
))
display_func
(
af
.
count
(
a
,
1
))
display_func
(
af
.
any_true
(
a
,
0
))
display_func
(
af
.
any_true
(
a
,
1
))
display_func
(
af
.
all_true
(
a
,
0
))
display_func
(
af
.
all_true
(
a
,
1
))
display_func
(
af
.
accum
(
a
,
0
))
display_func
(
af
.
accum
(
a
,
1
))
display_func
(
af
.
scan
(
a
,
0
,
af
.
BINARYOP
.
ADD
))
display_func
(
af
.
scan
(
a
,
1
,
af
.
BINARYOP
.
MAX
))
display_func
(
af
.
scan_by_key
(
k
,
a
,
0
,
af
.
BINARYOP
.
ADD
))
display_func
(
af
.
scan_by_key
(
k
,
a
,
1
,
af
.
BINARYOP
.
MAX
))
display_func
(
af
.
sort
(
a
,
is_ascending
=
True
))
display_func
(
af
.
sort
(
a
,
is_ascending
=
False
))
b
=
(
a
>
0.1
)
*
a
c
=
(
a
>
0.4
)
*
a
d
=
b
/
c
print_func
(
af
.
sum
(
d
))
print_func
(
af
.
sum
(
d
,
nan_val
=
0.0
))
display_func
(
af
.
sum
(
d
,
dim
=
0
,
nan_val
=
0.0
))
val
,
idx
=
af
.
sort_index
(
a
,
is_ascending
=
True
)
display_func
(
val
)
display_func
(
idx
)
val
,
idx
=
af
.
sort_index
(
a
,
is_ascending
=
False
)
display_func
(
val
)
display_func
(
idx
)
b
=
af
.
randu
(
3
,
3
)
keys
,
vals
=
af
.
sort_by_key
(
a
,
b
,
is_ascending
=
True
)
display_func
(
keys
)
display_func
(
vals
)
keys
,
vals
=
af
.
sort_by_key
(
a
,
b
,
is_ascending
=
False
)
display_func
(
keys
)
display_func
(
vals
)
c
=
af
.
randu
(
5
,
1
)
d
=
af
.
randu
(
5
,
1
)
cc
=
af
.
set_unique
(
c
,
is_sorted
=
False
)
dd
=
af
.
set_unique
(
af
.
sort
(
d
),
is_sorted
=
True
)
display_func
(
cc
)
display_func
(
dd
)
display_func
(
af
.
set_union
(
cc
,
dd
,
is_unique
=
True
))
display_func
(
af
.
set_union
(
cc
,
dd
,
is_unique
=
False
))
display_func
(
af
.
set_intersect
(
cc
,
cc
,
is_unique
=
True
))
display_func
(
af
.
set_intersect
(
cc
,
cc
,
is_unique
=
False
))
_util
.
tests
[
"algorithm"
]
=
simple_algorithm
Back
|
FazBrowse Home
|
New Git URL