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

Function af_cast

src/api/c/cast.cpp:71–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71af_err af_cast(af_array* out, const af_array in, const af_dtype type) {
72 try {
73 const ArrayInfo& info = getInfo(in, false);
74
75 af_dtype inType = info.getType();
76 if ((inType == c32 || inType == c64) &&
77 (type == f32 || type == f64 || type == f16)) {
78 AF_ERROR(
79 "Casting is not allowed from complex (c32/c64) to real "
80 "(f16/f32/f64) types.\n"
81 "Use abs, real, imag etc to convert complex to floating type.",
82 AF_ERR_TYPE);
83 }
84
85 dim4 idims = info.dims();
86 if (idims.elements() == 0) {
87 return af_create_handle(out, 0, nullptr, type);
88 }
89
90 af_array res = cast(in, type);
91
92 std::swap(*out, res);
93 }
94 CATCHALL;
95
96 return AF_SUCCESS;
97}

Callers 10

medianFunction · 0.70
meanvar_test_functionMethod · 0.50
cannyImageOtsuTestFunction · 0.50
morphImageTestFunction · 0.50
cast_testFunction · 0.50
cast_test_complex_realFunction · 0.50
TESTFunction · 0.50
SetUpMethod · 0.50
SetUpMethod · 0.50
asMethod · 0.50

Calls 6

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

Tested by

no test coverage detected