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

Function af_constant

src/api/c/data.cpp:45–75  ·  view source on GitHub ↗

Strong Exception Guarantee

Source from the content-addressed store, hash-verified

43
44// Strong Exception Guarantee
45af_err af_constant(af_array *result, const double value, const unsigned ndims,
46 const dim_t *const dims, const af_dtype type) {
47 try {
48 af_array out;
49 AF_CHECK(af_init());
50
51 if (ndims <= 0) { return af_create_handle(result, 0, nullptr, type); }
52 dim4 d = verifyDims(ndims, dims);
53
54 switch (type) {
55 case f32: out = createHandleFromValue<float>(d, value); break;
56 case c32: out = createHandleFromValue<cfloat>(d, value); break;
57 case f64: out = createHandleFromValue<double>(d, value); break;
58 case c64: out = createHandleFromValue<cdouble>(d, value); break;
59 case b8: out = createHandleFromValue<char>(d, value); break;
60 case s32: out = createHandleFromValue<int>(d, value); break;
61 case u32: out = createHandleFromValue<uint>(d, value); break;
62 case s8: out = createHandleFromValue<schar>(d, value); break;
63 case u8: out = createHandleFromValue<uchar>(d, value); break;
64 case s64: out = createHandleFromValue<intl>(d, value); break;
65 case u64: out = createHandleFromValue<uintl>(d, value); break;
66 case s16: out = createHandleFromValue<short>(d, value); break;
67 case u16: out = createHandleFromValue<ushort>(d, value); break;
68 case f16: out = createHandleFromValue<half>(d, value); break;
69 default: TYPE_ERROR(4, type);
70 }
71 std::swap(*result, out);
72 }
73 CATCHALL
74 return AF_SUCCESS;
75}
76
77template<typename To, typename Ti>
78static inline af_array createCplx(dim4 dims, const Ti real, const Ti imag) {

Callers 15

af_rootFunction · 0.70
medianFunction · 0.70
af_topkFunction · 0.70
af_save_imageFunction · 0.70
af_save_image_memoryFunction · 0.70
af_notFunction · 0.70
af_argFunction · 0.70
af_pow2Function · 0.70
af_factorialFunction · 0.70
af_minfiltFunction · 0.70
af_maxfiltFunction · 0.70
af_cplxFunction · 0.70

Calls 4

verifyDimsFunction · 0.85
swapFunction · 0.85
af_initFunction · 0.70
af_create_handleFunction · 0.70

Tested by 2

initMethod · 0.40
toTempFormatFunction · 0.40