org.uacalc.alg
Class ProductAlgebra

java.lang.Object
  extended by org.uacalc.alg.GeneralAlgebra
      extended by org.uacalc.alg.ProductAlgebra
All Implemented Interfaces:
Algebra, SmallAlgebra
Direct Known Subclasses:
PowerAlgebra

public class ProductAlgebra
extends GeneralAlgebra
implements SmallAlgebra

This class represents the direct product of SmallAlgebras.

Version:
$Id: ProductAlgebra.java,v 1.15 2011/04/03 01:25:04 ralphfreese Exp $
Author:
Ralph Freese

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.uacalc.alg.SmallAlgebra
SmallAlgebra.AlgebraType
 
Field Summary
protected  java.util.List<SmallAlgebra> algebras
           
protected  int numberOfProducts
           
protected  int[] sizes
           
 
Fields inherited from class org.uacalc.alg.GeneralAlgebra
con, description, monitor, name, operations, operationsMap, similarityType, size, sub, universe
 
Fields inherited from interface org.uacalc.alg.Algebra
CARDINALITY_COUNTABLE, CARDINALITY_COUNTABLY_INFINITE, CARDINALITY_FINITE, CARDINALITY_INFINITE, CARDINALITY_UNKNOWN
 
Constructor Summary
protected ProductAlgebra()
           
  ProductAlgebra(java.util.List<SmallAlgebra> algs)
           
protected ProductAlgebra(java.lang.String name)
           
  ProductAlgebra(java.lang.String name, java.util.List<SmallAlgebra> algs)
          Construct the direct product of a List of SmallAlgebra's.
 
Method Summary
 SmallAlgebra.AlgebraType algebraType()
          The type of algebra this is, like a quotient algebra.
static int calcCard(int[] sizes)
          Returns the product cardinality if it is an int; otherwise it returns -1.
 CongruenceLattice con()
          The congurence lattice.
 void convertToDefaultValueOps()
          This is used in the UI.
 int elementIndex(java.lang.Object obj)
          This method will return k if elem is the kth element; otherwise -1.
 java.util.List<SmallAlgebra> factors()
           
 java.lang.Object getElement(int index)
          returns the kth element.
 java.util.List getUniverseList()
          The universe as a List such getElement(k) will equal the kth element of the List.
 java.util.Map getUniverseOrder()
          A map that can be used for elementIndex(a).
static void main(java.lang.String[] args)
           
protected  java.util.Set makeCartesianProduct(java.util.List algs)
          Returns the carrier set of the product of the specified List algs of Objects as a Set.
protected  void makeOperations()
           
 void makeOperationTables()
          Make operation tables to speed up the evaluation of operations at the cost using more space.
 java.util.List<SmallAlgebra> parents()
          For a ProductAlgebra this will be the factors.
 SmallAlgebra projection(int k)
           
 BasicPartition projectionKernel(int k)
           
 Subalgebra Sg(java.util.List<IntArray> elems)
          The subalgebra generated by elems given as arrays of int's.
 java.util.List sgClose(java.util.List elems)
           
 SubalgebraLattice sub()
          The subalgebra lattice.
 
Methods inherited from class org.uacalc.alg.GeneralAlgebra
cardinality, constantOperations, getDescription, getMonitor, getName, getOperation, getOperationsMap, inputSize, isIdempotent, isSimilarTo, isTotal, isUnary, iterator, monitoring, operations, parent, resetConAndSub, setDescription, setMonitor, setName, setOperations, setUniverse, similarityType, universe
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.uacalc.alg.SmallAlgebra
parent, resetConAndSub
 
Methods inherited from interface org.uacalc.alg.Algebra
cardinality, constantOperations, getDescription, getMonitor, getName, getOperation, getOperationsMap, inputSize, isIdempotent, isSimilarTo, isTotal, isUnary, iterator, monitoring, operations, setDescription, setMonitor, setName, similarityType, universe
 

Field Detail

algebras

protected java.util.List<SmallAlgebra> algebras

sizes

protected int[] sizes

numberOfProducts

protected int numberOfProducts
Constructor Detail

ProductAlgebra

protected ProductAlgebra()

ProductAlgebra

protected ProductAlgebra(java.lang.String name)

ProductAlgebra

public ProductAlgebra(java.util.List<SmallAlgebra> algs)

ProductAlgebra

public ProductAlgebra(java.lang.String name,
                      java.util.List<SmallAlgebra> algs)
Construct the direct product of a List of SmallAlgebra's.

Method Detail

makeOperations

protected void makeOperations()

makeOperationTables

public void makeOperationTables()
Description copied from interface: Algebra
Make operation tables to speed up the evaluation of operations at the cost using more space.

Specified by:
makeOperationTables in interface Algebra
Overrides:
makeOperationTables in class GeneralAlgebra
See Also:
Operation.makeTable

factors

public java.util.List<SmallAlgebra> factors()

parents

public java.util.List<SmallAlgebra> parents()
Description copied from interface: SmallAlgebra
For a ProductAlgebra this will be the factors. For a BasicAlgebra it will be null. Otherwise it is a list of the parent algebra.

Specified by:
parents in interface SmallAlgebra
Overrides:
parents in class GeneralAlgebra
See Also:
parent

projection

public SmallAlgebra projection(int k)

projectionKernel

public BasicPartition projectionKernel(int k)

con

public CongruenceLattice con()
Description copied from interface: SmallAlgebra
The congurence lattice.

Specified by:
con in interface SmallAlgebra
Overrides:
con in class GeneralAlgebra

sub

public SubalgebraLattice sub()
Description copied from interface: SmallAlgebra
The subalgebra lattice.

Specified by:
sub in interface SmallAlgebra
Overrides:
sub in class GeneralAlgebra

elementIndex

public int elementIndex(java.lang.Object obj)
Description copied from interface: SmallAlgebra
This method will return k if elem is the kth element; otherwise -1. (Should we have it throw an error instead?)

Specified by:
elementIndex in interface SmallAlgebra

getElement

public java.lang.Object getElement(int index)
Description copied from interface: SmallAlgebra
returns the kth element.

Specified by:
getElement in interface SmallAlgebra

getUniverseList

public java.util.List getUniverseList()
Description copied from interface: SmallAlgebra
The universe as a List such getElement(k) will equal the kth element of the List. It is allowed to be null.

Specified by:
getUniverseList in interface SmallAlgebra

getUniverseOrder

public java.util.Map getUniverseOrder()
Description copied from interface: SmallAlgebra
A map that can be used for elementIndex(a). It is allowed to be null.

Specified by:
getUniverseOrder in interface SmallAlgebra

makeCartesianProduct

protected java.util.Set makeCartesianProduct(java.util.List algs)
Returns the carrier set of the product of the specified List algs of Objects as a Set. This set does not support to be modified in any way (by adding or deleting or otherwise modifying its members). This applies in particular to the elements returned by the iterator(). Modifying them does not have any effect on the elements in the set, as they are not stored explicitly.

For the size of the set, see the calcCard(int[]) method.

The contains method returns true iff applied to a List of objects that are successively contained in the algebras in algs.

The iterator() returns the tuples in the product as ArrayLists in lexicographic order (reading words from left to right). This means the right-most (last, largest) index is incremented fastest. The order of the algebras in the given List algs determines the order of the entries in the tuples. This iterator supports only forward iteration and has got no remove method. Furthermore, there is no possibility to change the elements in the Set by modifying the tuples returned by the iterator. Putting this differently, the iterator only provides the "enumeration functionality", but not the complete "element access functionality". It is possible to iterate past the end of the set, i.e., after hasNext has returned false. In this case the iterator starts again with the first tuple.

Parameters:
algs - List of Algebras being factors of the product.
Returns:
a Set of all tuples (ArrayLists) in the product.
Throws:
java.lang.UnsupportedOperationException - if the iterator() is used and one of the objects in the List algs is not an Algebra.
java.lang.UnsupportedOperationException - if the Set is modified by one of the methods add, addAll, clear, remove, removeAll, retainAll.

Sg

public Subalgebra Sg(java.util.List<IntArray> elems)
The subalgebra generated by elems given as arrays of int's.


sgClose

public java.util.List sgClose(java.util.List elems)

calcCard

public static int calcCard(int[] sizes)
Returns the product cardinality if it is an int; otherwise it returns -1.

Parameters:
sizes -
Returns:

convertToDefaultValueOps

public void convertToDefaultValueOps()
Description copied from interface: SmallAlgebra
This is used in the UI. Only valid for BASIC algebras.

Specified by:
convertToDefaultValueOps in interface SmallAlgebra

algebraType

public SmallAlgebra.AlgebraType algebraType()
Description copied from interface: SmallAlgebra
The type of algebra this is, like a quotient algebra.

Specified by:
algebraType in interface SmallAlgebra
Returns:

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException,
                        BadAlgebraFileException
Throws:
java.io.IOException
BadAlgebraFileException


Copyright 2003 Ralph Freese. All Rights Reserved.