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

Function af_inverse

src/api/c/inverse.cpp:27–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25}
26
27af_err af_inverse(af_array* out, const af_array in, const af_mat_prop options) {
28 try {
29 const ArrayInfo& i_info = getInfo(in);
30
31 if (i_info.ndims() > 2) {
32 AF_ERROR("solve can not be used in batch mode", AF_ERR_BATCH);
33 }
34
35 af_dtype type = i_info.getType();
36
37 if (options != AF_MAT_NONE) {
38 AF_ERROR("Using this property is not yet supported in inverse",
39 AF_ERR_NOT_SUPPORTED);
40 }
41
42 DIM_ASSERT(
43 1, i_info.dims()[0] == i_info.dims()[1]); // Only square matrices
44 ARG_ASSERT(1, i_info.isFloating()); // Only floating and complex types
45
46 af_array output;
47
48 if (i_info.ndims() == 0) { return af_retain_array(out, in); }
49
50 switch (type) {
51 case f32: output = inverse<float>(in); break;
52 case f64: output = inverse<double>(in); break;
53 case c32: output = inverse<cfloat>(in); break;
54 case c64: output = inverse<cdouble>(in); break;
55 default: TYPE_ERROR(1, type);
56 }
57 std::swap(*out, output);
58 }
59 CATCHALL;
60
61 return AF_SUCCESS;
62}

Callers 1

inverseFunction · 0.50

Calls 6

swapFunction · 0.85
isFloatingMethod · 0.80
af_retain_arrayFunction · 0.70
ndimsMethod · 0.45
getTypeMethod · 0.45
dimsMethod · 0.45

Tested by

no test coverage detected