zip
zip together two lists, matrices, or vectors
|
Calling Sequence
|
|
zip(f, u, v)
zip(f, u, v, d)
zip[dense]( f, u, v, d )
zip[sparse]( f, u, v, d )
zip[inplace]( f, u, v, d )
zip[evalhf]( f, u, v, d )
|
|
Parameters
|
|
f
|
-
|
binary function
|
u, v
|
-
|
lists, rtables, Arrays, Matrices, Vectors, or scalars
|
d
|
-
|
(optional) value
|
|
|
|
|
Description
|
|
•
|
The function zip applies the binary function f to the components of two data sets u and v, creating a new data set defined as follows. If m is the length of u and n is the length of v then is a data set of length with for i in .
|
•
|
If u and v are Matrices of the same size, then zip applies the binary function f to the pairs of corresponding entries of the matrices u and v. The -entry of the resulting matrix is .
|
•
|
If u and v are not both rtables, Arrays, or lists (ie. both are scalars) then is returned. If only u is a scalar then is computed. If only v is a scalar then is returned. In other words, zipping a matrix against a scalar is the same as zipping against a same-size matrix filled with that scalar at each entry.
|
•
|
If the optional fourth argument d is given, it is used as a default value for f when one of the data sets is shorter than the other. Thus is a data set of length with for i in and for in where is the longer of u and v.
|
•
|
If u and v are Matrices of the same size, then the optional fourth argument is accepted, but ignored. Similarly, if either u or v are not matrices then the fourth argument is also ignored.
|
•
|
If u and v are not Matrices of the same size, then the size of the result is determined by the presence or absence of the optional fourth parameter. If this parameter is omitted in the calling sequence then the result object's dimensions are determined by taking the minimum of the corresponding dimensions of u and v.
|
•
|
The sparse and dense options control how zip is applied to zero data in sparse storage Arrays, Vectors, and Matrices. The zip[sparse] command will apply f for each matched element in the array provided they are not both zero. This scans the actual stored entries (zeros are not stored in sparse arrays). The zip[dense] command will apply f for every matched element in the result index space, as if both input arrays were dense. By default sparse Array inputs, where f(0,0) is nonzero will have the zip[dense] algorithm applied. Sparse Matrix and Vector inputs will have the zip[sparse] algorithm applied by default. The zip[sparse] algorithm is used by default when zipping a sparse matrix against a scalar.
|
•
|
The inplace option only applies when u and v are both rtables of the same size, storage, and data type. When this option is used, u will be modified in-place.
|
•
|
The evalhf option only applies when u and v are both rtables of data type float[8] or complex[8]. When this option is used, evaluation of f will be done using the evalhf subsystem.
|
|
|
Examples
|
|
>
|
|
>
|
|
>
|
|
| (3) |
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
| (13) |
>
|
|
>
|
|
>
|
|
>
|
|
To use the list constructor as the function to apply, enter back quotes around [].
>
|
|
| (18) |
|
|
Compatibility
|
|
•
|
The zip command was updated in Maple 2021.
|
•
|
The inplace and evalhf options were introduced in Maple 2021.
|
|
|
|
|
|
|