Basic Concepts

This section provides an overview of the organization of the vector and matrix library and introduces some key concepts.

Organization of the library

There are three basic types of objects in the linear algebra library:


A vector is a one-dimensional array of values. Vectors are represented by the generic Vector<T> type. The element type of a vector can be anything. There is also a static type, Vector, that contains methods for constructing vectors and defines many operations on vectors.


A matrix is a two-dimensional array of values. The rows and columns of a matrix are vectors. Matrices are represented by the generic Matrix<T> type. The element type of a matrix can be anything. There is also a static type, Matrix, that contains methods for constructing matrices and defines many operations on matrices, and matrices and vectors.


A decomposition is a representation of a matrix in terms of other matrices of a specific form. Decompositions are used as intermediate values in many algorithms. Each type of decomposition has its own class, derived from Decomposition<T>.

Decomposition classes do not have constructors. Instead, they are created by calling a method on the matrix they are derived from.

Mutability and Intent

Two concepts are important when dealing with arrays. Mutability is the degree to which an array may be modified. There are four levels of mutability, enumerated by the ArrayMutability type:




All elements of the array are read-only.


The structure, size and shape of the array are fixed, but values are writable.


The size and shape of the array are fixed, but non-zero structure and values are writable.


All aspects of the array can be modified: values, structure and size.

Intent describes the way an array will be used, in particular when accessing parts of a larger parent array (like rows in a matrix). There are two dimensions to intent. First, will the elements only be read, or will they be modified? Second, should the array be a copy of the relevant part of the parent array, or should it be a live view into the parent array?

The possible values for intent are enumerated by the Intent type, and are listed below:




Return an array with the same mutability as the array from which it was derived. This is the default.


Return a read-only array that may be a live view or a copy. The result depends on the default mutability behavior and the type of array.


The array's values cannot be modified in any way.


Return an array that is a live view of the parent array's values that cannot be written to.


Return a writable copy of the array. Changing values will not affect the parent object's values. Actual copying may be delayed until the array is written to.


Return an array that is a live view of the parent array's values. Changing values also changes values in the parent array.

Complex vectors and matrices

As mentioned earlier, the elements of vectors and matrices can be of any type. This includes complex values. Complex arrays work just like their real counterparts.

There are a few instances where the behavior is slightly different. For example, functions like norms return real results for complex arrays. For complex arrays, these functions return complex values with the imaginary part zero.

Conversely, some or all of the eigenvalues of a real matrix may be complex. This is handled by having different types for the eigen-decomposition of real and complex matrices. In most situations, extension methods make it so a decomposition of the correct specific type will be returned. If this doesn't work, then methods exist on the decomposition object to return it in the desired form.