# About GMac

*On this page you can:*

- Learn about the purpose of GMac and its possible uses.
- Read the main features of GMac for coding with Geometric Algebra, scripting, and prototyping.
- Understand the requirements of using GMac and where to download it from.
- Find a short description of GMac’s various components and links to the GMac User Guides.

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

#### Coding with Geometric Algebra:

- A simple yet powerful computational Domain Specific Language,
, that exposes the power of Geometric Algebra to geometric computing software applications.**GMacDSL** - Using
, the user can define any number of fixed interrelated frames up to 15 dimensions of any signature.**GMac** - Through
, the user can define combinatorial nested structures containing multivectors and scalar values to hold basic geometric computing blocks of data.**GMacDSL** provides a rich set of multivector operators to construct sophisticated computational symbolic expressions.**GMacDSL**gives the user the ability to define Geometric Macros, a simple form of parameterized geometric computing procedures based on Geometric Algebra multivector expressions. Geometric macros can call each other to provide simple encapsulation and code reuse capabilities.**GMacDSL**- The
user code is automatically parsed to an Abstract Syntax Tree; stored in the**GMacDSL**component classes. The**GMacAST**structure is specifically designed to be effective when used for later scripting and code generation tasks by including comprehensive information about the semantics and relations of the code elements defined in the**GMacAST**code.**GMacDSL**

#### Scripting and Prototyping:

- The
language is a syntactically simplified version of the powerful C# 4.0 language that can integrate C#,**GMac Scripting**, and the Mathematica Language into a single scripting framework with limitless potential for geometric computing applications.**GMacDSL** - The
engine can communicate with Mathematica to perform symbolic, as well as numeric, manipulations and read the results as symbolic expressions, text, or images through the powerful capabilities of the Mathematica computer algebra system.**GMac Scripting** - The
engine can access**GMac Scripting**structures to perform multivector manipulations and explore the underlying**GMacAST**code effectively. This provides a valuable toolset for geometric computing application prototyping using Geometric Algebra at the core.**GMacDSL** - The
engine glues everything together through C#, a powerful object-oriented general-purpose strongly-typed programming language. C# capabilities, like Linq, Regular Expressions, .NET Framework Access, etc. can be used at various levels of complexity to perform simple-to-sophisticated prototyping tasks including the integration and coordination of**GMac Scripting**code and Mathematica symbolic and numeric manipulations.**GMacDSL**

#### Included Software Components:

includes the powerful text composition library**GMac**with all its capabilities intended for structured text generation including, but not limited to, code generation for any desired application.**TextComposerLib**also includes a simple wrapper, called**GMac**, around Wolfram Mathematica .NET/Link interface. The**SymbolicInterface**component classes can be used to interface any desired .NET application with Wolfram Mathematica (as a backend symbolic processor) with ease through a fully managed object-oriented interface.**SymbolicInterface**- The
component classes are designed for software engineers to be effective at creating full software libraries for geometric computing applications based on Geometric Algebra models.**GMacAPI**

#### Documentation:

- Comprehensive online user guides providing many examples and explanations.
- Freely downloadable GMac samples providing more
use cases that will be updated regularly (**GMac**).**coming****soon** - The GA Explorer Blog contains ideas and investigations that use
to explore Geometric Algebra constructions and applications.**GMac**

To use * GMac* you need to have a Windows 7 or later operating system and the .NET Framework version 4.0.

*depends on Wolfram Mathematica for its symbolic computations so you also need to install*

**GMac****Mathematica version 7 or later**. To take advantage of

*and its code generation capabilities you need to use*

**GMacAPI***as a .NET components library so you need a .NET development environment like Visual Studio 2010 or later to use*

**GMac***in your .NET projects. For more information about installing GMac, you can read the*

**GMac***. For detailed information about all aspects of GMac, you can read the online*

**GMac System Guide***.*

**GMac Guides**You can download the latest version of * GMac* source code from GitHub at https://github.com/ga-explorer/GMac.

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* backend 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 easily 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 is a sophisticated compiler and code composition system based on Geometric Algebra. In order to fully understand and effectively use the GMac system, you need to study the * GMac Guides* carefully.

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

*system operation. You can find these examples in the*

**GMac***page that will contain full source code and updated as new samples are created.*

**GMac Samples**