package jcliffford

jclifford
Class Clifford

java.lang.Object
  extended by jclifford.Clifford
Direct Known Subclasses:
Homogeneous

public class Clifford
extends java.lang.Object

This class represents a Clifford element and all the operation in a signed space.

Use this class for p + q <= 8. For p + q > 8 use CliffordBitSet or CliffordTreeSet instead.

Version:

0.9

Author:

Realized by Giorgio Vassallo, Pietro Brignola, November 2002.

See Also:
CliffordBitSet, CliffordTreeSet

Field Summary
protected static int dim
          Algebra's dimension.
protected static double eps
          Algebra's Precision.
protected static int[] gradeTable
          Stores the grade (number of bits 1 in the binary rappresentation) of a blade.
protected static int hdim
          Algebra's possible blades (2 ^ dim).
protected  java.util.TreeMap map
          Element's blade-value mappings.
protected static int p
          Number of dimensions with positive square versors.
protected static Clifford pseudoScalar
          Algebra's pseudoscalar.
protected static int q
          Number of dimensions with negative square versors.
protected static int signMask
          Mask with p bits 0 and q bits 1 corresponding to negative square versors (starting from l.s.b.).
protected static boolean[][] signTable
          Stores the grade (number of bits 1 in the binary rappresentation) of a blade.
protected static int spaceMask
          Mask with bits 1 corresponding to the presence of dimensions (starting from l.s.b.).
 
Constructor Summary
Clifford()
          Creates and returns an element with no blade-value mappings.
Clifford(int[] blades, double[] values)
          Creates and returns an element with specified blade-value mappings.
 
Method Summary
 Clifford add(Clifford cl)
          Adds two elements.
private static int bCoefficent(int n, int k)
          Computes binomial coefficents.
private static int bitCount(int bld)
          Counts the number of bits 1 in the binary rappresentation of a blade.
 java.lang.Object clone()
          Creates and returns an element deeply cloning this element.
 Clifford comm(Clifford cl)
          Computes the commutation with the specified element.
 Clifford conj()
          Computes the conjugation of this element.
 double dot(Clifford cl)
          Computes the fast dot product of two vector.
 Clifford dual()
          Computes the dual of this element.
 boolean equals(java.lang.Object obj)
          Compares two elements for equality.
 double get(int blade)
          Gets the value of a blade.
 double get(java.lang.String blademask)
          Gets the value of a blade.
static int getDim()
          Gets algebra's dimension.
static double getEps()
          Gets algebra's precision.
 int getMaxGrade()
          Gets highest grade of this element.
static int getPossibleBlades()
          Gets algebra's possible blades.
private static boolean getSign(int bld1, int bld2)
          Computes the sign of the product of two blades.
 Clifford gP(Clifford cl)
          Computes the geometric product of two elements.
 Clifford gP(double scalar)
          Computes the geometric product of an element and a scalar.
 Clifford grade(int grade)
          Grades an element.
 Clifford gradeInv()
          Computes the grade involution of this element.
static void init(int pdim, int ndim)
          Initializes algebra's signature.
 Clifford inv()
          Computes the inverse of this element.
 boolean isScalar()
          Verifies if this element is a scalar.
 boolean isVector()
          Verifies if this element is a vector.
 Clifford lC(Clifford cl)
          Computes the left contraction with the specified element.
 Clifford meet(Clifford cl)
          Computes the meet with the specified element.
 Clifford meet(Clifford cl, Clifford is)
          Computes the meet with the specified element in a common subspace.
 void normalize()
          Normalizes this element respect the unsigned module.
 void noZero()
          Removes blades with values lower than eps.
 void put(int blade, double value)
          Puts a new blade-value mapping or updates existing.
 void put(java.lang.String blademask, double value)
          Puts a new blade-value mapping or updates existing.
 Clifford rC(Clifford cl)
          Computes the right contraction with the specified element.
 Clifford reflect(Clifford n)
          Computes the reflection against the specified vector.
 void remove(int blade)
          Removes blade-value mapping if existing.
 Clifford rev()
          Computes the reverse of this element.
static void setEps(double e)
          Sets algebra's precision.
static void setMeetSubSpace(int subspace)
          Sets meet operation subspace.
 double sQuadMod()
          Computes the quad module of an element regarding signature.
 Clifford sub(Clifford cl)
          Subtracts two elements.
 java.lang.String toString()
          Returns a string representation of the element.
 double uQuadMod()
          Computes the quad module of an element discarding signature.
 Clifford wP(Clifford cl)
          Computes the wedge product of two elements.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

map

protected java.util.TreeMap map
Element's blade-value mappings.


eps

protected static double eps
Algebra's Precision.


p

protected static int p
Number of dimensions with positive square versors.


q

protected static int q
Number of dimensions with negative square versors.


dim

protected static int dim
Algebra's dimension.


hdim

protected static int hdim
Algebra's possible blades (2 ^ dim).


spaceMask

protected static int spaceMask
Mask with bits 1 corresponding to the presence of dimensions (starting from l.s.b.). Es.: dim = p + q = 5, spacemask = [0...011111].


signMask

protected static int signMask
Mask with p bits 0 and q bits 1 corresponding to negative square versors (starting from l.s.b.). Es.: p = 3, q = 2, signmask = [0...011000].


gradeTable

protected static int[] gradeTable
Stores the grade (number of bits 1 in the binary rappresentation) of a blade.


signTable

protected static boolean[][] signTable
Stores the grade (number of bits 1 in the binary rappresentation) of a blade.


pseudoScalar

protected static Clifford pseudoScalar
Algebra's pseudoscalar.

Constructor Detail

Clifford

public Clifford()
         throws java.lang.RuntimeException
Creates and returns an element with no blade-value mappings.

Throws:
java.lang.RuntimeException - if algebra's signature is not initialized.

Clifford

public Clifford(int[] blades,
                double[] values)
         throws java.lang.RuntimeException,
                java.lang.IllegalArgumentException
Creates and returns an element with specified blade-value mappings.

Parameters:
blades - the int array representing the specified blades.
values - the double array representing the corresponding values.
Throws:
java.lang.RuntimeException - if algebra's signature is not initialized.
java.lang.IllegalArgumentException - if the arrays have different lenght.
Method Detail

getEps

public static double getEps()
Gets algebra's precision.

Returns:
algebra's precision.

setEps

public static void setEps(double e)
                   throws java.lang.IllegalArgumentException
Sets algebra's precision.

Parameters:
e - positive precision.
Throws:
java.lang.IllegalArgumentException - if the precision is negative.

getDim

public static int getDim()
Gets algebra's dimension.

Returns:
algebra's dimension.

getPossibleBlades

public static int getPossibleBlades()
Gets algebra's possible blades.

Returns:
algebra's possible blades.

bitCount

private static int bitCount(int bld)
Counts the number of bits 1 in the binary rappresentation of a blade.

Parameters:
bld - the blade whose number of bits 1 in its binary rappresentation are to be counted.
Returns:
the number of bits 1 in the binary rappresentation of the specified blade.

getSign

private static boolean getSign(int bld1,
                               int bld2)
Computes the sign of the product of two blades.

Parameters:
bld1 - the first blade of the product.
bld2 - the second blade of the product.
Returns:
true if the sign of the product of the specified blades is negative, false otherwise.

bCoefficent

private static int bCoefficent(int n,
                               int k)
Computes binomial coefficents.

Parameters:
n - the dimension.
k - the grade.
Returns:
binomial coefficent.

init

public static void init(int pdim,
                        int ndim)
                 throws java.lang.IllegalArgumentException
Initializes algebra's signature.

Parameters:
pdim - the number of dimensions with versors that square in 1.
ndim - the number of dimensions with versors that square in -1.
Throws:
java.lang.IllegalArgumentException - if p or q are negative or their sum is greater than 8.

setMeetSubSpace

public static void setMeetSubSpace(int subspace)
                            throws java.lang.IllegalArgumentException
Sets meet operation subspace.

Parameters:
subspace - the meet operation subspace.
Throws:
java.lang.IllegalArgumentException - if subspace is negative or outside algebra's space mask.

get

public double get(int blade)
           throws java.lang.IllegalArgumentException
Gets the value of a blade.

Parameters:
blade - the int representing the specified blade whose value is to be retrieved.
Returns:
the value of the specified blade, 0.0 if blade is not present.
Throws:
java.lang.IllegalArgumentException - if blade is negative or outside algebra's space mask.

get

public double get(java.lang.String blademask)
           throws java.lang.IllegalArgumentException
Gets the value of a blade.

Parameters:
blademask - the binary mask representing the specified blade whose value is to be retrieved.
Returns:
the value of the specified blade, 0.0 if blade is not present.
Throws:
java.lang.IllegalArgumentException - if blademask is invalid, blade is negative or outside algebra's space mask.

put

public void put(int blade,
                double value)
         throws java.lang.IllegalArgumentException
Puts a new blade-value mapping or updates existing.

Parameters:
blade - the int representing the specified blade that is to be put.
value - the double representing the corresponding value of the specified blade.
Throws:
java.lang.IllegalArgumentException - if blade is negative or outside algebra's space mask.

put

public void put(java.lang.String blademask,
                double value)
         throws java.lang.IllegalArgumentException
Puts a new blade-value mapping or updates existing.

Parameters:
blademask - the binary mask representing the specified blade that is to be put.
value - the double representing the corresponding value of the specified blade.
Throws:
java.lang.IllegalArgumentException - if blademask is invalid, blade is negative or outside algebra's space mask.

remove

public void remove(int blade)
            throws java.lang.IllegalArgumentException
Removes blade-value mapping if existing.

Parameters:
blade - the int representing the specified blade that is to be removed.
Throws:
java.lang.IllegalArgumentException - if blade is negative or outside algebra's space mask.

toString

public java.lang.String toString()
Returns a string representation of the element.

Overrides:
toString in class java.lang.Object
Returns:
the string representation of the element.

clone

public java.lang.Object clone()
Creates and returns an element deeply cloning this element.

Overrides:
clone in class java.lang.Object

noZero

public final void noZero()
Removes blades with values lower than eps.


uQuadMod

public final double uQuadMod()
Computes the quad module of an element discarding signature.

Returns:
the quad module of the specified element discarding signature.

sQuadMod

public final double sQuadMod()
Computes the quad module of an element regarding signature.

Returns:
the quad module of the specified element regarding signature.

normalize

public final void normalize()
Normalizes this element respect the unsigned module.


getMaxGrade

public final int getMaxGrade()
Gets highest grade of this element.

Returns:
highest grade of this element.

isScalar

public final boolean isScalar()
Verifies if this element is a scalar.

Returns:
true if this element is a scalar, false otherwise.

isVector

public final boolean isVector()
Verifies if this element is a vector.

Returns:
true if this element is a vector, false otherwise.

equals

public boolean equals(java.lang.Object obj)
Compares two elements for equality. Two elements are considered equals if they have same blades and corresponding values differing less than 2*EPS.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the second element that is to be compared.
Returns:
true if the two specified elements are equals, false otherwise.

add

public final Clifford add(Clifford cl)
Adds two elements.

Parameters:
cl - the second element of the sum.
Returns:
a new element from the sum of the two specified elements.

sub

public final Clifford sub(Clifford cl)
Subtracts two elements.

Parameters:
cl - the second element of the difference.
Returns:
a new element from the difference of the two specified elements.

gradeInv

public final Clifford gradeInv()
Computes the grade involution of this element.

Returns:
a new element from the grade involution of the specified element.

rev

public final Clifford rev()
Computes the reverse of this element.

Returns:
a new element from the reversion of this element.

inv

public final Clifford inv()
Computes the inverse of this element.

Returns:
a new element from the inversion of this element.

conj

public final Clifford conj()
Computes the conjugation of this element. The conjugation of an element is a grade involution and a reversion.

Returns:
a new element from the conjugation of the specified element.

grade

public final Clifford grade(int grade)
Grades an element.

Parameters:
grade - the specified grade of the grading operation.
Returns:
a new element with only terms of the specified grade.

gP

public final Clifford gP(double scalar)
Computes the geometric product of an element and a scalar.

Parameters:
scalar - the scalar of the geometric product.
Returns:
a new element from the geometric product of the specified element and the specified scalar.

gP

public final Clifford gP(Clifford cl)
Computes the geometric product of two elements.

Parameters:
cl - the second element of the geometric product.
Returns:
a new element from the geometric product of the two specified elements.

wP

public final Clifford wP(Clifford cl)
Computes the wedge product of two elements.

Parameters:
cl - the second element of the wedge product.
Returns:
a new element from the wedge product of the two specified elements.

lC

public final Clifford lC(Clifford cl)
Computes the left contraction with the specified element.

Parameters:
cl - the second element of the left contraction.
Returns:
a new element from the left contraction with the specified element.

rC

public final Clifford rC(Clifford cl)
Computes the right contraction with the specified element.

Parameters:
cl - the second element of the right contraction.
Returns:
a new element from the right contraction with the specified element.

dot

public final double dot(Clifford cl)
                 throws java.lang.IllegalArgumentException
Computes the fast dot product of two vector.

Parameters:
cl - the second vector of the fast dot product.
Returns:
the dot product of the two specified vector.
Throws:
java.lang.IllegalArgumentException - if elements are not vectors.

comm

public final Clifford comm(Clifford cl)
Computes the commutation with the specified element.

Parameters:
cl - the second element of the commutation.
Returns:
a new element from the commutation with the specified element.

dual

public final Clifford dual()
Computes the dual of this element.

Returns:
a new element that is the dual of this element.

meet

public final Clifford meet(Clifford cl)
Computes the meet with the specified element.

Parameters:
cl - the second element of the meet.
Returns:
a new element from the meet with the specified element.

meet

public final Clifford meet(Clifford cl,
                           Clifford is)
Computes the meet with the specified element in a common subspace.

Parameters:
cl - the second element of the meet.
is - the element representing a common subspace.
Returns:
a new element from the meet with the specified element.

reflect

public final Clifford reflect(Clifford n)
Computes the reflection against the specified vector.

Parameters:
n - the vector against wich reflect.
Returns:
a new element from the reflection against the specified vector.

package jclifford

package jclifford API Specification