ArrayReshape¶
An array with the same elements in a different shape.
声明¶
语法¶
ArrayReshape(expr array, expr shape, expr? pad, expr? order,
ttype type, expr? value, expr? result)
参数¶
Argument |
描述 |
|---|---|
|
the array whose elements are taken. |
|
a rank one integer array giving the new extents. |
|
values used to fill the result when |
|
the permutation of the dimensions to fill in; |
|
the array type of the result. |
|
the compile time value of the expression, when the frontend could fold it; |
|
optional allocatable descriptor temporary supplying independent scratch storage for a runtime numeric or logical result without |
返回值¶
The value of the expression.
描述¶
reshape(a, shape). The elements are taken in array element order, so the
result holds the same values in the same sequence with different extents.
The temporary pass can supply result, with explicit allocation before
evaluation and deallocation before reuse. Scope cleanup releases its last
allocation. The backend fills this storage without allocating another data
buffer; it does not transfer ownership to the assignment target. This keeps
repeated evaluation bounded while preserving independent assigned values.
示例¶
(ArrayReshape
:array (Var
:v (SymbolRef 1 "a")
)
:shape (Var
:v (SymbolRef 1 "shape")
)
:pad nil
:order nil
:type (Array
:type (Integer
:kind 4
)
:dims [
(dimension
:start (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:length (IntegerConstant
:n 2
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
)
(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
)
:value nil
:result 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 6
: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_asynchronous false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
:common_block nil
)
"b" (Variable
:parent_symtab 1
:name "b"
: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 2
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
)
(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_asynchronous false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
:common_block nil
)
"shape" (Variable
:parent_symtab 1
:name "shape"
: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 2
: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_asynchronous false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
:common_block nil
)
}
)
:name "main"
:dependencies []
:body [
(Assignment
:target (Var
:v (SymbolRef 1 "b")
)
:value (ArrayReshape
:array (Var
:v (SymbolRef 1 "a")
)
:shape (Var
:v (SymbolRef 1 "shape")
)
:pad nil
:order nil
:type (Array
:type (Integer
:kind 4
)
:dims [
(dimension
:start (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:length (IntegerConstant
:n 2
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
)
(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
)
:value nil
:result nil
)
:overloaded nil
:realloc_lhs false
:move_allocation false
:new_target false
:new_allocation false
)
]
:global_init nil
)
}
)
:items []
:global_init nil
)