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

Function af_transpose

src/api/c/transpose.cpp:38–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38af_err af_transpose(af_array* out, af_array in, const bool conjugate) {
39 try {
40 const ArrayInfo& info = getInfo(in);
41 af_dtype type = info.getType();
42 af::dim4 dims = info.dims();
43
44 if (dims.elements() == 0) { return af_retain_array(out, in); }
45
46 if (dims[0] == 1 || dims[1] == 1) {
47 af::dim4 outDims(dims[1], dims[0], dims[2], dims[3]);
48 if (conjugate) {
49 af_array temp = 0;
50 AF_CHECK(af_conjg(&temp, in));
51 AF_CHECK(af_moddims(out, temp, outDims.ndims(), outDims.get()));
52 AF_CHECK(af_release_array(temp));
53 return AF_SUCCESS;
54 } else {
55 // for a vector OR a batch of vectors
56 // we can use modDims to transpose
57 AF_CHECK(af_moddims(out, in, outDims.ndims(), outDims.get()));
58 return AF_SUCCESS;
59 }
60 }
61
62 af_array output;
63 switch (type) {
64 case f32: output = trs<float>(in, conjugate); break;
65 case c32: output = trs<cfloat>(in, conjugate); break;
66 case f64: output = trs<double>(in, conjugate); break;
67 case c64: output = trs<cdouble>(in, conjugate); break;
68 case b8: output = trs<char>(in, conjugate); break;
69 case s32: output = trs<int>(in, conjugate); break;
70 case u32: output = trs<uint>(in, conjugate); break;
71 case s8: output = trs<schar>(in, conjugate); break;
72 case u8: output = trs<uchar>(in, conjugate); break;
73 case s64: output = trs<intl>(in, conjugate); break;
74 case u64: output = trs<uintl>(in, conjugate); break;
75 case s16: output = trs<short>(in, conjugate); break;
76 case u16: output = trs<ushort>(in, conjugate); break;
77 case f16: output = trs<half>(in, conjugate); break;
78 default: TYPE_ERROR(1, type);
79 }
80 std::swap(*out, output);
81 }
82 CATCHALL;
83
84 return AF_SUCCESS;
85}
86
87template<typename T>
88static inline void transpose_inplace(af_array in, const bool conjugate) {

Callers 7

af_save_imageFunction · 0.70
af_save_image_memoryFunction · 0.70
save_tFunction · 0.70
trsTestFunction · 0.50
transposeip_testFunction · 0.50
unwrapTestFunction · 0.50
transposeFunction · 0.50

Calls 10

af_conjgFunction · 0.85
swapFunction · 0.85
af_retain_arrayFunction · 0.70
af_moddimsFunction · 0.70
af_release_arrayFunction · 0.70
getTypeMethod · 0.45
dimsMethod · 0.45
elementsMethod · 0.45
ndimsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected