GALua
Geometric Algebra Library for the Lua Programming Language

# Defining the geometric algebra

To define a geometric algebra, we give GALua a set of basis vectors and then define the behavior of those basis vectors in the inner product. Such behavior is often referred to as the signature of the geometric algebra.

```galua_api.def_basis{ "e1", "e2", "e3" }
galua_api.def_sig( function( i, j )
if i == j then
return 1
end
return 0
end )
```

The indices given to the function that is the argument of the function `def_sig` correspond to the array given to the `def_basis` function. Note that when GA calculations are performed by the module, this function does not get called to determine the result of an inner product between two basis vectors. The function given here to `def_sig` is immediately evaluated to generate the full inner-product table, which is then kept and use internally for use in evaluating subsequent calculations.

As you can see, the code snippet above defines a simple Euclidean geometric algebra generated by a 3-dimensional vector space. The following example generates a Minkowski geometric algebra generated by a 5-dimensional vector space.

```galua_api.def_basis{ "e1", "e2", "e3", "no", "ni" }
galua_api.def_sig( function( i, j )
local ip_table =
{
{  1,  0,  0,  0,  0 },
{  0,  1,  0,  0,  0 },
{  0,  0,  1,  0,  0 },
{  0,  0,  0,  0, -1 },
{  0,  0,  0, -1,  0 },
}
return ip_table[i][j]
end )
```

As of this writing, there is no way to define the type of inner product to be used by the underlying GA calculation engine. The inner product that is used by GALua is an overloaded operator that implements the left contraction, right contraction, and the traditional vector-based inner product generalized to the taking of that product between any two blades of the same grade.

To make things a bit simpler, a companion module named GAUtil is provided with GALua that provides a set of convenient functions for defining a number of built-in geometric algebras. Make sure that GAUtil.lua is where Lua can find it. Adjust the LUA_PATH environment variable, if necessary. Utilizing this companion module, we may write the following at the start of our script.

```local galua_api = require "galua"
local gautil = require "gautil"

gautil.EGA3D( galua_api )
```

This goes ahead and defines the same 3-dimensional Euclidean geometric algebra we defined earlier. You can also call the `CGA3D` method in the same way to define the Minkowski geometric algebra also defined earlier. As of this writing, there is not much more to say about the GAUtil module.

On to the next tutorial!

Basic math operations

Copyright (C) 2013, by Spencer T. Parkin