Base Layer¶
This layer provides the foundation of the entire libSkylark library.
Random Values¶
Random values are generated in a lazy fashion using Random123 library. The access to the random streams is wrapped in two classes, which abstracts random number arrays.
- type struct skylark::utility::random_samples_array_t<Distribution>¶
- random_samples_array_t(size_t base, size_t size, int seed, Distribution& distribution)¶
Random-access array of samples drawn from a distribution starting from base up to a total of size samples. The distribution determines how samples are drawn.
- random_samples_array_t(const random_samples_array_t& other)¶
- random_samples_array_t& operator=(const random_samples_array_t& other)¶
Accessors
- value_type operator[](size_t index) const¶
Returns the random value (following the specified distribution) at position index in the random stream.
libSkylark Context¶
The library provides and tracks the state of the random number streams in the context class. Any use of functionality that generates random numbers will need to provide a context object.
- type struct skylark::base::context_t¶
Constructor
- context_t(int seed, int counter=0)¶
Initialize a context with a seed that is used for all computations.
Serialization
- context_t(const boost::property_tree::ptree& json)¶
Load a context from a serialized ptree structure.
- boost::property_tree::ptree to_ptree() const¶
Serialize the context to a Boost ptree.
Query
- size_t get_counter()¶
Returns the current position in the random stream.
Accessors
- skylark::utility::random_samples_array_t<Distribution> allocate_random_samples_array(size_t size, Distribution& distribution)¶
Returns a container of samples drawn from a distribution to be accessed as an array. The container contains size samples drawn from the specified distribution.
- std::vector<typename Distribution::result_type> generate_random_samples_array(size_t size, Distribution& distribution)¶
Returns a vector of samples drawn from a distribution. The vector contains size samples drawn from the specified distribution.
- skylark::utility::random_array_t allocate_random_array(size_t size)¶
Returns a container of random numbers to be accessed as an array. The container lazily provides size samples.
- int random_int()¶
Returns an integer random number.
Local sparse matrices¶
This implements a very crude CSC sparse matrix container only intended to hold local sparse matrices.
- Row indices are not sorted.
- Structure is always constants, and can only be attached by Attached.
- Values of non-zeros can be modified.
- type struct skylark::base::sparse_matrix_t<T>¶
Constructor
- sparse_matrix_t()¶
Creates a new sparse matrix.
- sparse_matrix_t sparse_matrix_t(sparse_matrix_t<ValueType>&& A)¶
Move constructor.
Query
- int height() const¶
Height of the matrix (number of rows).
- int width() const¶
Width of the matrix (number of cols).
- int nonzeros() const¶
Number of non-zeros.
- bool struct_updated() const¶
Flag that encodes if CSC structure has been modified.
- void reset_update_flag()¶
Reset the modified flag (to false).
Accessors
- const int* indptr() const¶
Access to indices pointer array.
- const int* indices() const¶
Access to non-zero column indices array.
- T* values()¶
Access to non-zero value array.
- const T* locked_values() const¶
Read only view on non-zero values.
Modifiers
- void detach<IdxType, ValType>(IdxType* indptr, IdxType* indices, ValType* values) const¶
Copy CSC data to external buffer.
- void attach(const int* indptr, const int* indices, double* values, int nnz, int n_rows, int n_cols, bool _own=false)¶
Attach CSC matrix data.
- void attach(const int* indptr, const int* indices, double* values, int nnz, int n_rows, int n_cols, bool ownindptr, bool ownindices, bool ownvalues)¶
Attach CSC matrix data where the caller can decide who retains the ownership.
Random Dense Matrices¶
The library provides functions for filling Elemental dense matrices (local or distributed) using the library’s random number generator.
- void RandomMatrix(El::Matrix<T>& A, El::Int m, El::Int n, DistributionType<T>& dist, context_t& context)¶
- void RandomMatrix(El::DistMatrix<T, CD, RD>& A, El::Int m, El::Int n, DistributionType<T>& dist, context_t& context)¶
Resize matrix to m-by-n and fill with entries which are i.i.d samples of the distribution.
- void GaussianMatrix(MatrixType& A, El::Int m, El::Int n, context_t& context)¶
Resize matrix to m-by-n and fill with entries which are i.i.d samples from standard normal distribution.
- void UniformMatrix(MatrixType& A, El::Int m, El::Int n, context_t& context)¶
Resize matrix to m-by-n and fill with entries which are i.i.d samples from a uniform distrbution on [0,1).
Cross matrix-type GEMM and other linear algebra routines¶
To be added...