ArrayPack¶
The elements of an array selected by a mask.
Declaration¶
Syntax¶
ArrayPack(expr array, expr mask, expr? vector, ttype type, expr? value)
Arguments¶
Argument |
Description |
|---|---|
|
the array to select from. |
|
a logical array of the same shape, or a scalar. |
|
values to pad the result with when it must be longer than the number of selected elements; |
|
the rank one array type of the result. |
|
the compile time value of the expression, when the frontend could fold it; |
Return values¶
The value of the expression.
Description¶
pack(a, mask). The result is always rank one, whatever the rank of the
input, and its length is the number of true elements of the mask unless
vector makes it longer.
Examples¶
(ArrayPack
:array (Var
:v (SymbolRef 1 "a")
)
:mask (Var
:v (SymbolRef 1 "mask")
)
:vector nil
:type (Array
:type (Integer
:kind 4
)
:dims [
(dimension
:start nil
:length nil
)
]
:physical_type :DescriptorArray
:memory_space :Global
)
:value nil
)
It comes from this complete ASR text document:
(TranslationUnit
:symtab (SymbolTable
:id 0
:symbols {
"main" (Program
:symtab (SymbolTable
:id 1
:symbols {
"a" (Variable
:parent_symtab 1
:name "a"
:dependencies []
:intent :Local
:symbolic_value nil
:value nil
:storage :Default
:type (Array
:type (Integer
:kind 4
)
:dims [
(dimension
:start (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:length (IntegerConstant
:n 3
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
)
]
:physical_type :FixedSizeArray
:memory_space :Global
)
:type_declaration nil
:abi :Source
:access :Public
:presence :Required
:value_attr false
:target_attr false
:contiguous_attr false
:bindc_name nil
:is_volatile false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
)
"b" (Variable
:parent_symtab 1
:name "b"
:dependencies []
:intent :Local
:symbolic_value nil
:value nil
:storage :Default
:type (Allocatable
:type (Array
:type (Integer
:kind 4
)
:dims [
(dimension
:start nil
:length nil
)
]
:physical_type :DescriptorArray
:memory_space :Global
)
)
:type_declaration nil
:abi :Source
:access :Public
:presence :Required
:value_attr false
:target_attr false
:contiguous_attr false
:bindc_name nil
:is_volatile false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
)
"mask" (Variable
:parent_symtab 1
:name "mask"
:dependencies []
:intent :Local
:symbolic_value nil
:value nil
:storage :Default
:type (Array
:type (Logical
:kind 4
)
:dims [
(dimension
:start (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:length (IntegerConstant
:n 3
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
)
]
:physical_type :FixedSizeArray
:memory_space :Global
)
:type_declaration nil
:abi :Source
:access :Public
:presence :Required
:value_attr false
:target_attr false
:contiguous_attr false
:bindc_name nil
:is_volatile false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
)
}
)
:name "main"
:dependencies []
:body [
(Assignment
:target (Var
:v (SymbolRef 1 "b")
)
:value (ArrayPack
:array (Var
:v (SymbolRef 1 "a")
)
:mask (Var
:v (SymbolRef 1 "mask")
)
:vector nil
:type (Array
:type (Integer
:kind 4
)
:dims [
(dimension
:start nil
:length nil
)
]
:physical_type :DescriptorArray
:memory_space :Global
)
:value nil
)
:overloaded nil
:realloc_lhs false
:move_allocation false
)
]
)
}
)
:items []
)