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

This section describes methods implementing unary operations, i.e. operations performed with one matrix.

Addition

Addition operation allows adding a matrix or a scalar to the given matrix.

Operation

Description

Performance

matrix-scalar addition

Calculates the sum of a scalar and a matrix (or a matrix and a scalar – as you know the addition is commutative operation). This operation is defined as:

given:

MMatrix

then:

MAddition Scalar

In place:

methodAddInPlace(Double)

Returning result:

methodAdd(Double)

Out of place:

methodAdd(Double, Matrix)

matrix-matrix addition

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

given:

MTwo Matrices

then:

MTwo Matrices Sum

In place:

methodAddInPlace(Matrix)

Returning result:

methodAdd(Matrix)

Out of place:

methodAdd(Matrix, Matrix)

Subtraction

Subtraction allows calculating the difference between a matrix and a scalar or between two matrices.

Multiplication

Multiplication of a matrix by a scalar, a vector or a matrix.

Operation

Description

Performance

matrix-scalar multiplication

Multiplies this matrix by the given scalar:

MMultiplication Scalar

In place:

methodMultiplyInPlace(Double)

Returning result:

methodMultiply(Double)

Out of place:

methodMultiply(Double, Matrix)

matrix-vector multiplication

Multiplies this matrix by the column vector from the right.

Consider the given vector is:

MVector Col

The result will be:

MMultiplication Vector 1

MMultiplication Vector 2

Returning result:

methodMultiply(Vector)

Out of place:

methodMultiply(Vector, Vector)

Multiplies this matrix by the row vector from the left.

Consider the given vector is:

MVector Row

MMultiplication Vector Left 1

MMultiplication Vector Left 2

Returning result:

methodLeftMultiply(Vector)

Out of place:

methodLeftMultiply(Vector, Vector)

matrix-matrix multiplication

Multiplies this matrix by the given matrix from the right.

Consider the given matrix is:

MMatrix Right

The result will be:

MMultiplication Matrix 1

MMultiplication Matrix 2

Returning result:

methodMultiply(Matrix)

Out of place:

methodMultiply(Matrix, Matrix)

Multiplies this matrix by the given matrix from the left.

Consider the given matrix is:

MMatrix Left

The result will be:

MMultiplication Matrix Left 1

MMultiplication Matrix Left 2

Returning result:

methodLeftMultiply(Matrix)

Out of place:

methodLeftMultiply(Matrix, Matrix)

Division

Division of a matrix by a scalar.

Operation

Description

Performance

matrix-scalar division

Divides each element of the matrix by the given scalar:

MDivision

In place:

methodDivideInPlace(Double)

Returning result:

methodDivide(Double)

Out of place:

methodDivide(Double, Matrix)

Overloaded operators

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

C#
1Matrix A = new Matrix(4);
2Matrix B = new Matrix(4);
3
4// Sum of matrices.
5Matrix C = A + B;
6
7// Sum of a matrix and a scalar.
8Matrix D = A + 2.0;

See Also