Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Eigen::internal::partial_lu_impl< Scalar, StorageOrder, PivIndex > Struct Template Reference

#include <src/eigen/Eigen/src/LU/PartialPivLU.h>

Public Types

typedef Map< Matrix< Scalar, Dynamic, Dynamic, StorageOrder > > MapLU
 
typedef Block< MapLU, Dynamic, DynamicMatrixType
 
typedef Block< MatrixType, Dynamic, DynamicBlockType
 
typedef MatrixType::RealScalar RealScalar
 

Static Public Member Functions

static Index unblocked_lu (MatrixType &lu, PivIndex *row_transpositions, PivIndex &nb_transpositions)
 
static Index blocked_lu (Index rows, Index cols, Scalar *lu_data, Index luStride, PivIndex *row_transpositions, PivIndex &nb_transpositions, Index maxBlockSize=256)
 

Detailed Description

template<typename Scalar, int StorageOrder, typename PivIndex>
struct Eigen::internal::partial_lu_impl< Scalar, StorageOrder, PivIndex >

Member Typedef Documentation

◆ BlockType

template<typename Scalar , int StorageOrder, typename PivIndex >
typedef Block<MatrixType,Dynamic,Dynamic> Eigen::internal::partial_lu_impl< Scalar, StorageOrder, PivIndex >::BlockType

◆ MapLU

template<typename Scalar , int StorageOrder, typename PivIndex >
typedef Map<Matrix<Scalar, Dynamic, Dynamic, StorageOrder> > Eigen::internal::partial_lu_impl< Scalar, StorageOrder, PivIndex >::MapLU

◆ MatrixType

template<typename Scalar , int StorageOrder, typename PivIndex >
typedef Block<MapLU, Dynamic, Dynamic> Eigen::internal::partial_lu_impl< Scalar, StorageOrder, PivIndex >::MatrixType

◆ RealScalar

template<typename Scalar , int StorageOrder, typename PivIndex >
typedef MatrixType::RealScalar Eigen::internal::partial_lu_impl< Scalar, StorageOrder, PivIndex >::RealScalar

Member Function Documentation

◆ blocked_lu()

template<typename Scalar , int StorageOrder, typename PivIndex >
static Index Eigen::internal::partial_lu_impl< Scalar, StorageOrder, PivIndex >::blocked_lu ( Index  rows,
Index  cols,
Scalar *  lu_data,
Index  luStride,
PivIndex *  row_transpositions,
PivIndex &  nb_transpositions,
Index  maxBlockSize = 256 
)
inlinestatic
427 {
428 MapLU lu1(lu_data,StorageOrder==RowMajor?rows:luStride,StorageOrder==RowMajor?luStride:cols);
429 MatrixType lu(lu1,0,0,rows,cols);
430
431 const Index size = (std::min)(rows,cols);
432
433 // if the matrix is too small, no blocking:
434 if(size<=16)
435 {
436 return unblocked_lu(lu, row_transpositions, nb_transpositions);
437 }
438
439 // automatically adjust the number of subdivisions to the size
440 // of the matrix so that there is enough sub blocks:
441 Index blockSize;
442 {
443 blockSize = size/8;
444 blockSize = (blockSize/16)*16;
445 blockSize = (std::min)((std::max)(blockSize,Index(8)), maxBlockSize);
446 }
447
448 nb_transpositions = 0;
449 Index first_zero_pivot = -1;
450 for(Index k = 0; k < size; k+=blockSize)
451 {
452 Index bs = (std::min)(size-k,blockSize); // actual size of the block
453 Index trows = rows - k - bs; // trailing rows
454 Index tsize = size - k - bs; // trailing size
455
456 // partition the matrix:
457 // A00 | A01 | A02
458 // lu = A_0 | A_1 | A_2 = A10 | A11 | A12
459 // A20 | A21 | A22
460 BlockType A_0(lu,0,0,rows,k);
461 BlockType A_2(lu,0,k+bs,rows,tsize);
462 BlockType A11(lu,k,k,bs,bs);
463 BlockType A12(lu,k,k+bs,bs,tsize);
464 BlockType A21(lu,k+bs,k,trows,bs);
465 BlockType A22(lu,k+bs,k+bs,trows,tsize);
466
467 PivIndex nb_transpositions_in_panel;
468 // recursively call the blocked LU algorithm on [A11^T A21^T]^T
469 // with a very small blocking size:
470 Index ret = blocked_lu(trows+bs, bs, &lu.coeffRef(k,k), luStride,
471 row_transpositions+k, nb_transpositions_in_panel, 16);
472 if(ret>=0 && first_zero_pivot==-1)
473 first_zero_pivot = k+ret;
474
475 nb_transpositions += nb_transpositions_in_panel;
476 // update permutations and apply them to A_0
477 for(Index i=k; i<k+bs; ++i)
478 {
479 Index piv = (row_transpositions[i] += internal::convert_index<PivIndex>(k));
480 A_0.row(i).swap(A_0.row(piv));
481 }
482
483 if(trows)
484 {
485 // apply permutations to A_2
486 for(Index i=k;i<k+bs; ++i)
487 A_2.row(i).swap(A_2.row(row_transpositions[i]));
488
489 // A12 = A11^-1 A12
490 A11.template triangularView<UnitLower>().solveInPlace(A12);
491
492 A22.noalias() -= A21 * A12;
493 }
494 }
495 return first_zero_pivot;
496 }
@ RowMajor
Definition Constants.h:322
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:33
constexpr auto size(const C &c) -> decltype(c.size())
Definition span.hpp:183
size_t cols(const T &raster)
Definition MarchingSquares.hpp:60
size_t rows(const T &raster)
Definition MarchingSquares.hpp:55
static Index blocked_lu(Index rows, Index cols, Scalar *lu_data, Index luStride, PivIndex *row_transpositions, PivIndex &nb_transpositions, Index maxBlockSize=256)
Definition PartialPivLU.h:426
static Index unblocked_lu(MatrixType &lu, PivIndex *row_transpositions, PivIndex &nb_transpositions)
Definition PartialPivLU.h:365
Map< Matrix< Scalar, Dynamic, Dynamic, StorageOrder > > MapLU
Definition PartialPivLU.h:350
Block< MatrixType, Dynamic, Dynamic > BlockType
Definition PartialPivLU.h:352
Block< MapLU, Dynamic, Dynamic > MatrixType
Definition PartialPivLU.h:351

References Eigen::internal::partial_lu_impl< Scalar, StorageOrder, PivIndex >::blocked_lu(), Eigen::RowMajor, and Eigen::internal::partial_lu_impl< Scalar, StorageOrder, PivIndex >::unblocked_lu().

Referenced by Eigen::internal::partial_lu_impl< Scalar, StorageOrder, PivIndex >::blocked_lu().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unblocked_lu()

template<typename Scalar , int StorageOrder, typename PivIndex >
static Index Eigen::internal::partial_lu_impl< Scalar, StorageOrder, PivIndex >::unblocked_lu ( MatrixType lu,
PivIndex *  row_transpositions,
PivIndex &  nb_transpositions 
)
inlinestatic
366 {
367 typedef scalar_score_coeff_op<Scalar> Scoring;
368 typedef typename Scoring::result_type Score;
369 const Index rows = lu.rows();
370 const Index cols = lu.cols();
371 const Index size = (std::min)(rows,cols);
372 nb_transpositions = 0;
373 Index first_zero_pivot = -1;
374 for(Index k = 0; k < size; ++k)
375 {
376 Index rrows = rows-k-1;
377 Index rcols = cols-k-1;
378
379 Index row_of_biggest_in_col;
380 Score biggest_in_corner
381 = lu.col(k).tail(rows-k).unaryExpr(Scoring()).maxCoeff(&row_of_biggest_in_col);
382 row_of_biggest_in_col += k;
383
384 row_transpositions[k] = PivIndex(row_of_biggest_in_col);
385
386 if(biggest_in_corner != Score(0))
387 {
388 if(k != row_of_biggest_in_col)
389 {
390 lu.row(k).swap(lu.row(row_of_biggest_in_col));
391 ++nb_transpositions;
392 }
393
394 // FIXME shall we introduce a safe quotient expression in cas 1/lu.coeff(k,k)
395 // overflow but not the actual quotient?
396 lu.col(k).tail(rrows) /= lu.coeff(k,k);
397 }
398 else if(first_zero_pivot==-1)
399 {
400 // the pivot is exactly zero, we record the index of the first pivot which is exactly 0,
401 // and continue the factorization such we still have A = PLU
402 first_zero_pivot = k;
403 }
404
405 if(k<rows-1)
406 lu.bottomRightCorner(rrows,rcols).noalias() -= lu.col(k).tail(rrows) * lu.row(k).tail(rcols);
407 }
408 return first_zero_pivot;
409 }

Referenced by Eigen::internal::partial_lu_impl< Scalar, StorageOrder, PivIndex >::blocked_lu().

+ Here is the caller graph for this function:

The documentation for this struct was generated from the following file: