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

Function af_join

src/api/c/join.cpp:68–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68af_err af_join(af_array *out, const int dim, const af_array first,
69 const af_array second) {
70 try {
71 const ArrayInfo &finfo{getInfo(first)};
72 const ArrayInfo &sinfo{getInfo(second)};
73 const dim4 &fdims{finfo.dims()};
74 const dim4 &sdims{sinfo.dims()};
75
76 ARG_ASSERT(1, dim >= 0 && dim < 4);
77 ARG_ASSERT(2, finfo.getType() == sinfo.getType());
78 if (sinfo.elements() == 0) { return af_retain_array(out, first); }
79 if (finfo.elements() == 0) { return af_retain_array(out, second); }
80 DIM_ASSERT(2, finfo.elements() > 0);
81 DIM_ASSERT(3, sinfo.elements() > 0);
82
83 // All dimensions except join dimension must be equal
84 for (int i{0}; i < AF_MAX_DIMS; i++) {
85 if (i != dim) { DIM_ASSERT(2, fdims.dims[i] == sdims.dims[i]); }
86 }
87
88 af_array output;
89
90 switch (finfo.getType()) {
91 case f32: output = join<float>(dim, first, second); break;
92 case c32: output = join<cfloat>(dim, first, second); break;
93 case f64: output = join<double>(dim, first, second); break;
94 case c64: output = join<cdouble>(dim, first, second); break;
95 case b8: output = join<char>(dim, first, second); break;
96 case s32: output = join<int>(dim, first, second); break;
97 case u32: output = join<uint>(dim, first, second); break;
98 case s64: output = join<intl>(dim, first, second); break;
99 case u64: output = join<uintl>(dim, first, second); break;
100 case s16: output = join<short>(dim, first, second); break;
101 case u16: output = join<ushort>(dim, first, second); break;
102 case s8: output = join<schar>(dim, first, second); break;
103 case u8: output = join<uchar>(dim, first, second); break;
104 case f16: output = join<half>(dim, first, second); break;
105 default: TYPE_ERROR(1, finfo.getType());
106 }
107 std::swap(*out, output);
108 }
109 CATCHALL;
110
111 return AF_SUCCESS;
112}
113
114af_err af_join_many(af_array *out, const int dim, const unsigned n_arrays,
115 const af_array *inputs) {

Callers 3

plotWrapperFunction · 0.70
joinTestFunction · 0.50
joinFunction · 0.50

Calls 5

swapFunction · 0.85
af_retain_arrayFunction · 0.70
dimsMethod · 0.45
getTypeMethod · 0.45
elementsMethod · 0.45

Tested by

no test coverage detected