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

Function af_solve_lu

src/api/c/solve.cpp:95–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95af_err af_solve_lu(af_array* out, const af_array a, const af_array piv,
96 const af_array b, const af_mat_prop options) {
97 try {
98 const ArrayInfo& a_info = getInfo(a);
99 const ArrayInfo& b_info = getInfo(b);
100 const ArrayInfo& piv_info = getInfo(piv);
101
102 if (a_info.ndims() > 2 || b_info.ndims() > 2) {
103 AF_ERROR("solveLU can not be used in batch mode", AF_ERR_BATCH);
104 }
105
106 af_dtype a_type = a_info.getType();
107 af_dtype b_type = b_info.getType();
108
109 dim4 adims = a_info.dims();
110 dim4 bdims = b_info.dims();
111 if (a_info.ndims() == 0 || b_info.ndims() == 0) {
112 return af_create_handle(out, 0, nullptr, a_type);
113 }
114
115 ARG_ASSERT(1, a_info.isFloating()); // Only floating and complex types
116 ARG_ASSERT(2, b_info.isFloating()); // Only floating and complex types
117
118 TYPE_ASSERT(a_type == b_type);
119
120 af_dtype piv_type = piv_info.getType();
121 TYPE_ASSERT(piv_type == s32); // TODO: add support for 64 bit types
122
123 DIM_ASSERT(1, adims[0] == adims[1]);
124 DIM_ASSERT(1, bdims[0] == adims[0]);
125 DIM_ASSERT(1, bdims[2] == adims[2]);
126 DIM_ASSERT(1, bdims[3] == adims[3]);
127
128 if (options != AF_MAT_NONE) {
129 AF_ERROR("Using this property is not yet supported in solveLU",
130 AF_ERR_NOT_SUPPORTED);
131 }
132
133 af_array output;
134
135 switch (a_type) {
136 case f32: output = solve_lu<float>(a, piv, b, options); break;
137 case f64: output = solve_lu<double>(a, piv, b, options); break;
138 case c32: output = solve_lu<cfloat>(a, piv, b, options); break;
139 case c64: output = solve_lu<cdouble>(a, piv, b, options); break;
140 default: TYPE_ERROR(1, a_type);
141 }
142 std::swap(*out, output);
143 }
144 CATCHALL;
145 return AF_SUCCESS;
146}

Callers 1

solveLUFunction · 0.50

Calls 6

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

Tested by

no test coverage detected