MCPcopy Create free account
hub / github.com/TinyMPC/TinyMPC / analyzePattern

Method analyzePattern

include/Eigen/Eigen/src/SparseLU/SparseLU.h:513–574  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

511 */
512template <typename MatrixType, typename OrderingType>
513void SparseLU<MatrixType, OrderingType>::analyzePattern(const MatrixType& mat)
514{
515
516 //TODO It is possible as in SuperLU to compute row and columns scaling vectors to equilibrate the matrix mat.
517
518 // Firstly, copy the whole input matrix.
519 m_mat = mat;
520
521 // Compute fill-in ordering
522 OrderingType ord;
523 ord(m_mat,m_perm_c);
524
525 // Apply the permutation to the column of the input matrix
526 if (m_perm_c.size())
527 {
528 m_mat.uncompress(); //NOTE: The effect of this command is only to create the InnerNonzeros pointers. FIXME : This vector is filled but not subsequently used.
529 // Then, permute only the column pointers
530 ei_declare_aligned_stack_constructed_variable(StorageIndex,outerIndexPtr,mat.cols()+1,mat.isCompressed()?const_cast<StorageIndex*>(mat.outerIndexPtr()):0);
531
532 // If the input matrix 'mat' is uncompressed, then the outer-indices do not match the ones of m_mat, and a copy is thus needed.
533 if(!mat.isCompressed())
534 IndexVector::Map(outerIndexPtr, mat.cols()+1) = IndexVector::Map(m_mat.outerIndexPtr(),mat.cols()+1);
535
536 // Apply the permutation and compute the nnz per column.
537 for (Index i = 0; i < mat.cols(); i++)
538 {
539 m_mat.outerIndexPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i];
540 m_mat.innerNonZeroPtr()[m_perm_c.indices()(i)] = outerIndexPtr[i+1] - outerIndexPtr[i];
541 }
542 }
543
544 // Compute the column elimination tree of the permuted matrix
545 IndexVector firstRowElt;
546 internal::coletree(m_mat, m_etree,firstRowElt);
547
548 // In symmetric mode, do not do postorder here
549 if (!m_symmetricmode) {
550 IndexVector post, iwork;
551 // Post order etree
552 internal::treePostorder(StorageIndex(m_mat.cols()), m_etree, post);
553
554
555 // Renumber etree in postorder
556 Index m = m_mat.cols();
557 iwork.resize(m+1);
558 for (Index i = 0; i < m; ++i) iwork(post(i)) = post(m_etree(i));
559 m_etree = iwork;
560
561 // Postmultiply A*Pc by post, i.e reorder the matrix according to the postorder of the etree
562 PermutationType post_perm(m);
563 for (Index i = 0; i < m; i++)
564 post_perm.indices()(i) = post(i);
565
566 // Combine the two permutations : postorder the permutation for future use
567 if(m_perm_c.size()) {
568 m_perm_c = post_perm * m_perm_c;
569 }
570

Callers

nothing calls this directly

Calls 11

coletreeFunction · 0.85
treePostorderFunction · 0.85
uncompressMethod · 0.80
MapFunction · 0.50
sizeMethod · 0.45
colsMethod · 0.45
isCompressedMethod · 0.45
outerIndexPtrMethod · 0.45
innerNonZeroPtrMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected