MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / main

Function main

examples/graphics/plot2d.cpp:19–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17static const float PRECISION = 1.0f / ITERATIONS;
18
19int main(int, char**) {
20 try {
21 // Initialize the kernel array just once
22 af::info();
23 af::Window myWindow(800, 800, "2D Plot example: ArrayFire");
24
25 array Y;
26 int sign = 1;
27 array X = seq(-af::Pi, af::Pi, PRECISION);
28 array noise = randn(X.dims(0)) / 5.f;
29
30 myWindow.grid(2, 1);
31
32 for (double val = 0; !myWindow.close();) {
33 Y = sin(X);
34
35 myWindow(0, 0).plot(X, Y);
36 myWindow(1, 0).scatter(X, Y + noise, AF_MARKER_POINT);
37
38 myWindow.show();
39
40 X = X + PRECISION * float(sign);
41 val += PRECISION * float(sign);
42
43 if (val > af::Pi) {
44 sign = -1;
45 } else if (val < -af::Pi) {
46 sign = 1;
47 }
48 }
49
50 } catch (af::exception& e) {
51 fprintf(stderr, "%s\n", e.what());
52 throw;
53 }
54 return 0;
55}

Callers

nothing calls this directly

Calls 10

infoFunction · 0.85
seqClass · 0.85
randnFunction · 0.85
sinFunction · 0.85
gridMethod · 0.80
closeMethod · 0.80
plotMethod · 0.80
scatterMethod · 0.80
showMethod · 0.80
dimsMethod · 0.45

Tested by

no test coverage detected