Main Content

Create codistributed sparse matrix

converts
a full codistributed matrix to sparse form by removing any zero elements. You can save
memory by converting a matrix that contains many zeros to sparse storage.`S`

= sparse(`A`

)

creates
an `S`

= sparse(`m,n`

)`m`

-by-`n`

codistributed sparse matrix of all
zeros.

creates a codistributed sparse matrix `S`

= sparse(`i,j`

,`v`

)`S`

from the triplets
`i`

, `j`

, and `v`

. The number of rows
in `S`

is set by the maximum value of `i`

, and the
number of rows in `S`

is set by the maximum value of
`j`

. The matrix has space allotted for `length(v)`

nonzero elements.

Each of the inputs `i`

, `j`

, and
`v`

must have either `1`

or `N`

elements, such that each non-scalar input has the same number of elements.

returns a codistributed sparse matrix. For example,
`S`

= sparse(___,`codist`

)`sparse(codistributed(2),codistributed(3),codist)`

creates a
codistributed sparse 2-by-3 matrix using the codistributor object
`codist`

. You can use this syntax with any of the input arguments in
the previous syntaxes.

Specify the distribution of the array values across the memory of workers using the
codistributor object `codist`

. For more information about creating
codistributors, see `codistributor1d`

and `codistributor2dbc`

.

returns a codistributed sparse matrix without using communication between workers. You can
specify `S`

= sparse(___,`codist`

,"noCommunication")`codist`

or `codist,"noCommunication"`

, but
not both.

When you create very large arrays or your communicating job or `spmd`

block uses many workers, worker-worker communication can slow down array creation. Use this
syntax to improve the performance of your code by removing the time required for
worker-worker communication.

**Tip**

When you use this syntax, some error checking steps are skipped. Use this syntax
to improve the performance of your code after you prototype your code without
specifying `"noCommunication"`

.