|
Calling Sequence
|
|
convert( expr, list, expected_type, opts )
|
|
Parameters
|
|
expr
|
-
|
expression to convert
|
expected_type
|
-
|
(optional) `+`, `*`, or `^`
|
opts
|
-
|
(optional) option name or equation of the form option = value where option is one of dimension or nested.
|
|
|
|
|
Options
|
|
|
When expr is an rtable and dimension=d for some positive integer d, the rtable will be split upon dimension d. The dimension d must be less than or equal to n, the number of dimensions of expr. The result is a list of n-1-dimensional rtables if n>1, or a list of scalars if n=1.
|
|
The default is dimension=0, meaning the rtable will be fully converted to a list or nested list.
|
|
Note this option is only relevant if the input expr is an rtable (Matrix, Array, or Vector) and one cannot specify both a positive value for dimension and nested=true.
|
|
This option specifies whether to preserve the structure of rtables and arrays in the returned result using nested lists. The default is false.
|
|
|
Description
|
|
•
|
This command can be used to convert a variety of expressions into list form. The precise form of the result is determined by the input expr, the expected_type option, and any additional options opts.
|
•
|
The use of the expected_type option enables the convenient extraction of terms, factors or (base, exponent) pairs without worrying about the trivial cases. If expected_type is given and expr is not of type expected_type, expr is interpreted trivially to be of that type: a sum of one term, a product of one factor, or a power with exponent 1. The return value is [expr, 1] if expected_type=`^`, and [expr] otherwise.
|
Input type
|
dimension and nested options
|
Output form
|
rtable
|
dimension=0, nested=false
|
single-level (flattened) list
|
rtable
|
dimension=d for d>0, nested=false
|
list of rtables, or list of scalars if expr is one-dimensional
|
rtable
|
dimension=0, nested or nested=true
|
nested list with structure reflecting input (*)
|
array, matrix, vector
|
nested=false
|
single-level (flattened list)
|
array, matrix, vector
|
nested or nested=true
|
nested list with structure reflecting input
|
table with integer indices
|
|
list ordered by table index
|
other table
|
|
unordered list
|
string
|
|
list of characters (equivalent to StringTools[Explode])
|
MultiSet
|
|
[ op(Entries(expr)) ]
|
other
|
|
[ op(expr) ]
|
|
|
(*) If the rtable is 0-dimensional, the empty list is returned, rather than NULL.
•
|
Note that when converting an rtable to unnested list form, the order of elements in the output list will depend on the storage order of the rtable.
|
|
|
Examples
|
|
>
|
|
| (2) |
>
|
|
| (3) |
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
| (5) |
>
|
|
| (6) |
>
|
|
The default behavior is to extract operands:
>
|
|
| (8) |
By setting `+` as the expected_type, one can extract terms instead:
>
|
|
| (9) |
Now get the factors in each term:
>
|
|
| (10) |
And the bases and exponents:
>
|
|
| (11) |
|
|
Compatibility
|
|
•
|
The expected_type parameter was introduced in Maple 18.
|
|
|
|