zip together two lists, matrices, or vectors
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 )
lists, rtables, Arrays, Matrices, Vectors, or scalars
The function zip applies the binary function f to the components of two data sets u and v, creating a new data set r defined as follows. If m is the length of u and n is the length of v then r is a data set of length min⁡m,n with ri=f⁡ui,vi for i in 1..min⁡m,n.
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 i,j-entry of the resulting matrix is f⁡ui,j,vi,j.
If u and v are not both rtables, Arrays, or lists (ie. both are scalars) then f⁡u,v is returned. If only u is a scalar then map2⁡f,u,v is computed. If only v is a scalar then map⁡f,u,v 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 r is a data set of length max⁡m,n with ri=f⁡ui,vi for i in 1..min⁡m,n and ri=f⁡ti,d for i in 1+min⁡m,n..max⁡m,n where t 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 or complex. When this option is used, evaluation of f will be done using the evalhf subsystem.
a ≔ Matrix⁡2,3,1,2,3,4,5,6:
b ≔ Matrix⁡2,3,1,3,5,7,9,2:
a ≔ Matrix⁡3,4,2,3,5,7,11,13,17,19,23,29,31,37:
b ≔ Matrix⁡2,2,shape=antisymmetric
b1,2 ≔ 3
c ≔ Array⁡1,0,0,1:
d ≔ Matrix⁡2,2,3,0,2,5:
f ≔ Vector⁡3,5
g ≔ Vectorrow⁡1,2
To use the list constructor as the function to apply, enter back quotes around .
The zip command was updated in Maple 2021.
The inplace and evalhf options were introduced in Maple 2021.
For more information on Maple 2021 changes, see Updates in Maple 2021.
Download Help Document