FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
lpython/integration_tests/array_expr_02.py at main · lucifer1004/lpython · GitHub
lucifer1004
/
lpython
Public
forked from
lcompilers/lpython
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
lpython
/
integration_tests
/
array_expr_02.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
36 lines (25 loc) · 800 Bytes
Breadcrumbs
lpython
/
integration_tests
/
array_expr_02.py
Copy path
File metadata and controls
36 lines (25 loc) · 800 Bytes
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
from
lpython
import
i32
,
f32
,
TypeVar
from
numpy
import
empty
,
sqrt
,
float32
n
:
i32
n
=
TypeVar
(
"n"
)
def
modify
(
array_a
:
f32
[:],
n
:
i32
)
->
f32
[
n
]:
return
sqrt
(
array_a
)
def
verify
(
array_a
:
f32
[:],
array_b
:
f32
[:],
result
:
f32
[:],
size
:
i32
):
i
:
i32
eps
:
f32
eps
=
f32
(
1e-6
)
for
i
in
range
(
size
):
assert
abs
(
array_a
[
i
]
*
array_a
[
i
]
+
sqrt
(
array_b
[
i
])
-
result
[
i
])
<=
eps
def
f
():
i
:
i32
j
:
i32
array_a
:
f32
[
256
]
=
empty
(
256
,
dtype
=
float32
)
array_b
:
f32
[
256
]
=
empty
(
256
,
dtype
=
float32
)
array_c
:
f32
[
256
]
=
empty
(
256
,
dtype
=
float32
)
for
i
in
range
(
256
):
array_a
[
i
]
=
f32
(
i
)
for
j
in
range
(
256
):
array_b
[
j
]
=
f32
(
j
+
5
)
array_c
=
array_a
**
f32
(
2
)
+
modify
(
array_b
,
256
)
verify
(
array_a
,
array_b
,
array_c
,
256
)
f
()
Back
|
FazBrowse Home
|
New Git URL