Functions

What are the main functions and what they do

Algebra()

Algebra() is the most important function of any system with this library, as it defines an environment, that is, an algebra that will be used to handle future operations. Thus, as its definition follows, we have:

Main.Mingal.AlgebraFunction
Algebra(p, q, VectorBasis, Basis)::AlgebraStruct

Main function for creating your Algebra and adding its basis blades to REPL. Constructor Function of an algebraic object with parameters p, q, R^{p, q}, and its multivector space. If not defined, the last two parameters are automatically calculated as canonical.

Arguments

  • p::Int : The first parameter of the definition
  • q::Int : The second parameter of the definition
  • VectorBasis::Array{String} : An Array with vectors to work with
  • Basis::Array{Tuple{String,Int}} : An Array with the multivector base and it's indexes

Return

Returns the created Algebra object.

source

Which allows us to create spaces like the following, representing the imaginary set:

Algebra(0,1,["i"])
Algebra:
- p: 0
- q: 1
- VectorBasis: ["i"]
- Basis: ["1", "i"]

Blades

All types introduced in Mingal are subtype of AbstractGeometricAlgebraType. Blade type is the most primitive subtype wich is used to define more complete structures, like Multivectors. Once we define an Algebra, a set of Blade is created. For example, let us create the space R3.

Algebra(3)
Algebra:
- p: 3
- q: 0
- VectorBasis: ["e1", "e2", "e3"]
- Basis: ["1", "e1", "e2", "e3", "e1e2", "e1e3", "e2e3", "e1e2e3"]

Now, the elements id, e1, e2, e3, e1e2, e1e3, e2e3, e1e2e3 were created, representing the basis blades of the Algebra.

typeof(e1) <: Mingal.AbstractGeometricAlgebraType
true

By now, operation tables related to the geometric, internal and outer products are created and will be used in these operations. The id element is a BasisBlade used in place of the number 1.

Multivectors

Multivectors are mutable structures primarily used for internal operations within Mingal, but they are subtypes of AbstractGeometricAlgebraType. They are composed of the sum of blades arranged in a sparse vector, used for more efficient representation.

Note that there when is defined a scalar product or sum or diference between an real scalar and BasisBlade element a new Multivector is always returned. A Multivector struct is showed just in function and order of the Basis Blade set that define the space.

julia> Multivector <: Mingal.AbstractGeometricAlgebraType # truetrue
julia> Multivectors([8],[2.5]) == 2.5*e1e2e3 # truetrue
julia> Multivectors([1, 2, 3, 4, 5, 6],[1, 2, 3, 4, 5, 6]) == 1 + 2*e1 + 3*e2 + 4*e3 + 5*e1e2 + 6*e1e3 # truetrue

Simple Blade functions

bladeindex()

Main.Mingal.bladeindexFunction
bladeindex(vec, Al)::Array

Function that returns the indexes of a blade.

Arguments

  • vec::Blade : A Blade.
  • Al::AlgebraStruct : The Algebra, it is setted as CurrentAlgebra.

Return

Returns an array with all indexes of that blade.

source

And it works as the following example:

julia> Mingal.bladeindex(e1e2)1-element Vector{Array{Int64}}:
 [1, 2]

bladescalar()

Main.Mingal.bladescalarFunction
bladescalar(vec)::Any

Function that returns scalar of a Blade.

Arguments

  • vec::Blade : A Blade.

Return

A real number, the scalar.

source

And it works as the following example:

julia> Mingal.bladescalar(4.5*e1e2)4.5

grade()

Main.Mingal.gradeFunction
grade(vec)::Int

Function that returns the grade of the Blade.

Arguments

  • vec::Blade : A Blade.

Return

An integer, the grade of the blade.

source

And it works as the following example:

julia> grade(e1e2e3)3

gradeprojection()

Main.Mingal.gradeprojectionFunction
gradeprojection(vec, k)::Blade

Function that returns the grade Projection between a Blade and an Integer.

Arguments

  • vec::Blade : A Blade.
  • k::Int : An integer to the Grade Projection

Return

The result Blade. It might be the 1D blade "1"

source

And it works as the following example:

julia> gradeprojection(-e1e2, 2) == -1.0*e1e2true

Operations

Scalar Multiplication

The scalar multiplication is a type of operation that occurs between a blade or multivector and any scalar number. Its symbol for operations is *

And it works as the following example:

julia> 2*id*(e1+e2) == 2.0*e1+2.0*e2true

Geometric Product

The geometric product is the core of all geometric algebra, and here in Mingal, it is represented between blades and multivectors using the symbol *, which should not be confused with the scalar product symbol. Although they are the same, they have different contexts and operands of different types.

And it works as the following example:

julia> e3*e1 == -e1e3true

Inner Product

The inner product is another type of operation defined for Geometric Algebra and is represented within Mingal by the symbol \.

And it works as the following example:

julia> e1e2\e1 == -e2true

Outer Product

The Outer product is another type of operation defined for Geometric Algebra and is represented within Mingal by the symbol ^.

And it works as the following example:

julia> e1^e1e2 == 0*idtrue

All Together

The products can be used in whichever way is preferred, including all mixed together, with sums, parentheses, or any usual arithmetic operation.

And it works as the following example:

julia> (1+2*e1)\(5e1e2^e2) == 0.0*idtrue