MCPcopy Create free account
hub / github.com/apache/madlib / run

Method run

src/modules/linear_systems/sparse_linear_systems.cpp:208–272  ·  view source on GitHub ↗

* @brief Perform the sparse linear system transition step */

Source from the content-addressed store, hash-verified

206 * @brief Perform the sparse linear system transition step
207 */
208AnyType
209sparse_direct_linear_system_transition::run(AnyType &args) {
210
211 SparseDirectLinearSystemTransitionState<MutableArrayHandle<double> >
212 state = args[0];
213 int32_t row_id = args[1].getAs<int32_t>();
214 int32_t col_id = args[2].getAs<int32_t>();
215 double value = args[3].getAs<double>();
216 double _b = args[4].getAs<double>();
217
218
219
220 // When the segment recieves the first non-zero in the sparse matrix
221 // we initialize the state
222 if (state.nnz_processed == 0) {
223
224 int32_t num_equations = args[5].getAs<int32_t>();
225 int32_t num_vars = args[6].getAs<int32_t>();
226 int32_t total_nnz = args[7].getAs<int32_t>();
227 int algorithm = args[8].getAs<int>();
228 state.initialize(*this,
229 num_vars,
230 num_equations,
231 total_nnz
232 );
233 state.algorithm = algorithm;
234 state.NNZA = total_nnz;
235 state.numVars = num_vars;
236 state.numEquations = num_equations;
237 state.b_stored.setZero();
238 state.b.setZero();
239
240 }
241
242 // Now do the transition step
243 // First we create a block of zeros in memory
244 // and then add the vector in the appropriate position
245 ColumnVector bvec(static_cast<uint32_t>(state.numEquations));
246 ColumnVector rvec(static_cast<uint32_t>(state.NNZA));
247 ColumnVector cvec(static_cast<uint32_t>(state.NNZA));
248 ColumnVector vvec(static_cast<uint32_t>(state.NNZA));
249
250 bvec.setZero();
251 rvec.setZero();
252 cvec.setZero();
253 vvec.setZero();
254
255 rvec(state.nnz_processed) = row_id;
256 cvec(state.nnz_processed) = col_id;
257 vvec(state.nnz_processed) = value;
258
259 if (state.b_stored(row_id) == 0) {
260 bvec(row_id) = _b;
261 state.b_stored(row_id) = 1;
262 state.b += bvec;
263 }
264
265 // Build the vector & matrices based on row_id

Callers

nothing calls this directly

Calls 5

NullFunction · 0.85
errorMethod · 0.80
initializeMethod · 0.45

Tested by

no test coverage detected