Click or drag to resize

Algebraic Operations

Hereinafter the following convention is used:

  • VSmall Greek – small Greek letters are used to denote scalars;

  • VSmall Latin – small Latin letters are used to denote vectors;

  • VCapital Latin – capital Latin letters are used to denote matrices.

This topic contains the following sections:

Unary operations
Addition

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:

VVector

then:

VAddition Scalar

In place:

methodAddInPlace(Double)

Returning result:

methodAdd(Double)

Out of place:

methodAdd(Double, Vector)

vector-vector addition

Adds the given vector to this vector. This operation is defined as:

given:

VTwo Vector

then:

VTwo Vector Sum

In place:

methodAddInPlace(Vector)

Returning result:

methodAdd(Vector)

Out of place:

methodAdd(Vector, Vector)

Subtraction

Subtraction allows calculating the difference between a vector and a scalar or between two vectors.

Multiplication

Multiplication of a vector and a scalar.

Operation

Description

Performance

vector-scalar multiplication

Multiplies this vector by the given scalar:

VMultiplication

In place:

methodMultiplyInPlace(Double)

Returning result:

methodMultiply(Double)

Out of place:

methodMultiply(Double, Vector)

Division

Division of a vector by a scalar.

Operation

Description

Performance

vector-scalar division

Divides this vector by the given scalar:

VDivision

In place:

methodDivideInPlace(Double)

Returning result:

methodDivide(Double)

Out of place:

methodDivide(Double, Vector)

Overloaded operators

The described algebraic operations methods can be replaced by mathematical signs of this operations: +, -, *, / like in the example below:

C#
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;

See Also