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

Function main

examples/lin_algebra/svd.cpp:16–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14using namespace af;
15
16int main(int argc, char* argv[]) {
17 try {
18 // Select a device and display arrayfire info
19 int device = argc > 1 ? atoi(argv[1]) : 0;
20 af::setDevice(device);
21 af::info();
22
23 float h_buffer[] = {1, 4, 2, 5, 3, 6}; // host array
24 array in(2, 3, h_buffer); // copy host data to device
25
26 array u;
27 array s_vec;
28 array vt;
29 svd(u, s_vec, vt, in);
30
31 array s_mat = diag(s_vec, 0, false);
32 array in_recon = matmul(u, s_mat, vt(seq(2), span));
33
34 af_print(in);
35 af_print(s_vec);
36 af_print(u);
37 af_print(s_mat);
38 af_print(vt);
39 af_print(in_recon);
40
41 } catch (af::exception& e) {
42 fprintf(stderr, "%s\n", e.what());
43 throw;
44 }
45
46 return 0;
47}

Callers

nothing calls this directly

Calls 6

infoFunction · 0.85
diagFunction · 0.85
seqClass · 0.85
setDeviceFunction · 0.50
svdFunction · 0.50
matmulFunction · 0.50

Tested by

no test coverage detected