MatCreateAIJHIPSPARSE — PETSc 3.25.4 documentation

Skip to main content
`Ctrl`+`K`

# MatCreateAIJHIPSPARSE

Creates a sparse matrix in AIJ (compressed row) format (the default parallel PETSc format).

## Synopsis

    #include "petscmat.h"
    PetscErrorCode MatCreateAIJHIPSPARSE(MPI_Comm comm, PetscInt m, PetscInt n, PetscInt M, PetscInt N, PetscInt d_nz, const PetscInt d_nnz[], PetscInt o_nz, const PetscInt o_nnz[], Mat *A)

Collective

## Input Parameters

- comm - MPI communicator, set to `PETSC_COMM_SELF`

- m - number of local rows (or `PETSC_DECIDE` to have calculated if `M` is given) This value should be the same as the local size used in creating the y vector for the matrix-vector product y = Ax.

- n - This value should be the same as the local size used in creating the x vector for the matrix-vector product y = Ax. (or PETSC_DECIDE to have calculated if `N` is given) For square matrices `n` is almost always `m`.

- M - number of global rows (or `PETSC_DETERMINE` to have calculated if `m` is given)

- N - number of global columns (or `PETSC_DETERMINE` to have calculated if `n` is given)

- d_nz - number of nonzeros per row (same for all rows), for the “diagonal” portion of the matrix

- d_nnz - array containing the number of nonzeros in the various rows (possibly different for each row) or `NULL`, for the “diagonal” portion of the matrix

- o_nz - number of nonzeros per row (same for all rows), for the “off-diagonal” portion of the matrix

- o_nnz - array containing the number of nonzeros in the various rows (possibly different for each row) or `NULL`, for the “off-diagonal” portion of the matrix

## Output Parameter

- A - the matrix

## Notes

This matrix will ultimately pushed down to AMD GPUs and use the HIPSPARSE library for calculations. For good matrix assembly performance the user should preallocate the matrix storage by setting the parameter `nz` (or the array `nnz`).

It is recommended that one use the `MatCreate()`, `MatSetType()` and/or `MatSetFromOptions()`, MatXXXXSetPreallocation() paradigm instead of this routine directly. [MatXXXXSetPreallocation() is, for example, `MatSeqAIJSetPreallocation()`]

If `d_nnz` (`o_nnz`) is given then `d_nz` (`o_nz`) is ignored

The `MATAIJ` format (compressed row storage), is fully compatible with standard Fortran storage. That is, the stored row and column indices can begin at either one (as in Fortran) or zero.

Specify the preallocated storage with either `d_nz` (`o_nz`) or `d_nnz` (`o_nnz`) (not both). Set `d_nz` (`o_nz`) = `PETSC_DEFAULT` and `d_nnz` (`o_nnz`) = `NULL` for PETSc to control dynamic memory allocation.

## See Also

Matrices, `Mat`, `MatCreate()`, `MatCreateAIJ()`, `MatSetValues()`, `MatSeqAIJSetColumnIndices()`, `MatCreateSeqAIJWithArrays()`, `MATMPIAIJHIPSPARSE`, `MATAIJHIPSPARSE`

## Level

intermediate

## Location

src/mat/impls/aij/mpi/mpihipsparse/mpiaijhipsparse.hip.cxx

Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages