.. _oneapi-mkl-sparse-set_csr_data:

oneapi::mkl::sparse::set_csr_data
=================================


Takes a matrix handle and the input Compressed Sparse Row (CSR)  matrix arrays and fills the
internal CSR data structure.


.. contents::
    :local:
    :depth: 1

Description
***********

The ``oneapi::mkl::sparse::set_csr_data`` routine takes a matrix handle
for a sparse matrix of dimensions ``num_rows`` -by- ``num_cols``
represented in the CSR format, and fills the internal CSR data
structure.

.. note::
   Refer to :ref:`Supported Types <supported-types>` for a list of supported ``<fp>`` and ``<intType>``, and refer to :ref:`Exceptions <exceptions>` for a detailed description of the exceptions thrown.


API
***

Syntax
------

.. note::
   Currently, complex types are not supported.


**Using SYCL buffers:**

.. code-block:: cpp

    namespace oneapi::mkl:sparse {
        void set_csr_data (
            oneapi::mkl::sparse::matrix_handle_t handle,
            const intType num_rows,
            const intType num_cols,
            oneapi::mkl::index_base index,
            cl::sycl::buffer<intType, 1> &row_ptr,
            cl::sycl::buffer<intType, 1> &col_ind,
            cl::sycl::buffer<fp, 1> &val)
     }


**Using USM pointers:**

.. code-block:: cpp

    namespace oneapi::mkl:sparse {
        void set_csr_data (
            oneapi::mkl::sparse::matrix_handle_t handle,
            const intType num_rows,
            const intType num_cols,
            oneapi::mkl::index_base index,
            intType *row_ptr,
            intType *col_ind, 
            fp *val)
    }


Include Files
-------------

-  oneapi/mkl/spblas.hpp


Input Parameters
----------------

handle
   Handle to object containing sparse matrix and other internal data
   for subsequent Sparse BLAS operations.


num_rows
   Number of rows of the input matrix.


num_cols
   Number of columns of the input matrix.


index
   Indicates how input arrays are indexed.


   .. list-table::
      :header-rows: 0

      * - ``oneapi::mkl::index_base::zero``
        - Zero-based (C-style) indexing: indices start at 0.
      * - ``oneapi::mkl::index_base::one``
        - One-based (Fortran-style) indexing: indices start at 1.


row_ptr
   SYCL memory object containing an array of length ``num_rows+1``. 
   Could be a SYCL buffer or a device-accessible USM pointer. Refer to 
   :ref:`Sparse Storage Formats<sparse-storage-formats>` for a detailed 
   description of ``row_ptr``.

col_ind
   SYCL memory object which stores an array containing the column
   indices in ``index``-based numbering. Could be a SYCL buffer or a 
   device-accessible USM pointer. Refer to :ref:`Sparse Storage Formats<sparse-storage-formats>` 
   for a detailed description of ``col_ind``.


val
   SYCL memory object which stores an array containing the non-zero
   elements of the input matrix. Could be a SYCL buffer or a device-accessible USM 
   pointer. Refer to :ref:`Sparse Storage Formats<sparse-storage-formats>` for a
   detailed description of ``val``.



Output Parameters
-----------------

handle
   Handle to object containing sparse matrix and other internal data
   for subsequent DPC++ Sparse BLAS operations.