SkillAgentSearch skills...

GeometricAlgebraFulcrumLib

A Unified Generic C# library for Geometric Algebra computations using any kind of scalars (floating point, symbolic, etc.)

Install / Use

/learn @ga-explorer/GeometricAlgebraFulcrumLib

README

= Geometric Algebra Fulcrum Library (GA-FuL) Ahmad H. Eid ga.computing.eg@gmail.com :imagesdir: assets/images :sectnums: :stem: latexmath :toc: :toclevels: 4

== About GA-FuL

Geometric Algebra Fulcrum Library (GA-FuL for short) is a unified generic C# library for Geometric Algebra computations using any kind of scalars (floating point, rational, symbolic, etc.). GA-FuL can be used for prototyping geometric algorithms based on the powerful mathematics of geometric algebra. The GA-FuL code base can be used to perform numeric computations, symbolic manipulations, and optimized code generation.

=== Why The Name Geometric Algebra Fulcrum?

Geometric Algebra (GA) is a powerful mathematical language that unifies many algebraic tools under the same framework of mathematical operations. Such tools include, for example, real vectors, complex numbers, quaternions, octonions, spinors, matrices, among others; along with their algebraic operations. The most important feature of GA is, however, that it unifies the geometric reasoning process among many seemingly diverse fields of application domains. Thus, Geometric Algebra acts as a Mathematical Fulcrum for geometric reasoning across scientific and engineering domains. We can use this Geometric Algebra Fulcrum to seamlessly balance the abstract ideal needs of geometric reasoning with the concrete tools of algebraic manipulation under a unifying mathematical framework.

On the other side, there is a need for software tools that act as a pivot point, i.e. a Fulcrum, for prototyping and implementing several kinds of computations on GA's multivectors. Commonly required computations include numerical, symbolic, and code generation, among others. Writing and maintaining a separate code base for each kind is highly impractical. GA-FuL is intended to play the role of a Computational Fulcrum for prototyping algorithms and implementing software based on Geometric Algebra.

=== Citation

You can cite GA-FuL using https://www.mdpi.com/2227-7390/12/14/2272[this article]: [source,]

@Article{Eid2024, author = {Eid, Ahmad Hosny and Montoya, Francisco G.}, journal = {Mathematics}, title = {Developing GA-FuL: A Generic Wide-Purpose Library for Computing with Geometric Algebra}, year = {2024}, issn = {2227-7390}, month = jul, number = {14}, pages = {2272}, volume = {12}, doi = {10.3390/math12142272}, publisher = {MDPI AG}, }

== GA-FuL Design

=== [[cdi]]Core Design Intentions

The high-level design of GA-FuL targets a specific set of Core Design Intentions (CDIs). The set of CDIs is a direct result of the experience gained during the development of the predecessor system, https://github.com/ga-explorer/GMac[GMac]. An overview of the CDIs is as follows:

  • [[cdi-1]]CDI-1: Abstracting multivector operations from concrete scalar representations. In practical computational applications, there are diversely useful representations for the mathematical concept of scalars, as classically introduced in https://www.taylorfrancis.com/books/mono/10.1201/9781315136554/abstract-algebra-applications-karlheinz-spindler[abstract algebra]. The most common representation for numerical applications is for real scalars using the https://dl.acm.org/doi/10.1145/103162.103163[IEEE 754 floating-point number format]. For modern https://databookuw.com/[data-driven and machine learning applications], https://www.sciencedirect.com/book/9780128039533/theory-and-computation-of-tensors[multi-dimensional arrays and tensors] are the basic representations for scalar data. Another very useful representation for scalars, used in most Computer Algebra Systems (CAS), is an https://link.springer.com/book/10.1007/978-3-642-55826-9[expression tree] which represents a symbolic scalar expression for mathematical manipulation applications. The foundational requirement for GA-FuL design is to provide a unified generic implementation for storing and manipulating multivectors and performing common GA operations on any kind of useful scalar representation.

  • [[cdi-2]]CDI-2: Reducing memory requirements for sparse multivectors. One major obstacle in the way of using GA for practical computations is the memory storage requirements imposed by the structure of multivectors. Storing a full multivector in a stem:[n]-dimensional GA requires stem:[2^{n}] scalars, while storing a full stem:[k]-vector requires stem:[\binom{n}{k}] scalars. For the simplest of numerical scalar representations, 32-bit floating point numbers, a single multivector in a 30-dimensional GA requires 8 GBytes of memory, while a full 15-vector one requires nearly 1.16 GBytes of memory; assuming the use of memory arrays to store the scalars. For most practical GA applications, however, there is rarely a need for storing full multivectors or full stem:[k]-vectors, and only sparse multivectors are sufficient. One feature of GA is to enable the creation of linear models of nonlinear geometric objects by embedding the original space into a higher-dimension GA space. This typically results in multivectors representing geometric objects using a significantly reduced number of scalars, not a full-sized multivector or stem:[k]-vector. For example, a sparse multivector in https://link.springer.com/chapter/10.1007/11499251_24[5-dimensional conformal GA], containing only 5 out of 32 scalars, can represent points, planes, and spheres of 3-dimensional Euclidean space. As such, another important requirement for the GA-FuL design is to provide a set of generic, memory-efficient data structures for storing the scalars of sparse multivectors in high-dimensional GAs.

  • [[cdi-3]]CDI-3: Providing metaprogramming capabilities. https://www.worldscientific.com/doi/abs/10.1142/S0218194018300014[Generative programming] in general and https://link.springer.com/book/10.1007/978-1-4471-4126-6[metaprogramming] in particular incorporate the process of creating software systems that treat programs as data, enabling the transformation of existing programs or for the generation of new ones. This was the target of the predecessor system https://github.com/ga-explorer/GMac[GMac] for generating https://arxiv.org/abs/1607.04767[optimized computational numerical code] from a https://www.tandfonline.com/doi/full/10.1080/02726343.2020.1811937[series of GA expressions]. This design goal is carried on to GA-FuL, which would enable code generation targeting high-performance platforms such as CUDA, in addition to classical general purpose programming languages such as C\C++, C#, Java, JavaScript, Python, MATLAB scripts, etc.

  • [[cdi-4]]CDI-4: Introducing a layered system design for a wide spectrum of uses. The complexity imposed by the previous CDIs must be organized and managed through a layered design of the system. Each layer should specialize in one aspect of the system such as storage management, processing, algebraic and geometric abstractions, etc. In addition, a system of such capabilities would have a wide range of users and use cases. Typically, a user would use the system to create a numerical\symbolic prototype for some geometric modeling ideas, and then after some experimentation, would use metaprogramming system capabilities to generate optimized code for the final model targeting a specific programming language or environment. The design of GA-FuL attempts to realize this layered approach to allow users of different backgrounds to select the suitable level of coding they can handle. The coding level ranges from the very high level of coordinate-independent prototyping using abstract GA operations up to a fully controlled low-level direct manipulation of scalars and coordinates for high-performance computing purposes.

  • [[cdi-5]]CDI-5: Providing a unified, generic, and extensible API for several classes of applications. The final design goal of GA-FuL is to expose the system functionality through a good Application Programming Interface (API). The API should have a unified public interface with uniform conventions to aid usability. Additionally, the API should be generic regarding the kinds of scalars and GAs it can handle, reflecting the capabilities of the underlying system. API extensibility is also important for future development of the system to aid in the addition of more features and widening system usage. Finally, the API should support the development of various classes of applications including, but not limited to, numerical prototyping computations, symbolic mathematical manipulations, signal processing, visualization, and metaprogramming.

=== [[dop]]Data-Oriented Programming in GA-FuL

During the initial design of GA-FuL, satisfying the set of <<cdi,CDIs>> using traditional Object-Oriented Programming (OOP) was found to be non-practical. This is mainly due to the tendency of classical OOP practices to increase the code-base complexity of large systems such as GA-FuL. In this context, complexity specifically means the deep coupling of data and behavior code typically imposed by classical OOP principles, especially encapsulation and inheritance. This typically results in complicated relations between system classes and complex inheritance hierarchies, leading to difficulties in understanding the design of large systems. If not properly mitigated, this can eventually result in reduced code understanding and difficulty in system maintenance and extensibility.

The solution found to be most useful was to use a newly emerging software design paradigm that while being compatible with OOP, also tends to produce a more readable, maintainable, and extensible code-base. The use of https://www.manning.com/books/data-oriented-programming[Data-Oriented Programming (DOP)] principles, as the highest-level design paradigm, proved to be highly beneficial to many aspects of GA-FuL system design. The https://blog.klipse.tech/dop/2022/06/22/principles-of-dop.html[four core principles of DOP] ar

View on GitHub
GitHub Stars22
CategoryDevelopment
Updated10d ago
Forks6

Languages

C#

Security Score

95/100

Audited on Mar 29, 2026

No findings