All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Pages
Public Member Functions | List of all members
paal::frequent_directions< Matrix > Class Template Reference

Represents sketch of matrix. More...

#include <frequent_directions.hpp>

Public Member Functions

template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 serialize
 
 frequent_directions (Matrix matrix, std::size_t const compress_size)
 Creates sketch. More...
 
 frequent_directions ()
 default constructor, only for serialization purpose
 
bool operator== (frequent_directions const &other) const
 operator==
 
template<typename MatrixData >
void update (MatrixData &&matrix)
 Adds new data in matrix form.
 
template<typename InputRow >
void update_row (InputRow &&input_row)
 Adds one new row.
 
template<typename RowRange >
void update_range (RowRange &&row_range)
 Adds new rows.
 
void compress ()
 Compress sketch. More...
 
std::pair< Matrix const
&, std::size_t > 
get_sketch ()
 

Detailed Description

template<typename Matrix>
class paal::frequent_directions< Matrix >

Represents sketch of matrix.

example:

#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.hpp>
#include <iostream>
#include <vector>
using coordinate_t = double;
using matrix_t = boost::numeric::ublas::matrix<coordinate_t>;
int main() {
std::size_t const rows_count = 5;
std::size_t const columns_count = 3;
std::size_t const sketch_size = 4;
auto fd_sketch = paal::make_frequent_directions<coordinate_t>(sketch_size, columns_count);
matrix_t data(rows_count, columns_count);
for (auto i : paal::irange(rows_count)) {
for (auto j : paal::irange(columns_count)) {
data(i, j) = i + j;
}
}
fd_sketch.update(std::move(data));
std::vector<std::vector<coordinate_t>> rows = {
{2, 1, 0},
{3, 2, 1},
{4, 3, 2},
{5, 4, 3},
{6, 5, 4}};
fd_sketch.update_range(std::move(rows));
auto row = {7.0, 6.0, 5.0};
fd_sketch.update_row(std::move(row));
fd_sketch.compress();
auto actual_size = fd_sketch.get_sketch().second;
std::cout << "Actual sketch size: " << actual_size << std::endl;
auto sketch = fd_sketch.get_sketch().first;
boost::numeric::ublas::matrix_range<matrix_t> sketch_range (sketch,
boost::numeric::ublas::range(0, actual_size),
boost::numeric::ublas::range(0, columns_count));
std::cout << "Sketch data:" << std::endl;
paal::print_matrix(std::cout, sketch_range, " ");
std::cout << std::endl;
return 0;
}

complete example is frequent_directions_example.cpp

Template Parameters
Matrix

Definition at line 92 of file frequent_directions.hpp.

Constructor & Destructor Documentation

template<typename Matrix >
paal::frequent_directions< Matrix >::frequent_directions ( Matrix  matrix,
std::size_t const  compress_size 
)
inline

Creates sketch.

Parameters
matrixsketch matrix where data is stored
compress_sizenumber of nonzero rows after compress phase

Definition at line 115 of file frequent_directions.hpp.

Member Function Documentation

template<typename Matrix >
void paal::frequent_directions< Matrix >::compress ( )
inline

Compress sketch.

After compress phase sketch contains m_compress_size nonzero rows.

Definition at line 164 of file frequent_directions.hpp.

template<typename Matrix >
std::pair<Matrix const &, std::size_t> paal::frequent_directions< Matrix >::get_sketch ( )
inline
Returns
sketch and number of its nonzero rows

Definition at line 192 of file frequent_directions.hpp.


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