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.

COO Matrix#

Basic Vocabulary#

#include <raft/core/coo_matrix.hpp>

template<typename RowType, typename ColType, typename NZType, int is_device>
class coordinate_structure_t : public raft::sparse_structure<RowType, ColType, NZType, is_device>#
#include <coo_matrix.hpp>

Subclassed by raft::coordinate_structure< RowType, ColType, NZType, is_device, ContainerPolicy >, raft::coordinate_structure_view< RowType, ColType, NZType, is_device >

Public Functions

virtual span<RowType, is_device> get_rows() = 0#

Return span containing underlying rows array

Returns:

span containing underlying rows array

virtual span<ColType, is_device> get_cols() = 0#

Return span containing underlying cols array

Returns:

span containing underlying cols array

template<typename RowType, typename ColType, typename NZType, bool is_device>
class coordinate_structure_view : public raft::coordinate_structure_t<RowType, ColType, NZType, is_device>#
#include <coo_matrix.hpp>

A non-owning view into a coordinate structure

The structure representation does not have a value/weight component so that its const-ness can be varied from it.

Template Parameters:
  • RowType

  • ColType

Public Functions

inline virtual span<row_type, is_device> get_rows() override#

Return span containing underlying rows array

Returns:

span containing underlying rows array

inline virtual span<col_type, is_device> get_cols() override#

Return span containing underlying cols array

Returns:

span containing underlying cols array

template<typename RowType, typename ColType, typename NZType, bool is_device, template<typename T> typename ContainerPolicy>
class coordinate_structure : public raft::coordinate_structure_t<RowType, ColType, NZType, is_device>#
#include <coo_matrix.hpp>

Represents a sparse coordinate structure (or edge list) which can be used to model a COO matrix.

The structure representation does not have a value/weight component so that its const-ness can be varied from it.

Template Parameters:
  • RowType

  • ColType

  • ContainerPolicy

Public Functions

inline view_type view()#

Return a view of the coordinate structure. Structural views are sparsity-preserving so while the structural elements can be updated in a non-const view, the sparsity itself (number of nonzeros) cannot be changed.

Returns:

coordinate structure view

inline virtual span<row_type, is_device> get_rows() override#

Return span containing underlying rows array

Returns:

span containing underlying rows array

inline virtual span<col_type, is_device> get_cols() override#

Return span containing underlying cols array

Returns:

span containing underlying cols array

inline virtual void initialize_sparsity(nnz_type nnz)#

Change the sparsity of the current compressed structure. This will resize the underlying data arrays.

Parameters:

nnz – new sparsity

template<typename ElementType, typename RowType, typename ColType, typename NZType, bool is_device>
class coo_matrix_view : public raft::sparse_matrix_view<ElementType, coordinate_structure_view<RowType, ColType, NZType, is_device>, is_device>#
#include <coo_matrix.hpp>
template<typename ElementType, typename RowType, typename ColType, typename NZType, bool is_device, template<typename T> typename ContainerPolicy, SparsityType sparsity_type = SparsityType::OWNING, typename structure_type = std::conditional_t<sparsity_type == SparsityType::OWNING, coordinate_structure<RowType, ColType, NZType, is_device, ContainerPolicy>, coordinate_structure_view<RowType, ColType, NZType, is_device>>>
class coo_matrix : public sparse_matrix<ElementType, std::conditional_t<SparsityType::OWNING == SparsityType::OWNING, coordinate_structure<RowType, ColType, NZType, is_device, ContainerPolicy>, coordinate_structure_view<RowType, ColType, NZType, is_device>>, coo_matrix_view<ElementType, RowType, ColType, NZType, is_device>, is_device, ContainerPolicy>#
#include <coo_matrix.hpp>

Public Functions

template<SparsityType sparsity_type_ = get_sparsity_type(), typename = typename std::enable_if_t<sparsity_type_ == SparsityType::OWNING>>
inline void initialize_sparsity(NZType nnz)#

Initialize the sparsity on this instance if it was not known upon construction Please note this will resize the underlying memory buffers

Parameters:

nnz – new sparsity to initialize.

inline structure_view_type structure_view()#

Return a view of the structure underlying this matrix

Returns:

Device COO Matrix#

#include <raft/core/device_coo_matrix.hpp>

template<typename RowType, typename ColType, typename NZType>
using device_coordinate_structure_view = coordinate_structure_view<RowType, ColType, NZType, true>#

Specialization for a sparsity-preserving coordinate structure view which uses device memory

template<typename RowType, typename ColType, typename NZType, template<typename T> typename ContainerPolicy = device_uvector_policy>
using device_coordinate_structure = coordinate_structure<RowType, ColType, NZType, true, ContainerPolicy>#

Specialization for a sparsity-owning coordinate structure which uses device memory

template<typename ElementType, typename RowType, typename ColType, typename NZType>
using device_coo_matrix_view = coo_matrix_view<ElementType, RowType, ColType, NZType, true>#

Specialization for a coo matrix view which uses device memory

template<typename ElementType, typename RowType, typename ColType, typename NZType, template<typename T> typename ContainerPolicy = device_uvector_policy, SparsityType sparsity_type = SparsityType::OWNING>
using device_coo_matrix = coo_matrix<ElementType, RowType, ColType, NZType, true, ContainerPolicy, sparsity_type>#
template<typename ElementType, typename RowType, typename ColType, typename NZType, template<typename T> typename ContainerPolicy = device_uvector_policy>
using device_sparsity_owning_coo_matrix = coo_matrix<ElementType, RowType, ColType, NZType, true, ContainerPolicy>#

Specialization for a sparsity-owning coo matrix which uses device memory

template<typename ElementType, typename RowType, typename ColType, typename NZType, template<typename T> typename ContainerPolicy = device_uvector_policy>
using device_sparsity_preserving_coo_matrix = coo_matrix<ElementType, RowType, ColType, NZType, true, ContainerPolicy, SparsityType::PRESERVING>#
template<typename T>
constexpr bool is_device_coo_matrix_view_v = is_device_coo_matrix_view<T>::value#
template<typename T>
constexpr bool is_device_coo_matrix_v = is_device_coo_matrix<T>::value#
template<typename T>
constexpr bool is_device_coo_sparsity_owning_v = is_device_coo_matrix<T>::value and T::get_sparsity_type() == OWNING#
template<typename T>
constexpr bool is_device_coo_sparsity_preserving_v = is_device_coo_matrix<T>::value and T::get_sparsity_type() == PRESERVING#
template<typename ElementType, typename RowType, typename ColType, typename NZType>
auto make_device_coo_matrix(raft::resources const &handle, RowType n_rows, ColType n_cols, NZType nnz = 0)#

Create a sparsity-owning sparse matrix in the coordinate format. sparsity-owning means that all of the underlying vectors (data, indptr, indices) are owned by the coo_matrix instance. If not known up front, the sparsity can be ignored in this factory function and resize() invoked on the instance once the sparsity is known.

#include <raft/core/resources.hpp>
#include <raft/core/device_coo_matrix.hpp>

int n_rows = 100000;
int n_cols = 10000;

raft::resources handle;
coo_matrix = raft::make_device_coo_matrix(handle, n_rows, n_cols);
...
// compute expected sparsity
...
int nnz = 5000;
coo_matrix.initialize_sparsity(nnz);
Template Parameters:
  • ElementType

  • RowType

  • ColType

  • NZType

Parameters:
  • handle[in] a raft handle for managing expensive device resources

  • n_rows[in] total number of rows in the matrix

  • n_cols[in] total number of columns in the matrix

  • nnz[in] number of non-zeros in the matrix if known [optional]

Returns:

a sparsity-owning sparse matrix in coordinate (coo) format

template<typename ElementType, typename RowType, typename ColType, typename NZType>
auto make_device_coo_matrix(raft::resources const &handle, device_coordinate_structure_view<RowType, ColType, NZType> structure)#

Create a sparsity-preserving sparse matrix in the coordinate format. sparsity-preserving means that a view of the coo sparsity is supplied, allowing the values in the sparsity to change but not the sparsity itself. The csr_matrix instance does not own the sparsity, the sparsity must be known up front, and cannot be resized later.

#include <raft/core/resources.hpp>
#include <raft/core/device_coo_matrix.hpp>

int n_rows = 100000;
int n_cols = 10000;

raft::resources handle;
coo_structure = raft::make_device_coordinate_structure(handle, n_rows, n_cols);
...
// compute expected sparsity
...
coo_structure.initialize_sparsity(nnz);
coo_matrix = raft::make_device_coo_matrix(handle, coo_structure.view());
Template Parameters:
  • ElementType

  • RowType

  • ColType

  • NZType

Parameters:
  • handle[in] raft handle for managing expensive device resources

  • structure[in] a sparsity-preserving coordinate structural view

Returns:

a sparsity-preserving sparse matrix in coordinate (coo) format

template<typename ElementType, typename RowType, typename ColType, typename NZType>
auto make_device_coo_matrix_view(ElementType *ptr, device_coordinate_structure_view<RowType, ColType, NZType> structure)#

Create a non-owning sparse matrix view in the coordinate format. This is sparsity-preserving, meaning that the underlying sparsity is known and cannot be changed. Use the sparsity-owning coo_matrix if sparsity needs to be mutable.

#include <raft/core/resources.hpp>
#include <raft/core/device_coo_matrix.hpp>

int n_rows = 100000;
int n_cols = 10000;
int nnz = 5000;

// The following pointer is assumed to reference device memory for a size of nnz
float* d_elm_ptr = ...;

raft::resources handle;
coo_structure = raft::make_device_coordinate_structure(handle, n_rows, n_cols, nnz);
coo_matrix_view = raft::make_device_coo_matrix_view(handle, d_elm_ptr, coo_structure.view());
Template Parameters:
  • ElementType

  • RowType

  • ColType

  • NZType

Parameters:
  • ptr[in] a pointer to array of nonzero matrix elements on device (size nnz)

  • structure[in] a sparsity-preserving coordinate structural view

Returns:

a sparsity-preserving sparse matrix in coordinate (coo) format

template<typename ElementType, typename RowType, typename ColType, typename NZType>
auto make_device_coo_matrix_view(raft::device_span<ElementType> elements, device_coordinate_structure_view<RowType, ColType, NZType> structure)#

Create a non-owning sparse matrix view in the coordinate format. This is sparsity-preserving, meaning that the underlying sparsity is known and cannot be changed. Use the sparsity-owning coo_matrix if sparsity needs to be mutable.

#include <raft/core/resources.hpp>
#include <raft/core/device_span.hpp>
#include <raft/core/device_coo_matrix.hpp>

int n_rows = 100000;
int n_cols = 10000;
int nnz = 5000;

// The following span is assumed to be of size nnz
raft::device_span<float> d_elm_ptr;

raft::resources handle;
coo_structure = raft::make_device_coordinate_structure(handle, n_rows, n_cols, nnz);
coo_matrix_view = raft::make_device_coo_matrix_view(handle, d_elm_ptr, coo_structure.view());
Template Parameters:
  • ElementType

  • RowType

  • ColType

  • NZType

Parameters:
  • elements[in] a device span containing nonzero matrix elements (size nnz)

  • structure[in] a sparsity-preserving coordinate structural view

Returns:

template<typename RowType, typename ColType, typename NZType>
auto make_device_coordinate_structure(raft::resources const &handle, RowType n_rows, ColType n_cols, NZType nnz = 0)#

Create a sparsity-owning coordinate structure object. If not known up front, this object can be resized() once the sparsity (number of non-zeros) is known, postponing the allocation of the underlying data arrays.

#include <raft/core/resources.hpp>
#include <raft/core/device_coo_matrix.hpp>

int n_rows = 100000;
int n_cols = 10000;
int nnz = 5000;

raft::resources handle;
coo_structure = raft::make_device_coordinate_structure(handle, n_rows, n_cols, nnz);
 * ...
// compute expected sparsity
...
coo_structure.initialize_sparsity(nnz);
Template Parameters:
  • RowType

  • ColType

  • NZType

Parameters:
  • handle[in] raft handle for managing expensive resources on device

  • n_rows[in] total number of rows

  • n_cols[in] total number of cols

  • nnz[in] number of non-zeros

Returns:

a sparsity-owning coordinate structure instance

template<typename RowType, typename ColType, typename NZType>
auto make_device_coordinate_structure_view(RowType *rows, ColType *cols, RowType n_rows, ColType n_cols, NZType nnz)#

Create a non-owning sparsity-preserved coordinate structure view. Sparsity-preserving means that the underlying sparsity is known and cannot be changed. Use the sparsity-owning version if the sparsity is not known up front.

#include <raft/core/resources.hpp>
#include <raft/core/device_coo_matrix.hpp>

int n_rows = 100000;
int n_cols = 10000;
int nnz = 5000;

// The following pointers are assumed to reference device memory of size nnz
int *rows = ...;
int *cols = ...;

raft::resources handle;
coo_structure = raft::make_device_coordinate_structure_view(handle, rows, cols, n_rows, n_cols,
nnz);
Template Parameters:
  • RowType

  • ColType

  • NZType

Parameters:
  • rows[in] pointer to row indices array on device (size nnz)

  • cols[in] pointer to column indices array on device (size nnz)

  • n_rows[in] total number of rows

  • n_cols[in] total number of columns

  • nnz[in] number of non-zeros

Returns:

a sparsity-preserving coordinate structural view

template<typename RowType, typename ColType, typename NZType>
auto make_device_coordinate_structure_view(raft::device_span<RowType> rows, raft::device_span<ColType> cols, RowType n_rows, ColType n_cols)#

Create a non-owning sparsity-preserved coordinate structure view. Sparsity-preserving means that the underlying sparsity is known and cannot be changed. Use the sparsity-owning version if the sparsity is not known up front.

#include <raft/core/resources.hpp>
#include <raft/core/device_coo_matrix.hpp>

int n_rows = 100000;
int n_cols = 10000;
int nnz = 5000;

// The following device spans are assumed to be of size nnz
raft::device_span<int> rows;
raft::device_span<int> cols;

raft::resources handle;
coo_structure = raft::make_device_coordinate_structure_view(handle, rows, cols, n_rows, n_cols);
Template Parameters:
  • RowType

  • ColType

  • NZType

Parameters:
  • rows[in] a device span containing row indices (size nnz)

  • cols[in] a device span containing column indices (size nnz)

  • n_rows[in] total number of rows

  • n_cols[in] total number of columns

Returns:

a sparsity-preserving coordinate structural view

template<typename T>
struct is_device_coo_matrix_view : public std::false_type#
#include <device_coo_matrix.hpp>
template<typename ElementType, typename RowType, typename ColType, typename NZType>
struct is_device_coo_matrix_view<device_coo_matrix_view<ElementType, RowType, ColType, NZType>> : public std::true_type#
#include <device_coo_matrix.hpp>
template<typename T>
struct is_device_coo_matrix : public std::false_type#
#include <device_coo_matrix.hpp>
template<typename ElementType, typename RowType, typename ColType, typename NZType, template<typename T> typename ContainerPolicy, SparsityType sparsity_type>
struct is_device_coo_matrix<device_coo_matrix<ElementType, RowType, ColType, NZType, ContainerPolicy, sparsity_type>> : public std::true_type#
#include <device_coo_matrix.hpp>

Host COO Matrix#

#include <raft/core/host_coo_matrix.hpp>

template<typename RowType, typename ColType, typename NZType>
using host_coordinate_structure_view = coordinate_structure_view<RowType, ColType, NZType, false>#

Specialization for a sparsity-preserving coordinate structure view which uses host memory

template<typename RowType, typename ColType, typename NZType, template<typename T> typename ContainerPolicy = host_vector_policy>
using host_coordinate_structure = coordinate_structure<RowType, ColType, NZType, false, ContainerPolicy>#

Specialization for a sparsity-owning coordinate structure which uses host memory

template<typename ElementType, typename RowType, typename ColType, typename NZType>
using host_coo_matrix_view = coo_matrix_view<ElementType, RowType, ColType, NZType, false>#

Specialization for a coo matrix view which uses host memory

template<typename ElementType, typename RowType, typename ColType, typename NZType, template<typename T> typename ContainerPolicy = host_vector_policy, SparsityType sparsity_type = SparsityType::OWNING>
using host_coo_matrix = coo_matrix<ElementType, RowType, ColType, NZType, false, ContainerPolicy, sparsity_type>#
template<typename ElementType, typename RowType, typename ColType, typename NZType, template<typename T> typename ContainerPolicy = host_vector_policy>
using host_sparsity_owning_coo_matrix = coo_matrix<ElementType, RowType, ColType, NZType, false, ContainerPolicy>#

Specialization for a sparsity-owning coo matrix which uses host memory

template<typename ElementType, typename RowType, typename ColType, typename NZType, template<typename T> typename ContainerPolicy = host_vector_policy>
using host_sparsity_preserving_coo_matrix = coo_matrix<ElementType, RowType, ColType, NZType, false, ContainerPolicy, SparsityType::PRESERVING>#
template<typename T>
constexpr bool is_host_coo_matrix_view_v = is_host_coo_matrix_view<T>::value#
template<typename T>
constexpr bool is_host_coo_matrix_v = is_host_coo_matrix<T>::value#
template<typename T>
constexpr bool is_host_coo_sparsity_owning_v = is_host_coo_matrix<T>::value and T::get_sparsity_type() == OWNING#
template<typename T>
constexpr bool is_host_coo_sparsity_preserving_v = is_host_coo_matrix<T>::value and T::get_sparsity_type() == PRESERVING#
template<typename ElementType, typename RowType, typename ColType, typename NZType>
auto make_host_coo_matrix(raft::resources const &handle, RowType n_rows, ColType n_cols, NZType nnz = 0)#

Create a sparsity-owning sparse matrix in the coordinate format. sparsity-owning means that all of the underlying vectors (data, indptr, indices) are owned by the coo_matrix instance. If not known up front, the sparsity can be ignored in this factory function and resize() invoked on the instance once the sparsity is known.

#include <raft/core/resources.hpp>
#include <raft/core/host_coo_matrix.hpp>

int n_rows = 100000;
int n_cols = 10000;

raft::resources handle;
coo_matrix = raft::make_host_coo_matrix(handle, n_rows, n_cols);
...
// compute expected sparsity
...
int nnz = 5000;
coo_matrix.initialize_sparsity(nnz);
Template Parameters:
  • ElementType

  • RowType

  • ColType

  • NZType

Parameters:
  • handle[in] raft handle for managing expensive resources

  • n_rows[in] total number of rows in the matrix

  • n_cols[in] total number of columns in the matrix

  • nnz[in] number of non-zeros in the matrix if known [optional]

Returns:

a sparsity-owning sparse matrix in coordinate (coo) format

template<typename ElementType, typename RowType, typename ColType, typename NZType>
auto make_host_coo_matrix(raft::resources const &handle, host_coordinate_structure_view<RowType, ColType, NZType> structure)#

Create a sparsity-preserving sparse matrix in the coordinate format. sparsity-preserving means that a view of the coo sparsity is supplied, allowing the values in the sparsity to change but not the sparsity itself. The coo_matrix instance does not own the sparsity, the sparsity must be known up front, and cannot be resized later.

#include <raft/core/resources.hpp>
#include <raft/core/host_coo_matrix.hpp>

int n_rows = 100000;
int n_cols = 10000;

raft::resources handle;
coo_structure = raft::make_host_coordinate_structure(handle, n_rows, n_cols);
...
// compute expected sparsity
...
coo_structure.initialize_sparsity(nnz);
coo_matrix = raft::make_host_coo_matrix(handle, coo_structure.view());
Template Parameters:
  • ElementType

  • RowType

  • ColType

  • NZType

Parameters:
  • handle[in] raft handle for managing expensive resources

  • structure[in] a sparsity-preserving coordinate structural view

Returns:

a sparsity-preserving sparse matrix in coordinate (coo) format

template<typename ElementType, typename RowType, typename ColType, typename NZType>
auto make_host_coo_matrix_view(ElementType *ptr, host_coordinate_structure_view<RowType, ColType, NZType> structure)#

Create a non-owning sparse matrix view in the coordinate format. This is sparsity-preserving, meaning that the underlying sparsity is known and cannot be changed. Use the sparsity-owning coo_matrix if sparsity needs to be mutable.

#include <raft/core/resources.hpp>
#include <raft/core/host_coo_matrix.hpp>

int n_rows = 100000;
int n_cols = 10000;
int nnz = 5000;

// The following pointer is assumed to reference host-accessible memory for a size of nnz
float* h_elm_ptr = ...;

raft::resources handle;
coo_structure = raft::make_host_coordinate_structure(handle, n_rows, n_cols, nnz);
coo_matrix_view = raft::make_host_coo_matrix_view(handle, h_elm_ptr, coo_structure.view());
Template Parameters:
  • ElementType

  • RowType

  • ColType

  • NZType

Parameters:
  • ptr[in] a pointer to array of nonzero matrix elements on host (size nnz)

  • structure[in] a sparsity-preserving coordinate structural view

Returns:

a sparsity-preserving sparse matrix in coordinate (coo) format

template<typename ElementType, typename RowType, typename ColType, typename NZType>
auto make_host_coo_matrix_view(raft::host_span<ElementType> elements, host_coordinate_structure_view<RowType, ColType, NZType> structure)#

Create a non-owning sparse matrix view in the coordinate format. This is sparsity-preserving, meaning that the underlying sparsity is known and cannot be changed. Use the sparsity-owning coo_matrix if sparsity needs to be mutable.

#include <raft/core/resources.hpp>
#include <raft/core/host_span.hpp>
#include <raft/core/host_coo_matrix.hpp>

int n_rows = 100000;
int n_cols = 10000;
int nnz = 5000;

// The following span is assumed to be of size nnz
raft::host_span<float> h_elm_ptr;

raft::resources handle;
coo_structure = raft::make_host_coordinate_structure(handle, n_rows, n_cols, nnz);
coo_matrix_view = raft::make_host_coo_matrix_view(handle, h_elm_ptr, coo_structure.view());
Template Parameters:
  • ElementType

  • RowType

  • ColType

  • NZType

Parameters:
  • elements[in] a host span containing nonzero matrix elements (size nnz)

  • structure[in] a sparsity-preserving coordinate structural view

Returns:

template<typename RowType, typename ColType, typename NZType>
auto make_host_coordinate_structure(raft::resources const &handle, RowType n_rows, ColType n_cols, NZType nnz = 0)#

Create a sparsity-owning coordinate structure object. If not known up front, this object can be resized() once the sparsity (number of non-zeros) is known, postponing the allocation of the underlying data arrays.

#include <raft/core/resources.hpp>
#include <raft/core/host_coo_matrix.hpp>

int n_rows = 100000;
int n_cols = 10000;
int nnz = 5000;

raft::resources handle;
coo_structure = raft::make_host_coordinate_structure(handle, n_rows, n_cols, nnz);
 * ...
// compute expected sparsity
...
coo_structure.initialize_sparsity(nnz);
Template Parameters:
  • RowType

  • ColType

  • NZType

Parameters:
  • handle[in] raft handle for managing expensive resources on host

  • n_rows[in] total number of rows

  • n_cols[in] total number of cols

  • nnz[in] number of non-zeros

Returns:

a sparsity-owning coordinate structure instance

template<typename RowType, typename ColType, typename NZType>
auto make_host_coordinate_structure_view(RowType *rows, ColType *cols, RowType n_rows, ColType n_cols, NZType nnz)#

Create a non-owning sparsity-preserved coordinate structure view. Sparsity-preserving means that the underlying sparsity is known and cannot be changed. Use the sparsity-owning version if the sparsity is not known up front.

#include <raft/core/resources.hpp>
#include <raft/core/host_coo_matrix.hpp>

int n_rows = 100000;
int n_cols = 10000;
int nnz = 5000;

// The following pointers are assumed to reference host-accessible memory of size nnz
int *rows = ...;
int *cols = ...;

raft::resources handle;
coo_structure = raft::make_host_coordinate_structure_view(handle, rows, cols, n_rows, n_cols,
nnz);
Template Parameters:
  • RowType

  • ColType

  • NZType

Parameters:
  • rows[in] pointer to row indices array on host (size nnz)

  • cols[in] pointer to column indices array on host (size nnz)

  • n_rows[in] total number of rows

  • n_cols[in] total number of columns

  • nnz[in] number of non-zeros

Returns:

a sparsity-preserving coordinate structural view

template<typename RowType, typename ColType, typename NZType>
auto make_host_coordinate_structure_view(raft::host_span<RowType> rows, raft::host_span<ColType> cols, RowType n_rows, ColType n_cols)#

Create a non-owning sparsity-preserved coordinate structure view. Sparsity-preserving means that the underlying sparsity is known and cannot be changed. Use the sparsity-owning version if the sparsity is not known up front.

#include <raft/core/resources.hpp>
#include <raft/core/host_coo_matrix.hpp>

int n_rows = 100000;
int n_cols = 10000;
int nnz = 5000;

// The following host spans are assumed to be of size nnz
raft::host_span<int> rows;
raft::host_span<int> cols;

raft::resources handle;
coo_structure = raft::make_host_coordinate_structure_view(handle, rows, cols, n_rows, n_cols);
Template Parameters:
  • RowType

  • ColType

  • NZType

Parameters:
  • rows[in] a host span containing row indices (size nnz)

  • cols[in] a host span containing column indices (size nnz)

  • n_rows[in] total number of rows

  • n_cols[in] total number of columns

Returns:

a sparsity-preserving coordinate structural view

template<typename T>
struct is_host_coo_matrix_view : public std::false_type#
#include <host_coo_matrix.hpp>
template<typename ElementType, typename RowType, typename ColType, typename NZType>
struct is_host_coo_matrix_view<host_coo_matrix_view<ElementType, RowType, ColType, NZType>> : public std::true_type#
#include <host_coo_matrix.hpp>
template<typename T>
struct is_host_coo_matrix : public std::false_type#
#include <host_coo_matrix.hpp>
template<typename ElementType, typename RowType, typename ColType, typename NZType, template<typename T> typename ContainerPolicy, SparsityType sparsity_type>
struct is_host_coo_matrix<host_coo_matrix<ElementType, RowType, ColType, NZType, ContainerPolicy, sparsity_type>> : public std::true_type#
#include <host_coo_matrix.hpp>