Linear algebra is the study of linear functions over vector spaces.
Every finite n-dimensional vector space over the reals is isomorphic to . Thus to solve problems in all such spaces, one only needs to develop computational tools to handle problems in . For brevity, let us abbreviate a finite m-dimensional vector space over the real numbers simply as an m-vector space. For general n-vector spaces, the problem is first mapped to (by choosing a suitable basis), solved there, and then mapped back to the original domain.
Of special interest are linear functions between an n-vector space and an m-vector space . A linear function is simply a function from to which preserves linear combinations of vectors. Choosing a basis in can be used to fix an isomorphism between vectors of and vectors of . Similarly between and . However, having fixed both isomorphisms, we have come to fix an isomorphism between linear functions from to and matrices.
Matrix algebra is linear algebra in (in our case). Because of the isomorphism results, it is a machinery sufficiently powerful to answer questions in finite-dimensional linear algebra.
One can generalize the described structure to several directions. Notably:
One can allow general fields for underlying scalars.
One can make the condition of preserving linear combinations weaker. This allows for more general underlying spaces such as the affine space (see affine transformation class), and the projective space.
One can allow subspaces of more than 1 dimensions to be used as primitive. This gives Grassmann algebra and even more importantly geometric algebra. The multivectors of geometric algebra are represented by components if the underlying vector space is of dimension .
One can consider linear functions between linear functions. This gives tensor algebra. Computationally, tensors are represented by -dimensional arrays of values compared to the 2-dimensional representation of matrices.
Pastel implements a matrix algebra component where matrices assume elements from an ordered field. Most importantly, this abstraction includes real numbers (modeled with floating point numbers), and rational numbers (modeled as a ratio of two integers, allowing exact arithmetic). For geometric problems and computer graphics, this covers most of the needs.
We do not generalize to arbitrary fields because that is rarely needed in computer graphics and geometric applications.
In contrast, affine and projective spaces are very important. Pastel recognizes affine spaces by supplying the user with a class that encapsulates affine transformations. Points in projective n-space can be embedded into a vector space with dimension n + 1 (the corresponding coordinates are commonly known as homogeneous coordinates) and be handled with conventional linear algebra followed by a projection. Because affine n-space can be embedded into the projective n-space, affine space can also be handled this way. However, affine transformations are most naturally performed in the native space, as demonstrated by the affine transformation class.
Tensors are rarely needed in our applications, so we do not implement matrices as a special case of tensors.
However, support for geometric algebra is something we consider adding to Pastel in the future. The advantage of geometric algebra is that it is very intuitive for geometric problems and can express more analytical solutions that linear algebra (for example, ‘give the intersection of two 2-dimensional planes in ’). Particularly interesting would be the geometric algebras of and .
Vector Calculus, Linear Algebra, and Differential Forms: A Unified Approach, 2nd. ed., John H. Hubbard, Barbara Burke Hubbard, 2002.
Geometric Algebra for Computer Science, Leo Dorst, Daniel Fontijne, Stephen Mann, 2007.
Applied Numerical Linear Algebra, James W. Demmel, 1997.
Matrix Computations, 3rd. edition, Gene H. Golub, Charles F. Van Loan, 1996.