Gaussian Sketching

template<Number T, DataLocation L = Host>
class GaussianSketch

Gaussian Embedding is a random matrix \( \Gamma \in \mathbb{R}^{n \times s}\) where each entry is i.i.d. random variable from the Gaussian distribution \( \mathcal{N}(0, s^{-1})\). This sketching operator has the strongest theoretical support among all sketching methods, but it requires O(ns) space in memory to be stored and can be applied to a vector in O(ns) operations. It can be applied in both sides of the matrix and can be used on accelerators.

Template Parameters:
  • T – Data type of the sketching matrix.

  • L – Location of the data.

Public Functions

GaussianSketch() = default

Creates a new sketching operator.

inline GaussianSketch(const GaussianSketchOptions &options)

Creates a new sketching operator according to options.

Parameters:

options[in] sketching parameters

virtual ~GaussianSketch() = default

Destructor.

inline void set_params(const GaussianSketchOptions &options)

Sets the parameter of the sketching.

Parameters:

options[in] sketching parameters

inline DCTResultVec operator()(VectorMap<T, L> v)

Calculates the random sketch of a vector v.

Parameters:

v[in] input vector

Returns:

An abstract object representing the sketch

inline DCTResultMat operator()(MatrixMap<T, L> A)

Calculates the random sketch of a matrix A. The sketching is applied to each column of the matrix.

Parameters:

A[in] input matrix

Returns:

An abstract object representing the sketch

struct GaussianSketchOptions

Options for the GaussianSketch.

Public Members

index_t input_size

The number of rows of the input.

index_t sketch_size

Sketch size.

uint128_t seed = random::DefaultGenerator::default_seed

Random seed for the random number generator.

uint128_t stream = random::DefaultGenerator::default_stream

Random stream for the random number generator.

OpSide side = kLeft

Specify which side to apply the sketching operator.