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

Function TEST

test/matrix_manipulation.cpp:21–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19using std::vector;
20
21TEST(MatrixManipulation, SNIPPET_matrix_manipulation_tile) {
22 //! [ex_matrix_manipulation_tile]
23 float h[] = {1, 2, 3, 4};
24 array small_arr = array(2, 2, h); // 2x2 matrix
25 af_print(small_arr);
26 array large_arr =
27 tile(small_arr, 2, 3); // produces 4x6 matrix: (2*2)x(2*3)
28 af_print(large_arr);
29 //! [ex_matrix_manipulation_tile]
30
31 ASSERT_EQ(4, large_arr.dims(0));
32 ASSERT_EQ(6, large_arr.dims(1));
33
34 vector<float> h_large_arr(large_arr.elements());
35 large_arr.host(&h_large_arr.front());
36
37 unsigned fdim = large_arr.dims(0);
38 unsigned sdim = large_arr.dims(1);
39 for (unsigned i = 0; i < sdim; i++) {
40 for (unsigned j = 0; j < fdim; j++) {
41 ASSERT_FLOAT_EQ(h[(i % 2) * 2 + (j % 2)],
42 h_large_arr[i * fdim + j]);
43 }
44 }
45}
46
47TEST(MatrixManipulation, SNIPPET_matrix_manipulation_join) {
48 //! [ex_matrix_manipulation_join]

Callers

nothing calls this directly

Calls 10

moddimsFunction · 0.85
randuFunction · 0.85
hostMethod · 0.80
TMethod · 0.80
HMethod · 0.80
arrayClass · 0.50
tileFunction · 0.50
joinFunction · 0.50
dimsMethod · 0.45
elementsMethod · 0.45

Tested by

no test coverage detected