For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
GitHubCUDA-X
    • Home
    • Installation
  • Getting Started
    • Introduction
    • Integrations
    • Use-cases
  • User Guide
    • API Guide
    • Benchmarking Guide
    • Compatibility
    • Integration Patterns
    • Advanced Topics
    • References
  • Developer Guide
    • Coding Guidelines
    • ABI Stability
    • Link-time Optimization
    • Contributing
  • API Reference
    • C API Documentation
    • Cpp API Documentation
      • Cluster Agglomerative
      • Cluster Kmeans
      • Cluster Spectral
      • Common Types
        • Execution Resources
        • Dense Array Views
        • Dense View Factories
        • Owning Dense Arrays
        • Owning Array Factories
        • Layouts and Extents
        • Sparse Array Types
        • Copy, Serialization, and Utility APIs
        • Errors and Logging
      • Distance Distance
      • Distance Grammian
      • Neighbors All Neighbors
      • Neighbors Ball Cover
      • Neighbors Brute Force
      • Neighbors Cagra
      • Neighbors Common
      • Neighbors Dynamic Batching
      • Neighbors Epsilon Neighborhood
      • Neighbors HNSW
      • Neighbors Composite Index
      • Neighbors IVF Flat
      • Neighbors IVF PQ
      • Neighbors NN Descent
      • Neighbors Refine
      • Neighbors Scann
      • Neighbors Tiered Index
      • Neighbors Vamana
      • Preprocessing Quantize Binary
      • Preprocessing PCA
      • Preprocessing Quantize PQ
      • Preprocessing Quantize Scalar
      • Preprocessing Spectral Embedding
      • Selection Select K
      • Stats Silhouette Score
      • Stats Trustworthiness Score
      • Util Cutlass Utils
      • Util File Io
    • Python API Documentation
    • Java API Documentation
    • Rust API Documentation
    • Go API Documentation
NVIDIANVIDIA
Developer-friendly docs for your API
Privacy Policy | Manage My Privacy | Do Not Sell or Share My Data | Terms of Service | Accessibility | Corporate Policies | Product Security | Contact

Copyright © 2026, NVIDIA Corporation.

LogoLogocuVS
GitHubCUDA-X
On this page
  • raft::device_csr_matrix
  • raft::device_csr_matrix::initialize_sparsity
  • raft::device_csr_matrix::get_elements
  • raft::device_csr_matrix::structure_view
  • raft::device_csr_matrix::view
  • raft::device_csr_matrix_view
  • raft::device_csr_matrix_view::get_elements
  • raft::device_csr_matrix_view::structure_view
  • raft::device_coo_matrix
  • raft::device_coo_matrix::initialize_sparsity
  • raft::device_coo_matrix::get_elements
  • raft::device_coo_matrix::structure_view
  • raft::device_coo_matrix::view
  • raft::device_coo_matrix_view
  • raft::device_coo_matrix_view::get_elements
  • raft::device_coo_matrix_view::structure_view
  • raft::make_device_csr_matrix
  • raft::make_device_coo_matrix
API ReferenceCpp API DocumentationCommon Types

Sparse Array Types

||View as Markdown|
Previous

Layouts and Extents

Next

Copy, Serialization, and Utility APIs

Sparse RAFT types describe both the sparsity pattern and the values for APIs that accept sparse feature matrices or graph-style connectivity data.

raft::device_csr_matrix

Source header: raft/core/device_csr_matrix.hpp

Owning compressed sparse row matrix in device memory.

1template <typename ElementType,
2 typename IndptrType,
3 typename IndicesType,
4 typename NZType,
5 template <typename T> typename ContainerPolicy = device_container_policy,
6 SparsityType sparsity_type = SparsityType::OWNING>
7using device_csr_matrix =
8 csr_matrix<ElementType, IndptrType, IndicesType,
9 NZType, true, ContainerPolicy, sparsity_type>;

raft::device_csr_matrix::initialize_sparsity

Initializes or changes the number of nonzero entries when the matrix owns its sparsity.

1void initialize_sparsity(NNZType nnz);

Parameters

NameTypeDescription
nnzNNZTypeNumber of nonzero entries.

Returns

void

raft::device_csr_matrix::get_elements

Returns a span over the nonzero values.

1raft::device_span<ElementType> get_elements();

Returns

raft::device_span<ElementType>

raft::device_csr_matrix::structure_view

Returns a non-owning view of the CSR sparsity structure. The returned view exposes the row offsets and column indices.

1structure_view_type structure_view();

Returns

structure_view_type

raft::device_csr_matrix::view

Returns a sparsity-preserving non-owning view of the sparse matrix.

1view_type view();

Returns

view_type

raft::device_csr_matrix_view

Source header: raft/core/device_csr_matrix.hpp

Non-owning compressed sparse row matrix view over device memory.

1template <typename ElementType,
2 typename IndptrType,
3 typename IndicesType,
4 typename NZType>
5using device_csr_matrix_view =
6 csr_matrix_view<ElementType, IndptrType, IndicesType, NZType, true>;

raft::device_csr_matrix_view::get_elements

Returns a span over the nonzero values.

1raft::device_span<ElementType> get_elements();

Returns

raft::device_span<ElementType>

raft::device_csr_matrix_view::structure_view

Returns a non-owning view of the CSR sparsity structure.

1structure_view_type structure_view();

Returns

structure_view_type

raft::device_coo_matrix

Source header: raft/core/device_coo_matrix.hpp

Owning coordinate sparse matrix in device memory.

1template <typename ElementType,
2 typename RowType,
3 typename ColType,
4 typename NZType,
5 template <typename T> typename ContainerPolicy = device_container_policy,
6 SparsityType sparsity_type = SparsityType::OWNING>
7using device_coo_matrix =
8 coo_matrix<ElementType, RowType, ColType,
9 NZType, true, ContainerPolicy, sparsity_type>;

raft::device_coo_matrix::initialize_sparsity

Initializes or changes the number of nonzero entries when the matrix owns its sparsity.

1void initialize_sparsity(NNZType nnz);

Parameters

NameTypeDescription
nnzNNZTypeNumber of nonzero entries.

Returns

void

raft::device_coo_matrix::get_elements

Returns a span over the nonzero values.

1raft::device_span<ElementType> get_elements();

Returns

raft::device_span<ElementType>

raft::device_coo_matrix::structure_view

Returns a non-owning view of the COO sparsity structure. The returned view exposes the row and column coordinate arrays.

1structure_view_type structure_view();

Returns

structure_view_type

raft::device_coo_matrix::view

Returns a sparsity-preserving non-owning view of the sparse matrix.

1view_type view();

Returns

view_type

raft::device_coo_matrix_view

Source header: raft/core/device_coo_matrix.hpp

Non-owning coordinate sparse matrix view over device memory.

1template <typename ElementType,
2 typename RowType,
3 typename ColType,
4 typename NZType>
5using device_coo_matrix_view =
6 coo_matrix_view<ElementType, RowType, ColType, NZType, true>;

raft::device_coo_matrix_view::get_elements

Returns a span over the nonzero values.

1raft::device_span<ElementType> get_elements();

Returns

raft::device_span<ElementType>

raft::device_coo_matrix_view::structure_view

Returns a non-owning view of the COO sparsity structure.

1structure_view_type structure_view();

Returns

structure_view_type

raft::make_device_csr_matrix

Source header: raft/core/device_csr_matrix.hpp

Allocates an owning CSR matrix.

1template <typename ElementType,
2 typename IndptrType,
3 typename IndicesType,
4 typename NZType = uint64_t>
5auto make_device_csr_matrix(raft::resources const& handle,
6 IndptrType n_rows,
7 IndicesType n_cols,
8 NZType nnz = 0);
9
10template <typename ElementType,
11 typename IndptrType,
12 typename IndicesType,
13 typename NZType = uint64_t>
14auto make_device_csr_matrix(
15 raft::resources const& handle,
16 device_compressed_structure_view<IndptrType,
17 IndicesType,
18 NZType> structure);

Parameters

NameTypeDescription
handleraft::resources const&Resources object used for allocation.
n_rowsIndptrTypeNumber of rows.
n_colsIndicesTypeNumber of columns.
nnzNZTypeNumber of nonzero entries when known.
structuredevice_compressed_structure_view<IndptrType, IndicesType, NZType>Existing CSR sparsity structure for sparsity-preserving matrices.

Returns

raft::device_csr_matrix<ElementType, IndptrType, IndicesType, NZType>

raft::make_device_coo_matrix

Source header: raft/core/device_coo_matrix.hpp

Allocates an owning COO matrix.

1template <typename ElementType,
2 typename RowType,
3 typename ColType,
4 typename NZType>
5auto make_device_coo_matrix(raft::resources const& handle,
6 RowType n_rows,
7 ColType n_cols,
8 NZType nnz = 0);
9
10template <typename ElementType,
11 typename RowType,
12 typename ColType,
13 typename NZType>
14auto make_device_coo_matrix(
15 raft::resources const& handle,
16 device_coordinate_structure_view<RowType,
17 ColType,
18 NZType> structure);

Parameters

NameTypeDescription
handleraft::resources const&Resources object used for allocation.
n_rowsRowTypeNumber of rows.
n_colsColTypeNumber of columns.
nnzNZTypeNumber of nonzero entries when known.
structuredevice_coordinate_structure_view<RowType, ColType, NZType>Existing COO sparsity structure for sparsity-preserving matrices.

Returns

raft::device_coo_matrix<ElementType, RowType, ColType, NZType>