Zip - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


LinearAlgebra

  

Zip

  

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

 

Calling Sequence

Parameters

Description

Examples

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

Examples

withLinearAlgebra:

Zip`+`,1,2,3,4

46

(1)

A1,2,3|4,5,6

A142536

(2)

B1,2|3,4|5,6

B135246

(3)

Zip`+`,A,B

2749

(4)

Zip`+`,A,B,π

27π+549π+63+ππ+62π

(5)

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

Zip`*`,A,B

112420

(6)

See Also

Matrix

operators/elementwise

Vector