# API:IVectorMutable

From Wiketomica

API Home | Participants | API | Discussion | Demos | Downloads | Documentation | Contact Us | Acknowledgements |

# IVector

## Reason for existence

Vectors are used throughout off-lattice simulation programs for quantities such as positions, velocities and gradients. Simulation components should be able to pass around vector quantities to one another.

superclass: IVector

## Proposed Interface

interface IVectorMutable : IVector { /** * Sets the i-th component of the vector to the given value d. If index * exceeds dimension of vector, no error is given and the last element of * the vector is assigned. */ void setX(in int i, in double d); /** * Sets the components of this vector equal to those of the given vector. */ void E(in IVector u); /** * Sets all components of this vector equal to the given value. */ void E(in double a); /** * Sets the components of this vector equal to the corresponding elements of * the given array. Inverse of the assignTo method. */ void E(in double[] a); /** * Plus-equals (+=) operation. Increments each component of this vector by * the corresponding value in the given vector. */ void PE(in IVector u); /** * Plus-equals (+=) operation, causing a constant value to be added to all * components of this vector. */ void PE(in double a); /** * Minus-equals (-=) operation. Decrements each component of this vector by * the corresponding value in the given vector. */ void ME(in IVector u); /** * Times-equals (*=) operation. Multiplies each component of this vector by * the corresponding value in the given vector. */ void TE(in IVector u); /** * Divide-equals (/=) operation. Divides each component of this vector by * the corresponding value in the given vector. */ void DE(in IVector u); /** * Multiplies all components by a constant. */ void TE(in double a); /** * Operation (= a1 * v1); sets the components of this to those of the given * vector multiplied by the given constant. */ void Ea1Tv1(in double a, in IVector v1); /** * Increments (+=) components by (a1 * v1) */ void PEa1Tv1(in double a, in IVector v1); /** * Sets the components of this vector equal to (v1 + v2) */ void Ev1Pv2(in IVector v1, in IVector v2); /** * Sets the components of this vector equal to (v1 - v2) */ void Ev1Mv2(in IVector v1, in IVector v2); /** * Replaces each component of this vector with its value modulo * the corresponding component in u */ void mod(in IVector u); /** * Normalizes this vector, so this.squared() == 1. Divides all * components by Math.sqrt(this.squared()). */ void normalize(); /** * Applies the given function to each element of the vector. */ void map(in IFunction f); /** * Sets this vector equal to the cross product of this vector with the * given vector (only works for 3D vectors). */ void XE(IVector u); }

## Use

We expect that the IAtom subinterfaces that correspond to atoms with positions or velocities would include a `getPosition`

method to return the vector position of an atom as a double array. The position of the atom could be changed by directly manipulating the elements of the array.

To change the size of the simulation box, the dimensions of the IBoundary could be set by passing a double array to a `setDimensions`

method.