powerit
C++ implementation for power iterations
|
Namespace for power iterations. More...
Classes | |
struct | Options |
Options for compute() . More... | |
struct | Result |
Result of compute() . More... | |
Functions | |
template<typename Data_ , class Engine_ > | |
void | fill_starting_vector (size_t order, Data_ *vector, Engine_ &engine) |
template<class Multiply_ , typename Data_ > | |
Result< Data_ > | compute_core (size_t order, Multiply_ multiply, Data_ *vector, const Options &opt) |
template<typename Task_ , class Run_ > | |
void | parallelize (int num_workers, Task_ num_tasks, Run_ run_task_range) |
template<typename Data_ , class Engine_ > | |
Result< Data_ > | compute (size_t order, const Data_ *matrix, bool row_major, Data_ *vector, Engine_ &engine, const Options &opt) |
template<typename Data_ > | |
Result< Data_ > | compute (size_t order, const Data_ *matrix, bool row_major, Data_ *vector, const Options &opt) |
Namespace for power iterations.
Result< Data_ > powerit::compute | ( | size_t | order, |
const Data_ * | matrix, | ||
bool | row_major, | ||
Data_ * | vector, | ||
const Options & | opt | ||
) |
Perform power iterations on an array containing a diagonizable matrix. This overload assumes that a random starting vector has already been generated.
Data_ | Floating-point type for the data. |
order | Order of the square matrix. | |
[in] | matrix | Pointer to an array containing an order -by-order diagonalizable matrix. |
row_major | Whether matrix is row-major. | |
[in,out] | vector | Pointer to an array of length order . On input, this should contain a random starting vector. On output, this contains the estimate of the first eigenvector. |
opt | Further options. |
Result< Data_ > powerit::compute | ( | size_t | order, |
const Data_ * | matrix, | ||
bool | row_major, | ||
Data_ * | vector, | ||
Engine_ & | engine, | ||
const Options & | opt | ||
) |
Perform power iterations on a diagonizable matrix to find the first eigenvalue/vector. This overload generates a starting vector from an existing (P)RNG.
Data_ | Floating-point type for the data. |
Engine_ | Any C++11-compliant random number generator class. |
order | Order of the square matrix. | |
[in] | matrix | Pointer to an array containing an order -by-order diagonalizable matrix. |
row_major | Whether matrix is row-major. | |
[out] | vector | Pointer to an array of length order . On output, this contains the estimate of the first eigenvector. |
engine | Instance of the random number generator. | |
opt | Further options. |
Result< Data_ > powerit::compute_core | ( | size_t | order, |
Multiply_ | multiply, | ||
Data_ * | vector, | ||
const Options & | opt | ||
) |
Perform power iterations on some diagonizable matrix to find the first eigenvalue/vector. This overload generates a starting vector from an existing (P)RNG.
Multiply_ | Function that performs a matrix dot product. This is used to abstract away the representation of the actual matrix. |
Data_ | Floating-point type for the data. |
Engine_ | Any C++11-compliant random number generator class. |
order | Order of the square matrix. | |
multiply | Function to perform a matrix dot product with the working eigenvector. This should accept buffer , a std::vector<Data_>& of length order ; and vector , a const Data_* as described below. It should fill buffer with the product of the matrix and vector . The return value is ignored. | |
[out] | vector | Pointer to an array of length order . On output, this contains the estimate of the first eigenvector. |
opt | Further options. |
void powerit::fill_starting_vector | ( | size_t | order, |
Data_ * | vector, | ||
Engine_ & | engine | ||
) |
Data_ | Floating-point type for the data. |
Engine_ | Any C++11-compliant random number generator class. |
order | Length of the array in vector . | |
[out] | vector | Pointer to an array of length order . On output, this will be filled with draws from a standard normal distribution. |
engine | Instance of the random number generator. |
void powerit::parallelize | ( | int | num_workers, |
Task_ | num_tasks, | ||
Run_ | run_task_range | ||
) |
Task_ | Integer type for the number of tasks. |
Run_ | Function to execute a range of tasks. |
num_workers | Number of workers. |
num_tasks | Number of tasks. |
run_task_range | Function to iterate over a range of tasks within a worker. |
By default, this is an alias to subpar::parallelize_range()
. However, if the POWERIT_CUSTOM_PARALLEL
function-like macro is defined, it is called instead. Any user-defined macro should accept the same arguments as subpar::parallelize_range()
.