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

Function af_diff1

src/api/c/diff.cpp:40–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40af_err af_diff1(af_array* out, const af_array in, const int dim) {
41 try {
42 ARG_ASSERT(2, ((dim >= 0) && (dim < 4)));
43
44 const ArrayInfo& info = getInfo(in);
45 af_dtype type = info.getType();
46
47 af::dim4 in_dims = info.dims();
48 if (in_dims[dim] < 2) {
49 return af_create_handle(out, 0, nullptr, type);
50 }
51
52 DIM_ASSERT(1, in_dims[dim] >= 2);
53
54 af_array output;
55
56 switch (type) {
57 case f32: output = diff1<float>(in, dim); break;
58 case c32: output = diff1<cfloat>(in, dim); break;
59 case f64: output = diff1<double>(in, dim); break;
60 case c64: output = diff1<cdouble>(in, dim); break;
61 case b8: output = diff1<char>(in, dim); break;
62 case s32: output = diff1<int>(in, dim); break;
63 case u32: output = diff1<uint>(in, dim); break;
64 case s64: output = diff1<intl>(in, dim); break;
65 case u64: output = diff1<uintl>(in, dim); break;
66 case s16: output = diff1<short>(in, dim); break;
67 case u16: output = diff1<ushort>(in, dim); break;
68 case s8: output = diff1<schar>(in, dim); break;
69 case u8: output = diff1<uchar>(in, dim); break;
70 default: TYPE_ERROR(1, type);
71 }
72 std::swap(*out, output);
73 }
74 CATCHALL;
75
76 return AF_SUCCESS;
77}
78
79af_err af_diff2(af_array* out, const af_array in, const int dim) {
80 try {

Callers 3

diff1TestFunction · 0.85
diff1ArgsTestFunction · 0.85
diff1Function · 0.85

Calls 4

swapFunction · 0.85
af_create_handleFunction · 0.70
getTypeMethod · 0.45
dimsMethod · 0.45

Tested by

no test coverage detected