Generic Linear Algebra

Vectors and matrices are some of the most common objects used in numerical computing. Numerics.NET provide a full set of classes for generic real vectors and matrices. Any type that has an associated arithmetic can be used as the generic element type.

Specializing for specific element types

For any element type, the generic version of the linear algebra classes is inherently slower than the non-generic version because of additional overhead that is hard or impossible to optimize away. The less work is involved in actual operations, the more prominent the overhead will be.

Numerics.NET provides a general mechanism for providing specialized implementations. The same technique can be applied to other generic algorithms as well.

To create a specialized implementation of the linear algebra kernel, the following steps need to be taken:

  1. Implement one or more of the interfaces that define the low level API for linear algebra code for the element type.

  2. Create the specialization class by implementing the IRealOperations<T> interface.

  3. Create an assembly level attribute (TypeAssociationAttribute) that declares the type created in the previous step as the specialization for the element type. Use ArithmeticKey to identify the association.