true - Create codistributed array of logical 1 (true) - MATLAB (original) (raw)

Create codistributed array of logical 1 (true)

Syntax

Description

`cT` = true([n](#mw%5Fe7eee995-3547-4d2a-90f9-225b90024f14),[codist](#mw%5F073f1806-0af3-492a-8a80-a2714e7ae2ab)) creates an n-by-n codistributed matrix of logical ones and uses codist to specify the distribution of the array values across the workers.

Specify codist as "codistributed" to use the default codistributor1d distribution scheme or the distribution scheme defined by a codistributor1d or codistributor2dbc object.

When you create the codistributed array in a communicating job or spmd block, the function creates an array on each worker. If you create a codistributed array outside of a communicating job or spmd block, the array is stored only on the worker or client that creates the codistributed array.

By default, the codistributed array has the underlying type double.

example

`cT` = true([sz](#mw%5F8f86dad2-cb42-4fd2-bcaa-151c862b6da7),[codist](#mw%5F073f1806-0af3-492a-8a80-a2714e7ae2ab)) creates a codistributed array of logical ones where the size vectorsz defines the size of cT. For example,true([2 3],"codistributed") creates a 2-by-3 codistributed array.

`cT` = true([sz1,...,szN](#mw%5F905f629c-aa78-4478-97bd-cc89e217e0ef),[codist](#mw%5F073f1806-0af3-492a-8a80-a2714e7ae2ab)) creates an sz1-by-...-by-szN codistributed array of logical ones where sz1,...,szN indicates the size of each dimension.

`cT` = true(___,"noCommunication") creates a codistributed array of logical ones without using communication between workers. You can use this syntax with any of the input arguments in the previous syntaxes.

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".

`cT` = true(___,like=[p](#mw%5Fc1a63bf8-5fa6-4f49-ae93-9e4b4d38d4a2)) uses the array p to return a codistributed array of logical ones. You can also specify "noCommunication" as part of the function call.

The returned array cT has the same sparsity asp.

Examples

collapse all

Create a 1000-by-1000 codistributed matrix oftrues, distributed by its second dimension (columns).

spmd(4) C = true(1000,"codistributed"); end

With four workers, each worker contains a 1000-by-250 local piece ofC.

Create a 1000-by-1000 codistributed matrix of trues, distributed by its columns.

spmd(4) codist = codistributor1d(2,100*[1:spmdSize]); C = true(1000,1000,codist); end

Each worker contains a 100-by-spmdIndex local piece ofC.

Input Arguments

collapse all

Size of the square matrix, specified as an integer.

Distribution scheme for codistributed array, specified as one of these options:

Size of each dimension, specified as an integer row vector. Each element of this vector indicates the size of the corresponding dimension:

Example: sz = [2 3 4] creates a 2-by-3-by-4 codistributed array.

Size of each dimension, specified as separate arguments of integer values.

Prototype of array to create, specified as a codistributed array.

If you do not specify the datatype, the resulting codistributed array has the same underlying type, sparsity, and complexity (real or complex) asp.

Tips

Version History

Introduced in R2006b