-- Download About GMac as PDF --

* GMac*, short for “

*“, is a .NET based software system that allows implementing geometric models and algorithms based on Geometric Algebra (GA) in arbitrary target programming languages.*

**G**eometric**Mac**roThe core part of * GMac* is the

*, a transcompiler or source-to-source translator that accepts code written in a simple high-level domain-specific language (*

**GMacCompiler***), and can be configured using*

**GMacDSL***to output very efficient low-level code in any desired target programming language. The ultimate goal behind creating*

**GMacAPI***is to allow Geometric Computing (GC) implementations to be as flexible, organized, and efficient as possible. Although*

**GMac***is originally created using C#, it can be configured to generate a set of textual code files in any desired structure using an API that is accessible through any .NET language including C++, C#, VB.NET, F#, and IronPython among others.*

**GMac**The main ideas behind * GMac *date back to my 2010 Ph.D. dissertation that can be found at https://arxiv.org/abs/1607.04767.

*is intended to be a sophisticated software system for implementing Geometric Algebra algorithms in an efficient manner to narrow the gap between practical software engineering and GA-based geometric modeling in order to enable GA to gain wider acceptance among software designers, as well as researchers. I strongly believe Geometric Algebra rightly deserves to become the main mathematical language for teaching and representing geometric models in computer science and engineering in the very near future.*

**GMac**### GMac Users

* GMac* is a “geometric computing design aid” that can be efficiently and creatively used to implement important aspects of a wide spectrum of geometric computing applications. If we take a look at the

*system diagram we can see 4 types of users; they are actually 4 roles that an actual user may have two or more of them at once:*

**GMac****Geometric Computing System User**: The end-goal of any geometric computing system is to provide computational services to its users. But the kinds of interfaces, computations, and data exchange in a GC system are geometric in essence. Examples of GC systems include computational geometry, computer graphics, CAD\CAM, robotics, computer vision, engineering and many others. Each system is unique in its specific requirements and possible users but they all enjoy a common base of geometric ideas deserving a unified development methodology; just like data-driven and object-oriented software design and tools serve many diverse areas of computing.

**Geometric Computing System Designer**: To satisfy the geometric computing requirements of the users, the GC system designer must have a set of methods and tools to ease the design and development of his GC system. * GMac* is one such tool that uses well-established software engineering techniques (a DSL-based optimizing compiler with a configurable text generator) based on the fascinating and universal mathematical language of Geometric Algebra to translate many abstract geometric ideas into optimized code that is both efficient to execute and flexible to shape into the final GC system design.

**Geometric Algebra Model Designer**: The GA model designer is a person having a geometric idea and wishing to investigate, interact, and eventually implement it. The use of Geometric Algebra as a universal model for geometry goes most of the way into these goals. What remains is translating GA equations and algebraic processes into a working prototype using * GMac*‘s simple and effective GA-based domain-specific language

*. The resulting intermediate*

**GMacDSL***can be then used to provide interactive scripting for the GA model designer\user and structured code generation for the GC system designer.*

**GMacAST****Geometric Algebra Model User**: Often a GA model is general enough that it can be used to interactively investigate many geometric ideas at once. For example, the whole of the very powerful Cinderella interactive geometry system is based on a single GA model; the 2D conformal geometry model on complex scalars. After designing the GA model any number of users can use it as a prototype for studying geometric ideas expressible by that model.

### GMac Components

The various * GMac* system components will never be complete, they are under continuous development to mature into an incrementally useful system. Some features will be added in time, but the basic architecture described here will remain unchanged:

**GMacCompiler**: This is the core of GMac, a source-to-source compiler that can generate an Abstract Syntax Tree (* GMacAST*) from a GA-based Domain-Specific Language (

*) code. The*

**GMacDSL***is an optimizing transcompiler; it can perform high-level domain-specific optimizations backed up by a powerful Computer Algebra System (CAS), like Mathematica or Python’s SymPy for example, to generate the desired code. The*

**GMacCompiler***has two sub-components:*

**GMacCompiler****The GMacCompiler Front End**: The main role of the front end is to translatecode into a**GMacDSL**structure. The front end follows the traditional lexer>parser>semantic analyzer sequence of compiler front ends. It interacts with the**GMacAST**, the user interface of**GMacIDE**, by accepting**GMac**code and reporting any errors in the code through the**GMacDSL**interface. It also occasionally requests symbolic computations from the CAS to complete the translation process successfully.**GMacIDE****The GMacCompiler Back End**: The back end is responsible for generating text code from thestructure translated from**GMacAST**code. The generation process is highly configurable through an Application Programming Interface (**GMacDSL**). Using**GMacAPI**we can reshape with full control the information abstractly encoded in the**GMacAPI**structure into text files having any desired folder, file, and text structure. We can select a target language to convert**GMacAST**macros into executable code in a given target language. The**GMacDSL**infrastructure can be extended easily to add more target languages as desired.**GMacAPI**

**GMacDSL**: The use of GA for expressing geometric ideas is very effective. * GMacDSL* is designed to be a good and simple expressive language for general GA operations on multivectors in any arbitrary GA model of geometry.

*is not Turing-Complete; it has no looping or conditional branching constructs. These constructs are left for the main GC system application code and the*

**GMacDSL***scripting engine.*

**GMac***primarily focuses on representing geometric objects in two main ways:*

**GMacDSL**- Direct representation using multivectors of some GA frame.
- Non-recursive combinatorial structures of multivectors and scalars.

* GMacDSL* also focuses on implementing GA operations on these two types of representations using Geometric Macros: solid parametric blocks containing a sequence of simple commands that assign GA computational expressions to local and output variables of the block. The

*front end translates*

**GMacCompiler***code into*

**GMacDSL***structures that can be used for interactive scripting through*

**GMacAST***, or for configurable code generation through the*

**GMacIDE***back end and*

**GMacCompiler***.*

**GMacAPI****GMacAST**: When a GA model encoded in * GMacDSL* has compiled into an Abstract Syntax Tree it is ready for many interesting uses through scripting and code generation. The

*is a set of simple .NET classes that are written in C# but accessible through any .NET language to hold the minimum necessary abstract information for code generation and scripting interaction processes. The*

**GMacAST***is accessible through*

**GMacAST***and*

**GMacIDE***. Learning the full structure of*

**GMacAPI***as provided by the*

**GMacAST***Guide is necessary for effective use of the*

**GMacAST***system.*

**GMac****GMac Scripting**: After we have a * GMacAST* we can easily interact with it computationally through the

*scripting engine to test the GA model we encoded with*

**GMac***. Scripting can provide many insights into the GA model prototype we created. Scripting also provides more computational power to GA models implemented in the non-Turing-Complete*

**GMacDSL***like looping, conditional branching, and others.*

**GMacDSL****GMacAPI**: The * GMacCompiler* back end can be configured using

*to generate efficient text code in any desired language.*

**GMacAPI***is a set of .NET classes created with C# but usable by any .NET language (C++, C#, VB.NET, F#, IronPython, etc.) to specify how to use the information and geometric macros encoded in the*

**GMacAPI***structure to generate files with desired structure in terms of folders, files, and text.*

**GMacAST***has a set of classes specifically designed for easy controllable template-based or free text generation from arbitrary sources.*

**GMacAPI***can also specify binding patterns to associate target language variables or constant values with parts of input parameters to the geometric macros. The net result is a flexible, powerful, and efficient means for implementing configurable low-level code generation from*

**GMacAPI***GA-based high-level code.*

**GMacDSL****GMacIDE**: This is the main user interface of * GMac* where we can write

*code, interact with the*

**GMacDSL***, and use the*

**GMacCompiler***scripting engine. The main interaction services*

**GMac***can provide are:*

**GMacIDE**- Write
source code with the help of a project management and code highlighting capable interface.**GMacDSL** - Compile
code into a**GMacDSL**structure and report any errors in the code.**GMacAST** - Explore the details of the compiled
in various ways.**GMacAST** - Explore a single high-level geometric macro to see how it translates into low-level code with some statistics on the intermediate optimizations performed.
- Interact with the compiled
computationally through the**GMacAST**scripting engine.**GMac** - Provide an extendable interface for generating a set of useful code libraries using a given
structure.**GMacAST**

**GMac Guides**: GMac can be used to create structured code based on GA models of geometric concepts. In order to fully understand and effectively use the GMac system, we need to study the * GMac Guides* carefully. Here we will provide several user guides to the GMac components including:

- GMac System Guide: Describes the GMac system, installation, and user interface with examples.
- GMac Math Guide: Describes the custom OOP interface library for communicating with the Mathematica symbolic computing system for performing symbolic operations on GA multivectors. The library is originally designed for GMac, but usable for any other similar system.
- GMacDSL Guide: Describes the syntax of the
language providing examples for its use.**GMacDSL** - GMacAST Guide: Describes the construction of the
data structure that is the main intermediate information source for code generation and scripting in GMac.**GMacAST** - TextComposerLib Guide: Describes a custom text composition library made specifically for GMac but very useful by itself for general text composition applications.
- GMacAPI Guide: The most important, and longest, of all
. This guide describes the processes, classes, and implementation examples for generating structured code from**GMac Guides**code for any target language.**GMacDSL** - GMac Scripting Guide: Describes the scripting capabilities of GMac that enable GA-based model creators to explore their creations.

In addition to * GMac* guides, we will provide many practical examples of using GMac for real geometric computing problems as tutorials and illustrations of the

*system operation. These examples will be provided on the blog of this website in addition to the GMac Samples page that will contain full source code and updated as new samples are created.*

**GMac**