Zip - Maple Help

LinearAlgebra

 Zip
 zip a 2-argument procedure onto a pair of Matrices or Vectors

 Calling Sequence Zip(f, A, B, ex, ip, options)

Parameters

 f - procedure or name; procedure to apply A - Matrix or Vector B - Matrix or Vector ex - (optional) any type; value used for unassigned entry locations when A and B are not the same size ip - (optional) equation of the form inplace=true or false; specifies if output overwrites input options - (optional); constructor options for the result object

Description

 • The Zip(f, A, B) function applies the bivariate function f to the paired entries of the Matrices (or Vectors) A and B.
 Parameters A and B must be either both Matrices or both Vectors. If they are Vectors, their orientations do not have to match; the orientation of the result will be the same as that of A.
 • If A and B are not the same size, then the size of the result is determined by the presence or absence of the optional ex 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 A and B.
 Therefore, if A and B are Vectors, the result object is a Vector whose dimension is $\mathrm{min}\left(\mathrm{dim}\left(A\right),\mathrm{dim}\left(B\right)\right)$. If A and B are Matrices, the result object is a Matrix whose dimensions are $\mathrm{min}\left(\mathrm{rowdim}\left(A\right),\mathrm{rowdim}\left(B\right)\right)X\mathrm{min}\left(\mathrm{coldim}\left(A\right),\mathrm{coldim}\left(B\right)\right)$.
 If ex is provided in the calling sequence, then the result object's dimensions are determined by taking the maximum of the corresponding dimensions of A and B. In this case, if A or B does not contain a value for a particular entry location in the result, the value ex is substituted for the missing value(s).
 • The inplace option (ip) determines where the result is returned. If given as inplace=true, the result overwrites the first argument. If given as inplace=false, or if this option is not included in the calling sequence, the result is returned in a new Matrix (or Vector).
 The condition inplace=true can be abbreviated to inplace.
 The inplace option must be used with caution since, if the operation fails, the original Matrix (or Vector) argument may be corrupted.
 The inplace option is valid only if the result object's dimensions are exactly those of A.
 • The constructor options provide additional information (readonly, shape, storage, order, datatype, and attributes) to the Matrix or Vector constructor that builds the result. These options may also be provided in the form outputoptions=[...], where [...] represents a Maple list.  If a constructor option is provided in both the calling sequence directly and in an outputoptions option, the latter takes precedence (regardless of the order).
 • The inplace and constructor options are mutually exclusive.
 • This function is part of the LinearAlgebra package, and so it can be used in the form Zip(..) only after executing the command with(LinearAlgebra). However, it can always be accessed through the long form of the command by using LinearAlgebra[Zip](..).

Examples

 > $\mathrm{with}\left(\mathrm{LinearAlgebra}\right):$
 > $\mathrm{Zip}\left(\mathrm{+},⟨1,2⟩,⟨3,4⟩\right)$
 $\left[\begin{array}{c}{4}\\ {6}\end{array}\right]$ (1)
 > $A≔⟨⟨1,2,3⟩|⟨4,5,6⟩⟩$
 ${A}{≔}\left[\begin{array}{cc}{1}& {4}\\ {2}& {5}\\ {3}& {6}\end{array}\right]$ (2)
 > $B≔⟨⟨1,2⟩|⟨3,4⟩|⟨5,6⟩⟩$
 ${B}{≔}\left[\begin{array}{ccc}{1}& {3}& {5}\\ {2}& {4}& {6}\end{array}\right]$ (3)
 > $\mathrm{Zip}\left(\mathrm{+},A,B\right)$
 $\left[\begin{array}{cc}{2}& {7}\\ {4}& {9}\end{array}\right]$ (4)
 > $\mathrm{Zip}\left(\mathrm{+},A,B,\mathrm{\pi }\right)$
 $\left[\begin{array}{ccc}{2}& {7}& {\mathrm{\pi }}{+}{5}\\ {4}& {9}& {\mathrm{\pi }}{+}{6}\\ {3}{+}{\mathrm{\pi }}& {\mathrm{\pi }}{+}{6}& {2}{}{\mathrm{\pi }}\end{array}\right]$ (5)

The next example uses Zip to perform elementwise (pointwise) multiplication. This is also known as the "Hadamard product" or "Schur product".

 > $\mathrm{Zip}\left(\mathrm{*},A,B\right)$
 $\left[\begin{array}{cc}{1}& {12}\\ {4}& {20}\end{array}\right]$ (6)