coder.PrimitiveType class

Package: coder
Superclasses: coder.ArrayType

Represent set of logical, numeric, or char arrays

Description

Specifies the set of logical, numeric, or char values that the generated code should accept. Supported classes are half, double, single, int8, uint8, int16, uint16, int32, uint32, int64, uint64, char, and logical. Use only with the fiaccel -args option. Do not pass as an input to a generated MEX function.

Construction

Note

You can also create and edit coder.Type objects interactively by using the Coder Type Editor. See Create and Edit Input Types by Using the Coder Type Editor.

t=coder.typeof(v) creates a coder.PrimitiveType object denoting the smallest non-constant type that contains v. v must be a MATLAB® numeric, logical or char.

t=coder.typeof(v, sz, variable_dims) returns a modified copy of coder.typeof(v) with (upper bound) size specified by sz and variable dimensions variable_dims. If sz specifies inf for a dimension, then the size of the dimension is assumed to be unbounded and the dimension is assumed to be variable sized. When sz is [], the (upper bound) sizes of v remain unchanged. When variable_dims is not specified, the dimensions of the type are assumed to be fixed except for those that are unbounded. When variable_dims is a scalar, it is applied to bounded dimensions that are not 1 or 0 (which are assumed to be fixed).

t=coder.newtype(numeric_class, sz, variable_dims) creates a coder.PrimitiveType object representing values of class numeric_class with (upper bound) sizes sz and variable dimensions variable_dims. If sz specifies inf for a dimension, then the size of the dimension is assumed to be unbounded and the dimension is assumed to be variable sized. When variable_dims is not specified, the dimensions of the type are assumed to be fixed except for those that are unbounded. When variable_dims is a scalar, it is applied to the dimensions of the type that are not 1 or 0 (which are assumed to be fixed).

t=coder.newtype(numeric_class, sz, variable_dims, Name, Value) creates a coder.PrimitiveType object with additional options specified by one or more Name, Value pair arguments. Name can also be a property name and Value is the corresponding value. Specify Name as character vector or string scalar. You can specify several name-value pair arguments in any order as Name1,Value1,…,NameN,ValueN.

Input Arguments

v

Input that is not a coder.Type object

sz

Size for corresponding dimension of type object. Size must be a valid size vector.

Default: [1 1] for coder.newtype

variable_dims

Logical vector that specifies whether each dimension is variable size (true) or fixed size (false).

Default: false(size(sz)) | sz==Inf for coder.newtype

numeric_class

Class of type object.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

'complex'

Set complex to true to create a coder.PrimitiveType object that can represent complex values. The type must support complex data.

Character arrays do not support complex data.

Default: false

'sparse'

Set sparse to true to create a coder.PrimitiveType object representing sparse data. The type must support sparse data.

Character and half-precision data types do not support sparse data.

Default: false

'gpu'

Set gpu to true to create a coder.PrimitiveType object that can represent GPU input type. This option requires a valid GPU Coder™ license.

Character and half-precision data types do not support GPU Arrays.

Default: false

Properties

ClassName

Class of values in this set

Complex

Indicates whether the values in this set are real (false) or complex (true)

SizeVector

The upper-bound size of arrays in this set.

Sparse

Indicates whether the values in this set are sparse arrays (true)

VariableDims

A vector used to specify whether each dimension of the array is fixed or variable size. If a vector element is true, the corresponding dimension is variable size.

Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects.

Examples

Create a coder.PrimitiveType object.

z = coder.typeof(0,[2 3 4],[1 1 0]) % returns double :2x:3x4
% ':' indicates variable-size dimensions
Introduced in R2011a