This class provides methods for reshaping arrays. In C language, an array of
objects is physically a sequence of objects in memory but can be accessed in
various ways. For example, an array T a[10] can be access as a
one dimensional array of T with length 10, as a two dimensional array
T a[2][5], a two dimensional array T a[5][2], etc.
In CIVL, arrays are represented in a logical way, e.g. a two dimensional array is a one dimensional array of arrays. But such difference will not prevent us from providing array reshaping.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanallComplete(dev.civl.sarl.IF.type.SymbolicArrayType arrayType) dev.civl.sarl.IF.expr.SymbolicExpressionarrayFlatten(dev.civl.sarl.IF.expr.SymbolicExpression array, ArrayToolBox.ArrayShape shape) Reshape a multiple dimensional array of type t to a one dimensional array of type t.dev.civl.sarl.IF.expr.NumericExpression[]arrayIndiceProjecting(dev.civl.sarl.IF.expr.NumericExpression[] fromArrayIndices, ArrayToolBox.ArrayShape fromArrayShape, ArrayToolBox.ArrayShape toArrayShape) Projecting indicesIof an arraya0to another arraya1, i.e.dev.civl.sarl.IF.expr.SymbolicExpressionarrayReshape(dev.civl.sarl.IF.expr.SymbolicExpression array, ArrayToolBox.ArrayShape originShape, ArrayToolBox.ArrayShape targetShape) Reshape an arrayato the given target shapet.dev.civl.sarl.IF.expr.NumericExpression[]sliceIndiceProjecting(dev.civl.sarl.IF.expr.NumericExpression[] fromSliceArrayIndices, ArrayToolBox.ArrayShape fromSliceArrayShape, dev.civl.sarl.IF.expr.NumericExpression[] fromSliceStartIndices, ArrayToolBox.ArrayShape toSliceArrayShape, dev.civl.sarl.IF.expr.NumericExpression[] toSliceStartIndices) Projecting the indices of an array slices0to another array slices1.
-
Method Details
-
arrayFlatten
dev.civl.sarl.IF.expr.SymbolicExpression arrayFlatten(dev.civl.sarl.IF.expr.SymbolicExpression array, ArrayToolBox.ArrayShape shape) Reshape a multiple dimensional array of type t to a one dimensional array of type t. Notice that the type t is the base type of the givenArrayToolBox.ArrayShape. (i.e.ArrayToolBox.ArrayShape.baseType).- Parameters:
array- a multiple dimensional arrayshape- theArrayToolBox.ArrayShapeof the given array- Returns:
- a one dimensional array which is equivalent (physically in C language) to the given array.
-
arrayReshape
dev.civl.sarl.IF.expr.SymbolicExpression arrayReshape(dev.civl.sarl.IF.expr.SymbolicExpression array, ArrayToolBox.ArrayShape originShape, ArrayToolBox.ArrayShape targetShape) Reshape an arrayato the given target shapet. The target shapetmust be physically equivalent to the shape of arraya.- Parameters:
array- the array that will be reshaped.originShape- theArrayToolBox.ArrayShapeof the given arraytargetShape- theArrayToolBox.ArrayShapethat the given array will be reshaped to- Returns:
- an array of the given target shape that is physically equivalent to the given array.
-
allComplete
boolean allComplete(dev.civl.sarl.IF.type.SymbolicArrayType arrayType) - Parameters:
arrayType-- Returns:
- true iff the given type is an array type and is complete at every dimension.
-
sliceIndiceProjecting
dev.civl.sarl.IF.expr.NumericExpression[] sliceIndiceProjecting(dev.civl.sarl.IF.expr.NumericExpression[] fromSliceArrayIndices, ArrayToolBox.ArrayShape fromSliceArrayShape, dev.civl.sarl.IF.expr.NumericExpression[] fromSliceStartIndices, ArrayToolBox.ArrayShape toSliceArrayShape, dev.civl.sarl.IF.expr.NumericExpression[] toSliceStartIndices) Projecting the indices of an array slice
s0to another array slices1. Requires thats0ands1have exact same base type.Example, there is an array slice
s0in an arrayT a[10][10], from indices{2,3}, of length 10. Then the indices of such slice areI : {{2, 3}, {2, 4}, ..., {2, 9}, {3, 0}, ..., {3, 2}}.And, there is another array slice
s1in an arrayT b[100], from index{x}, of length 20.Now projects indices
{i, j}, which belongs toIto indices ofs1, the result should be:k : i * 10 + j - (2 * 10 + 3) + x
This projecting is mainly used for such case : the value of n-th element ofs0, which is referred by{i, j}, is the value of n-th element ofs1, which is referred byk.Notice that the caller of this method is responsible to guarantee that the given indices belong to
s0and the projected indices (returned indices) belong tos1.- Parameters:
fromSliceArrayIndices- The indices over the array of slices0, that belongs tos0. They refer to the n-th element ins0fromSliceArrayShape- the shape of the array of slices0fromSliceStartIndices- the starting indices of slices0toSliceArrayShape- the shape of the array of projected slices1toSliceStartIndices- the starting indices of projected slices1- Returns:
- the indices of the n-th element in
s1
-
arrayIndiceProjecting
dev.civl.sarl.IF.expr.NumericExpression[] arrayIndiceProjecting(dev.civl.sarl.IF.expr.NumericExpression[] fromArrayIndices, ArrayToolBox.ArrayShape fromArrayShape, ArrayToolBox.ArrayShape toArrayShape) Projecting indices
Iof an arraya0to another arraya1, i.e. the value of the n-th element, referred by I, ina0is same as the value of the n-th element ina1.Notice that caller of this method is responsible to guarantee that the given indices I belongs to
a0(is valid indices ofa0) and the resulting indices belongs toa1- Parameters:
fromArrayIndices- the indices of arraya0, refers to the n-th element ofa0fromArrayShape- the shape of the arraya0toArrayShape- the shape of the arraya1- Returns:
- indices referring to the n-th element of
a1
-