主要内容

真的

创建逻辑1(true)的编码阵列

    Description

    example

    X= true(n)creates ann-by-n逻辑矩阵的编码矩阵。

    When you create the codistributed array in a communicating job orspmd块,该函数在每个工人上创建一个数组。如果您在交流作业或spmdblock, the array is stored only on the worker or client that creates the codistributed array.

    By default, the codistributed array has the underlying typedouble

    X= true(SZ1,...,SZN)creates ansz1-by-...-by-szNcodistributed array of logical ones whereSZ1,...,SZNindicates the size of each dimension.

    X= true(sz)creates a codistributed array of logical ones where the size vectorszdefines the size ofX。For example,真的(codistributed([2 3]))creates a 2-by-3 codistributed array.

    X= true(___,codist)使用Codistributor对象codistto create a codistributed array of logical ones. 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 objectcodist。有关创建codistibutor的更多信息,请参阅Codistributor1dCodistributor2DBC

    X= true(___,codist,"noCommunication")creates a codistributed array of logical ones without using communication between workers. You can specifycodist或者编码师,“ Nocommunication”, but not both.

    When you create very large arrays or your communicating job orspmdblock 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

    当您使用此语法时,会跳过一些错误检查步骤。原型未指定后,请使用此语法来改善代码的性能“ nocommunication”

    X= true(___,"like",p)uses the arrayp返回一个逻辑上的编码阵列。您可以指定datatype或者"like", but not both.

    The returned arrayXhas the same sparsity asp

    Examples

    collapse all

    Create a 1000-by-1000 codistributed matrix of真的s, distributed by its second dimension (columns).

    spmd(4) C = true(1000,“编码”);end

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

    Create a 1000-by-1000 codistributed matrix of真的s, distributed by its columns.

    spmd(4)代码师= Codistributor('1d',2,100*[1:numlabs]);c = true(1000,1000,编码师);end

    Each worker contains a 100-by-labindexlocal piece ofC

    Input Arguments

    collapse all

    Size of the square matrix, specified as acodistributed整数。

    • Ifnis0, thenXis an empty matrix.

    • Ifnis negative, then the function treats it as0

    Size of each dimension, specified as separate arguments ofcodistributed整数values.

    • If the size of any dimension is0, thenXis an empty array.

    • If the size of any dimension is negative, then the function treats it as0

    • Beyond the second dimension, the function ignores trailing dimensions with a size of1

    Size of each dimension, specified as acodistributed整数row vector. Each element of this vector indicates the size of the corresponding dimension:

    • If the size of any dimension is0, thenXis an empty array.

    • If the size of any dimension is negative, then the function treats it as0

    • Beyond the second dimension,真的忽略了trailing dimensions with a size of1。For example,true(codistribed([3 1 1 1]))produces a 3-by-1 codistributed vector of logical ones.

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

    Codistributor,指定为Codistributor1d或者Codistributor2DBCobject. For information on creating codistributors, see the reference pages forCodistributor1dCodistributor2DBC。要使用默认的分发方案,您可以在没有参数的情况下指定Codistributor构造函数。

    Prototype of array to create, specified as acodistributed大批。

    提示

    • 真的(codistributed(n))is much faster and more memory efficient than逻辑(一个(codistribed(n)))

    Version History

    Introduced in R2006b