# 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:

#### Vectors

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.

#### Matrices

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.

#### Decompositions

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:

Value | Description |
---|---|

Immutable | All elements of the array are read-only. |

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

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

MutableSize | 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:

Value | Description |
---|---|

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

ReadOnly | 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. |

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

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

WritableCopy | 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. |

WritableView | 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.