8.7 Vector operations

The following simple vector operations are possible:

- Copying or appending a vector to another vector. For instance
`S=R`copies a vector`R`to a vector`S`.`S(3)=R`copies`R`to`S(3), S(4), ...`.`S(#S+1)=R`appends vector`R`to vector`S`. It is also possible to access a range of subsequent elements in a vector:`S=R(2:4)`copies elements 2 to 4 of`R`to`S(1), S(2), S(3)`. Note that`R(2:)`denotes elements`R(2)`to`R(#R)`, but`R(2)`denotes a single element of`R`. - Vector-scalar operations:
`R=R*2`multiplies each element of`R`by 2. Instead of the number 2, also scalar (one dimensional) variables or expressions can be used, e.g.,`R=R*ANG`converts all elements of`R`from Ångstrøm to bohr, or`Z=R*COS(THETA)`creates a vector`Z`with elements`Z(i) = R(i)*COS(THETA)`. All other algebraic operators can be used instead of “*”. Note that the scalar must come last since the first variable in the expression determines the vector length. - Vector-vector operations: If
`A`and`B`are vectors of the same length, then`A B`is also a vector of this length. Here stands for any algebraic operator, and the operation is done for each pair of corresponding elements. For instance,`A + B`adds the vectors`A`and`B`, and`A * B`multiplies their elements. Note that the latter case is not a scalar product. If an attempt is made to connect two vectors of different lengths by an algebraic operator, an error occurs. - Intrinsic functions: Assume
`THETA=[100,110,120,-130]`to be a vector of angles (in degrees). In this case`X=2*COS(THETA)`is also a vector containing the cosines of each element of`THETA`multiplied by two, i.e.,`X(i) = 2*COS(THETA(i))`.`MAX(THETA)`or`MIN(THETA)`return the maximum and minimum values, respectively, in array`THETA`. Vector operations can also be nested, e.g.,`MAX(ABS(THETA))`returns the maximum value in array`ABS(THETA)`.

At present, vector operations are not supported with `string` variables.

molpro@molpro.net 2019-01-21