-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classThe data structure for describing array shapes, including dimensions, extent for each dimension and slice size for each sub-array with lower dimension.static classthe data structure for describing array slices. -
Method Summary
Modifier and TypeMethodDescriptiondev.civl.sarl.IF.expr.BooleanExpressionTest if two array shapes s0 and s1 are physically equivalent.dev.civl.sarl.IF.expr.SymbolicExpressionarrayFlatten(dev.civl.sarl.IF.expr.SymbolicExpression array) 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 targethape) Reshape an arrayato the given target shapet.dev.civl.sarl.IF.expr.SymbolicExpressionarraySliceRead(dev.civl.sarl.IF.expr.SymbolicExpression array, dev.civl.sarl.IF.expr.NumericExpression[] indices, int count) Same asarraySliceRead(SymbolicExpression, NumericExpression[], NumericExpression)but the "count" is known as having a concrete value.dev.civl.sarl.IF.expr.SymbolicExpressionarraySliceRead(dev.civl.sarl.IF.expr.SymbolicExpression array, dev.civl.sarl.IF.expr.NumericExpression[] indices, dev.civl.sarl.IF.expr.NumericExpression count) Returns a symbolic expression representing an array slice which is an one-dimensional array of elements of typetthat is carved out from the given arraya, wheretis associated to to the given indices:{i0, i1, ...dev.civl.sarl.IF.expr.SymbolicExpressionarraySliceWrite(ArrayToolBox.ArraySlice slice, dev.civl.sarl.IF.expr.SymbolicExpression targetArray, ArrayToolBox.ArrayShape targetShape, dev.civl.sarl.IF.expr.NumericExpression[] targetStartIndices) dev.civl.sarl.IF.expr.SymbolicExpressionextractArraySlice(ArrayToolBox.ArraySlice arraySlice) Returns aSymbolicExpressionrepresenting the givenArrayToolBox.ArraySlice.booleanisArrayTypeallComplete(dev.civl.sarl.IF.type.SymbolicArrayType arrayType) dev.civl.sarl.IF.expr.SymbolicExpressionmdArrayRead(dev.civl.sarl.IF.expr.SymbolicExpression array, dev.civl.sarl.IF.expr.NumericExpression[] indices) Read a multi-dimensional arraydev.civl.sarl.IF.expr.SymbolicExpressionmdArrayWrite(dev.civl.sarl.IF.expr.SymbolicExpression array, dev.civl.sarl.IF.expr.NumericExpression[] indices, dev.civl.sarl.IF.expr.SymbolicExpression value) Write a value to a multi-dimensional arraynewArrayShape(dev.civl.sarl.IF.type.SymbolicArrayType arrayType) create anArrayToolBox.ArrayShape, the base type will be (default) non-array typenewArrayShape(dev.civl.sarl.IF.type.SymbolicArrayType arrayType, dev.civl.sarl.IF.type.SymbolicType baseType) create anArrayToolBox.ArrayShapewith a specified base type.newArraySlice(dev.civl.sarl.IF.expr.SymbolicExpression array, dev.civl.sarl.IF.expr.NumericExpression[] startIndices, dev.civl.sarl.IF.expr.NumericExpression count, dev.civl.sarl.IF.type.SymbolicType baseType) create anArrayToolBox.ArraySlice.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.subArrayShape(ArrayToolBox.ArrayShape arrayShape, int subArrayDimensions) switchBaseType(ArrayToolBox.ArrayShape arrayShape, int baseTypeDimensions) Given an array shapes, returns an new array shapes'.
-
Method Details
-
arrayFlatten
dev.civl.sarl.IF.expr.SymbolicExpression arrayFlatten(dev.civl.sarl.IF.expr.SymbolicExpression array) 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 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 targethape) 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.targetShape- 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.
-
newArrayShape
create anArrayToolBox.ArrayShape, the base type will be (default) non-array type- Parameters:
arrayType-- Returns:
- The
ArrayToolBox.ArrayShapeof the given array type, or null is the array type is NOTinvalid reference
#allComplete(SymbolicArrayType)
-
newArrayShape
ArrayToolBox.ArrayShape newArrayShape(dev.civl.sarl.IF.type.SymbolicArrayType arrayType, dev.civl.sarl.IF.type.SymbolicType baseType) create anArrayToolBox.ArrayShapewith a specified base type. The behavior is undefined if the given base type is not a sub-type of the given array type.- Parameters:
arrayType-baseType-- Returns:
- The
ArrayToolBox.ArrayShapeof the given array type, or null is the array type is NOTinvalid reference
#allComplete(SymbolicArrayType)
-
newArraySlice
ArrayToolBox.ArraySlice newArraySlice(dev.civl.sarl.IF.expr.SymbolicExpression array, dev.civl.sarl.IF.expr.NumericExpression[] startIndices, dev.civl.sarl.IF.expr.NumericExpression count, dev.civl.sarl.IF.type.SymbolicType baseType) create anArrayToolBox.ArraySlice.- Parameters:
array- the array where the slice is carved outstartIndices- the starting indices for carving out the slice from the arraycount- the number of base type elements in the slice, notice that the base type is decided bystartIndices.lengthbaseType- the base type of this slice. The slice type is an array of "count" baseType elements.- Returns:
- an
ArrayToolBox.ArraySlice
-
extractArraySlice
Returns aSymbolicExpressionrepresenting the givenArrayToolBox.ArraySlice. The type of the symbolic expression will be theArrayToolBox.ArraySlice.sliceTypeofarraySlice. -
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
-
areArrayShapesPhysicallyEquivalent
dev.civl.sarl.IF.expr.BooleanExpression areArrayShapesPhysicallyEquivalent(ArrayToolBox.ArrayShape s0, ArrayToolBox.ArrayShape s1) Test if two array shapes s0 and s1 are physically equivalent. s0 and s1 are physically equivalent if and only if there exists an element type e_t such that array of s0 has N elements of e_t and array of s1 has M elements of e_t and N = M.- Parameters:
s0-s1-- Returns:
- True iff the two array shapes are physically equivalent.
-
isArrayTypeallComplete
boolean isArrayTypeallComplete(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.
-
arraySliceRead
dev.civl.sarl.IF.expr.SymbolicExpression arraySliceRead(dev.civl.sarl.IF.expr.SymbolicExpression array, dev.civl.sarl.IF.expr.NumericExpression[] indices, dev.civl.sarl.IF.expr.NumericExpression count) Returns a symbolic expression representing an array slice which is an one-dimensional array of elements of type
tthat is carved out from the given arraya, wheretis associated to to the given indices:{i0, i1, ... in-1}.
t = typeof(a[i0][...][in-1]- Parameters:
array- an arrayindices- the indices of the element in the given array which is the first element in the returned array. (inclusive)count- the number of elements in the returned array- Returns:
- a symbolic expression representing the array slice
-
arraySliceRead
dev.civl.sarl.IF.expr.SymbolicExpression arraySliceRead(dev.civl.sarl.IF.expr.SymbolicExpression array, dev.civl.sarl.IF.expr.NumericExpression[] indices, int count) Same asarraySliceRead(SymbolicExpression, NumericExpression[], NumericExpression)but the "count" is known as having a concrete value. -
arraySliceWrite
dev.civl.sarl.IF.expr.SymbolicExpression arraySliceWrite(ArrayToolBox.ArraySlice slice, dev.civl.sarl.IF.expr.SymbolicExpression targetArray, ArrayToolBox.ArrayShape targetShape, dev.civl.sarl.IF.expr.NumericExpression[] targetStartIndices) Write an
ArrayToolBox.ArraySlices into thetargetArray, starting from the giventargetStartIndices- Parameters:
slice- the array slicetargetArray- the target array where the slice will be written intargetShape- theArrayToolBox.ArrayShapeof the target array.targetShapeandsliceShapemust have the same base typetargetStartIndices- the start indices of the written slice in the target array. (inclusive).targetStartIndices.length == targetShape.dimensions- Returns:
- the updated target array which has been written the slice
-
mdArrayRead
dev.civl.sarl.IF.expr.SymbolicExpression mdArrayRead(dev.civl.sarl.IF.expr.SymbolicExpression array, dev.civl.sarl.IF.expr.NumericExpression[] indices) Read a multi-dimensional array- Parameters:
array- a multi-dimensional arrayindices- indices for reading- Returns:
- The element indexed by the given indices
-
mdArrayWrite
dev.civl.sarl.IF.expr.SymbolicExpression mdArrayWrite(dev.civl.sarl.IF.expr.SymbolicExpression array, dev.civl.sarl.IF.expr.NumericExpression[] indices, dev.civl.sarl.IF.expr.SymbolicExpression value) Write a value to a multi-dimensional array- Parameters:
array- a multi-dimensional arrayindices- indices for reading- Returns:
- new array after writing
-
subArrayShape
- Parameters:
arrayShape- the array shape of an arraysubArrayDimensions- the dimension of the sub-array, it must be greater than 0 and LESS THAN OR EQUAL TO the dimensions of the given array shape.- Returns:
- The
ArrayToolBox.ArrayShapeof the sub array, which is a "subArrayDimensions"-dimensional array of "arrayShape".baseType
-
switchBaseType
Given an array shapes, returns an new array shapes'.sands'represent exact the same array shape but the base type ofs'may have an array type of the base type ofs.- Parameters:
arrayShape- theArrayToolBox.ArrayShapeof an arraybaseTypeDimensions- the dimensions of the new base type. The new base type is a 'baseTypeDimensions'-dimensional array of the old base type. 'baseTypeDimensions' must be GREATER THAN OR EQUAL TO 0 and LESS THAN the dimensions of the given array shape.- Returns:
- a new
ArrayToolBox.ArrayShapewhich represents the same shape as the given one but has different base type.
-