Improve Support for Arrays and Array-Like Expressions
Improve Type Inference for Array Literals
The Typifier
currently has only limited support for inferring the type of array initializer lists (PsArrayInitList
) when no type information about their entries is given. This is especially the case for declarations of arrays of numeric constants, e.g.
ps.Assignment(sp.Symbol("arr"), (1, 2, 3, 4))
should translate to C code as
double arr[] = { 1., 2., 3., 4. };
provided that float64
is the default_dtype
. Currently, the type of arr
cannot be inferred.
When array literals such as this occur inline within an expression, such as x + {1, 2, 3, 4}[idx]
, type inference is also unreliable.
Requirement: If the type of an array literal's entries, and therefore the array itself, cannot be inferred from its entries, it should be inferred from the enclosing context in the same way as for scalar constants.
Parsing of SymPy Matrices and Tensor-Like objects
Currently, pystencils only parses sp.Tuple
as an array literal.
The implementation of FreezeExpressions
should be extended such that
immutable SymPy
matrices
and tensor-like objects
(which qualify as expressions) are also parsed as array literals.
Documentation of Array-Parsing Capabilities
The new capabilities of pystencils to handle array-like objects have to be documented. Add a section about arrays to the symbolic language documentation.