Algebraic Operations |
Hereinafter the following convention is used:
– small Greek letters are used to denote scalars;
– small Latin letters are used to denote vectors;
– capital Latin letters are used to denote matrices.
This topic contains the following sections:
This section describes methods implementing unary operations, i.e. operations performed with one vector.
Operation | Description | Performance |
---|---|---|
plus | Creates a copy of the original vector In place:Returning result:Out of place: | |
minus | Negates this vector. If the vector is , then the result of this operation will be In place:Returning result:Out of place: |
Addition operation allows adding a vector or a scalar to the given vector.
Operation | Description | Performance |
---|---|---|
vector-scalar addition | Calculates the sum of a scalar and a vector (or a vector and a scalar – as you know the addition is commutative operation). This operation is defined as: given: then: In place:Returning result:Out of place: | |
vector-vector addition | Adds the given vector to this vector. This operation is defined as: given: then: In place:Returning result:Out of place: |
Subtraction allows calculating the difference between a vector and a scalar or between two vectors.
Operation | Description | Performance |
---|---|---|
vector-scalar subtraction | The difference of a vector and a scalar: In place:Returning result:Out of place:The difference of a scalar and a vector: In place:Returning result:Out of place: | |
vector-vector subtraction | The difference of the given vector and another vector: then: In place:Returning result:Out of place:The opposite operation: In place:Returning result:Out of place: |
Multiplication of a vector and a scalar.
Operation | Description | Performance |
---|---|---|
vector-scalar multiplication | Multiplies this vector by the given scalar: In place:Returning result:Out of place: |
Division of a vector by a scalar.
Operation | Description | Performance |
---|---|---|
vector-scalar division | Divides this vector by the given scalar: In place:Returning result:Out of place: |
The described algebraic operations methods can be replaced by mathematical signs of this operations: +, -, *, / like in the example below:
1Vector u = new Vector(4); 2Vector v = new Vector(4); 3 4//vector sum 5Vector sum = u + v; 6//vector-scalar sum 7 8double a = 2; 9sum = u + a + v;