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

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : Mathematics : Linear Algebra : LinearAlgebra Package : Standard : LinearAlgebra/Zip

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

Calling Sequence

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




procedure or name; procedure to apply



Matrix or Vector



Matrix or Vector



(optional) any type; value used for unassigned entry locations when A and B are not the same size



(optional) BooleanOpt(inplace); specifies if output overwrites input



(optional); constructor options for the result object



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 mindimA,dimB. If A and B are Matrices, the result object is a Matrix whose dimensions are minrowdimA,rowdimBXmincoldimA,coldimB.


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](..).


















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




See Also

Matrix, operators/elementwise, type[BooleanOpt], Vector

Download Help Document

Was this information helpful?

Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam