codistributed.speye
Create codistributed sparse identity matrix
Syntax
CS = codistributed.speye(n)
CS = codistributed.speye(m,n)
CS
= codistributed.speye([m,n])
CS = speye(n,codist)
CS = speye(m,n,codist)
CS
= speye([m,n],codist)
CS = codistributed.speye(___,typename)
Description
CS = codistributed.speye(n)
creates an n
-by-n
sparse codistributed array of underlying class double.
CS = codistributed.speye(m,n)
or CS
= codistributed.speye([m,n])
creates an m
-by-n
sparse codistributed array of underlying class double.
Optional arguments to codistributed.speye
must be specified after the required arguments, and in the following order:
codist
— A codistributor object specifying the distribution scheme of the resulting array. If omitted, the array is distributed using the default distribution scheme. For information on constructing codistributor objects, see the reference pages forcodistributor1d
andcodistributor2dbc
.'noCommunication'
— Specifies that no interworker communication is to be performed when constructing the array, skipping some error checking steps.
CS = speye(n,codist)
is the same as CS = codistributed.speye(n,codist)
. You can also use the optional arguments with this syntax. To use the default distribution scheme, specify a codistributor constructor without arguments. For example:
spmd CS = codistributed.speye(8,codistributor1d); end
CS = speye(m,n,codist)
and CS
= speye([m,n],codist)
are the same as CS = codistributed.speye(m,n)
and CS = codistributed.speye([m,n])
, respectively. You can also use the optional arguments with this syntax.
CS = codistributed.speye(___,typename)
also specifies
the data type (class) for any of the previous syntaxes. The typename
input can be either "single"
or "double"
. (since R2025a)
Before R2025a: To create a sparse codistributed array of
underlying class logical, first create an array of underlying class double and then cast
it using the logical
function:
CLS = logical(speye(m,n,codistributor1d))
Examples
With four workers, create a 1000-by-1000 sparse codistributed double array
CS
, distributed by its second dimension (columns). Each worker
contains a 1000-by-250 local piece of CS
.
spmd(4) CS = speye(1000,codistributor) end
Create a 10-by-10 sparse codistributed double array CS
, distributed
by its columns. Each worker contains a 10-by-spmdIndex
local piece
of CS
.
spmd(4) codist = codistributor1d(2,1:spmdSize); CS = speye(10,10,codist); end
Create a 500-by-500 sparse codistributed single-precision array.
spmd(6) SD = codistributed.speye(500,500,"single"); end