Macaulay2 Engine
Loading...
Searching...
No Matches

◆ computeLU() [2/5]

void DMatLUinPlace< M2::ARingRR >::computeLU ( )
inlineprivate

Definition at line 319 of file dmat-lu-inplace.hpp.

320{
321 if (mIsDone) return;
322
323 // std::cout << "computing LU decomposition ARingRR" << std::endl;
324 int rows = static_cast<int>(mLU.numRows());
325 int cols = static_cast<int>(mLU.numColumns());
326 int info;
327 int min = (rows <= cols) ? rows : cols;
328
329 if (min == 0)
330 return;
331
332 int* perm = new int[min];
334
335 dgetrf_(&rows, &cols, copyA.data(), &rows, perm, &info);
336
337 if (info < 0)
338 {
339 // First, clean up, then throw an exception
340 delete [] perm;
341 throw exc::engine_error("argument passed to dgetrf had an illegal value");
342 }
343
344 // Now copy back to row major order
346
347 // Now place the correct permutation into mPerm
348 for (int i = 0; i < min; i++)
349 {
350 int thisloc = perm[i] - 1;
351 if (i != thisloc)
352 {
353 mSign = not mSign;
354 size_t tmp = mPerm[thisloc];
355 mPerm[thisloc] = mPerm[i];
356 mPerm[i] = tmp;
357 }
358 }
359
361 mIsDone = true;
362
363 delete [] perm;
364}
std::vector< size_t > mPivotColumns
std::vector< size_t > mPerm
static void computePivotColumns(const Mat &LU, std::vector< size_t > &result_columns)
std::vector< double > make_lapack_array(const DMatRR &mat)
Definition lapack.cpp:20
void fill_from_lapack_array(const std::vector< double > &doubles, DMatRR &mat)
Definition lapack.cpp:45
void dgetrf_(const int *rows, const int *cols, double *A, const int *ld, int *ipiv, int *info)