forked from arrayfire/arrayfire-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot2d.py
More file actions
executable file
·35 lines (26 loc) · 775 Bytes
/
plot2d.py
File metadata and controls
executable file
·35 lines (26 loc) · 775 Bytes
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
#!/usr/bin/env python
#######################################################
# Copyright (c) 2019, 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 math
import arrayfire as af
POINTS = 10000
PRECISION = 1.0 / float(POINTS)
val = -math.pi
X = math.pi * (2 * (af.range(POINTS) / POINTS) - 1)
win = af.Window(512, 512, "2D Plot example using ArrayFire")
sign = 1.0
while not win.close():
Y = af.sin(X)
win.plot(X, Y)
X += PRECISION * sign
val += PRECISION * sign
if val > math.pi:
sign = -1.0
elif val < -math.pi:
sign = 1.0