|
| template<class Matrix_ , class EigenMatrix_ , class EigenVector_ > |
| std::pair< bool, int > | compute (const Matrix_ &matrix, const Eigen::Index number, EigenMatrix_ &outU, EigenMatrix_ &outV, EigenVector_ &outD, const Options &options) |
| |
| template<class InputEigenMatrix_ , class OutputEigenMatrix_ , class EigenVector_ > |
| std::pair< bool, int > | compute_simple (const InputEigenMatrix_ &matrix, Eigen::Index number, OutputEigenMatrix_ &outU, OutputEigenMatrix_ &outV, EigenVector_ &outD, const Options &options) |
| |
| template<class EigenMatrix_ = Eigen::MatrixXd, class EigenVector_ = Eigen::VectorXd, class Matrix_ > |
| Results< EigenMatrix_, EigenVector_ > | compute (const Matrix_ &matrix, Eigen::Index number, const Options &options) |
| |
| template<class OutputEigenMatrix_ = Eigen::MatrixXd, class EigenVector_ = Eigen::VectorXd, class InputEigenMatrix_ > |
| Results< OutputEigenMatrix_, EigenVector_ > | compute_simple (const InputEigenMatrix_ &matrix, Eigen::Index number, const Options &options) |
| |
| template<typename Task_ , class Run_ > |
| void | parallelize (Task_ num_tasks, Run_ run_task) |
| |
| template<class InputEigenMatrix_ , class OutputEigenMatrix_ , class EigenVector_ > |
| std::pair< bool, int > | pca (const InputEigenMatrix_ &matrix, bool center, bool scale, Eigen::Index number, OutputEigenMatrix_ &outU, OutputEigenMatrix_ &outV, EigenVector_ &outD, const Options &options) |
| |
| template<class OutputEigenMatrix_ = Eigen::MatrixXd, class EigenVector_ = Eigen::VectorXd, class InputEigenMatrix_ > |
| Results< OutputEigenMatrix_, EigenVector_ > | pca (const InputEigenMatrix_ &matrix, bool center, bool scale, Eigen::Index number, const Options &options) |
| |
Implements IRLBA for approximate SVD.
template<class Matrix_ , class EigenMatrix_ , class EigenVector_ >
| std::pair< bool, int > irlba::compute |
( |
const Matrix_ & | matrix, |
|
|
const Eigen::Index | number, |
|
|
EigenMatrix_ & | outU, |
|
|
EigenMatrix_ & | outV, |
|
|
EigenVector_ & | outD, |
|
|
const Options & | options ) |
Implements the Implicitly Restarted Lanczos Bidiagonalization Algorithm (IRLBA) for fast truncated singular value decomposition. This is heavily derived from the C code in the irlba package, with refactoring into C++ to use Eigen instead of LAPACK for much of the matrix algebra.
- Template Parameters
-
| Matrix_ | Class satisfying the Matrix<EigenVector_, EigenMatrix_> interface. |
| EigenMatrix_ | A dense floating-point Eigen::Matrix class to store the output. |
| EigenVector_ | A floating-point Eigen::Vector class to store the output, typically of the same scalar type as EigenMatrix_. |
- Parameters
-
| [in] | matrix | Input matrix. |
| number | Number of singular triplets to obtain. |
| [out] | outU | Output matrix where columns contain the first left singular vectors. Dimensions are set automatically on output; the number of columns is set to number and the number of rows is equal to the number of rows in mat. |
| [out] | outV | Output matrix where columns contain the first right singular vectors. Dimensions are set automatically on output; the number of columns is set to number and the number of rows is equal to the number of columns in mat. |
| [out] | outD | Vector to store the first singular values. The length is set to number on output. |
| options | Further options. |
- Returns
- A pair where the first entry indicates whether the algorithm converged, and the second entry indicates the number of restart iterations performed.
template<typename Task_ , class Run_ >
| void irlba::parallelize |
( |
Task_ | num_tasks, |
|
|
Run_ | run_task ) |
- Template Parameters
-
| Task_ | Integer type for the number of tasks. |
| Run_ | Function to execute each task. |
- Parameters
-
| num_tasks | Number of tasks. This is equal to the number of threads in the context of ParallelSparseMatrix. |
| run_task | Function to execute each task within its own worker. |
By default, this is an alias to subpar::parallelize_simple(). However, if the IRLBA_CUSTOM_PARALLEL function-like macro is defined, it is called instead. Any user-defined macro should accept the same arguments as subpar::parallelize_simple().
template<class InputEigenMatrix_ , class OutputEigenMatrix_ , class EigenVector_ >
| std::pair< bool, int > irlba::pca |
( |
const InputEigenMatrix_ & | matrix, |
|
|
bool | center, |
|
|
bool | scale, |
|
|
Eigen::Index | number, |
|
|
OutputEigenMatrix_ & | outU, |
|
|
OutputEigenMatrix_ & | outV, |
|
|
EigenVector_ & | outD, |
|
|
const Options & | options ) |
Perform a principal components analysis (PCA) using IRLBA for the underlying SVD. This applies deferred centering and scaling via the CenteredMatrix and ScaledMatrix classes, respectively.
- Template Parameters
-
| InputEigenMatrix_ | An Eigen matrix class containing the input data. |
| OutputEigenMatrix_ | A dense floating-point Eigen::Matrix class for the output. |
| EigenVector_ | A floating-point Eigen::Vector class for the output, typically of the same scalar type as OutputEigenMatrix_. |
- Parameters
-
| [in] | matrix | Input matrix. |
| center | Should the matrix be centered by column? |
| scale | Should the matrix be scaled to unit variance for each column? |
| number | Number of singular triplets to obtain. |
| [out] | outU | Output matrix where columns contain the first left singular vectors. Dimensions are set automatically on output; the number of columns is set to number and the number of rows is equal to the number of rows in mat. |
| [out] | outV | Output matrix where columns contain the first right singular vectors. Dimensions are set automatically on output; the number of columns is set to number and the number of rows is equal to the number of columns in mat. |
| [out] | outD | Vector to store the first singular values. The length is set to number on output. |
| options | Further options. |
- Returns
- A pair where the first entry indicates whether the algorithm converged, and the second entry indicates the number of restart iterations performed.
Centering is performed by subtracting each element of center from the corresponding column of mat. Scaling is performed by dividing each column of mat by the corresponding element of scale (after any centering has been applied). Note that scale=true requires center=true to guarantee unit variance along each column. No scaling is performed when the variance of a column is zero, so as to avoid divide-by-zero errors.