Attention

The vector search and clustering algorithms in RAFT are being migrated to a new library dedicated to vector search called cuVS. We will continue to support the vector search algorithms in RAFT during this move, but will no longer update them after the RAPIDS 24.06 (June) release. We plan to complete the migration by RAPIDS 24.08 (August) release.

Matrix Manipulation#

Initialization#

#include <raft/matrix/init.cuh>

namespace raft::matrix

template<typename math_t, typename extents, typename layout>
void fill(raft::resources const &handle, raft::device_mdspan<const math_t, extents, layout> in, raft::device_mdspan<math_t, extents, layout> out, raft::host_scalar_view<math_t> scalar)#

set values to scalar in matrix

Template Parameters:
  • math_t – data-type upon which the math operation will be performed

  • extents – dimension and indexing type used for the input

  • layout – layout of the matrix data (must be row or col major)

Parameters:
  • handle[in] raft handle

  • in[in] input matrix

  • out[out] output matrix. The result is stored in the out matrix

  • scalar[in] scalar value to fill matrix elements

template<typename math_t, typename extents, typename layout>
void fill(raft::resources const &handle, raft::device_mdspan<math_t, extents, layout> inout, math_t scalar)#

set values to scalar in matrix

Template Parameters:
  • math_t – data-type upon which the math operation will be performed

  • extents – dimension and indexing type used for the input

  • layout_t – layout of the matrix data (must be row or col major)

Parameters:
  • handle[in] raft handle

  • inout[inout] input matrix

  • scalar[in] scalar value to fill matrix elements

Reverse#

#include <raft/matrix/reverse.cuh>

namespace raft::matrix

template<typename m_t, typename idx_t, typename layout_t>
void col_reverse(raft::resources const &handle, raft::device_matrix_view<m_t, idx_t, layout_t> inout)#

Reverse the columns of a matrix in place (i.e. first column and last column are swapped)

Parameters:
  • handle[in] raft handle

  • inout[inout] input and output matrix

template<typename m_t, typename idx_t, typename layout_t>
void row_reverse(raft::resources const &handle, raft::device_matrix_view<m_t, idx_t, layout_t> inout)#

Reverse the rows of a matrix in place (i.e. first row and last row are swapped)

Parameters:
  • handle[in] raft handle

  • inout[inout] input and output matrix

Threshold#

#include <raft/matrix/threshold.cuh>

namespace raft::matrix

template<typename math_t, typename idx_t, typename layout>
void zero_small_values(raft::resources const &handle, raft::device_matrix_view<const math_t, idx_t, layout> in, raft::device_matrix_view<math_t, idx_t, layout> out, math_t thres = 1e-15)#

sets the small values to zero based on a defined threshold

Template Parameters:
  • math_t – data-type upon which the math operation will be performed

  • idx_t – integer type used for indexing

  • layout – layout of the matrix data (must be row or col major)

Parameters:
  • handle – raft handle

  • in[in] input matrix

  • out[out] output matrix. The result is stored in the out matrix

  • thres[in] threshold to set values to zero

template<typename math_t, typename idx_t, typename layout>
void zero_small_values(raft::resources const &handle, raft::device_matrix_view<math_t, idx_t, layout> inout, math_t thres = 1e-15)#

sets the small values to zero in-place based on a defined threshold

Template Parameters:
  • math_t – data-type upon which the math operation will be performed

  • idx_t – integer type used for indexing

  • layout – layout of the matrix data (must be row or col major)

Parameters:
  • handle – raft handle

  • inout – input matrix and also the result is stored

  • thres – threshold