FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
lpython/integration_tests/array_expr_02.py at refs/heads/main · lcompilers/lpython · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
lcompilers
/
lpython
Public
Notifications
You must be signed in to change notification settings
Fork
176
Star
1.6k
Code
Issues
500
Pull requests
80
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
lpython
/
integration_tests
/
array_expr_02.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
35 lines (24 loc) · 793 Bytes
Breadcrumbs
lpython
/
integration_tests
/
array_expr_02.py
Copy path
File metadata and controls
35 lines (24 loc) · 793 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
from
lpython
import
i32
,
f32
,
TypeVar
from
numpy
import
empty
,
sqrt
,
float32
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