proj home

Files   Classes   Functions   Hierarchy  

permutationfunc Class Reference

Store a list of permutation functions and calculate the binary operator * on these states. More...

#include <permutationfunc.h>

Collaboration diagram for permutationfunc:

List of all members.

Public Member Functions

 permutationfunc (uintc *fop_, uintc N_, uintc dim_)
 Initialize the class with the matrix of functions, the number of functions and the permutations dimension.
uintcfi (uintc i) const
 Return the function.
void ik (uint *x, uintc i, uintc k) const
 Apply binary functions i(k(0,1,.
uintc ik (bool &found, uintc i, uintc k) const
 Apply binary functions i(k(0,1,.
uintc inverse (bool &found, uintc *x) const
 Given a permutation find the index if it exists.
void writeBinaryOperator (bool &result, uint *mat) const
 Write the operator to matrix mat which is assumed to be N by N in length.

Public Attributes

uintcfop
 A pointer to the matrix of size N by dim.
uintc N
 The number of functions.
uintc dim
 The dimension of the permutation.


Detailed Description

Store a list of permutation functions and calculate the binary operator * on these states.

General support for permutations so looking at the classes interface does not help much.

This class was written was to calculate the states given the operators as permutations.

Example
  cout << "Test if flipping a triange and rotating it form a group." << endl;

  uint fop[] = 
  {
    0,1,2,
    1,2,0,
    2,0,1,
    0,2,1,
    2,1,0,
    1,0,2
  };
  permutationfunc pf(fop,6,3);

  cout << "Generate the binary table" << endl;

  uint mat[6*6];
  bool result;
  pf.writeBinaryOperator(result,mat);
  if (result==false)
  {
    cout << "Failed to form a binary operator." << endl;
    return;
  }

  binopproperties gt(mat,6);
  cout << "isGroup()=" << gt.isGroup() << endl;

Definition at line 46 of file permutationfunc.h.


Constructor & Destructor Documentation

permutationfunc::permutationfunc ( uintc fop_,
uintc  N_,
uintc  dim_ 
) [inline]

Initialize the class with the matrix of functions, the number of functions and the permutations dimension.

Definition at line 53 of file permutationfunc.h.

00057     : fop(fop_), N(N_), dim(dim_) {}


Member Function Documentation

uintc* permutationfunc::fi ( uintc  i  )  const [inline]

Return the function.

ie the i'th row.

Definition at line 67 of file permutationfunc.h.

References dim, and fop.

00068     { return fop + dim*i; }

uintc permutationfunc::ik ( bool found,
uintc  i,
uintc  k 
) const

Apply binary functions i(k(0,1,.

.,dim-1) and return the result as a state.

Definition at line 40 of file permutationfunc.cpp.

References dim, ik(), and inverse().

00041 {
00042   uint x[dim];
00043   ik(x,i,k);
00044 
00045   return inverse(found,x);
00046 }

void permutationfunc::ik ( uint x,
uintc  i,
uintc  k 
) const

Apply binary functions i(k(0,1,.

.,dim-1) and store in x.

Definition at line 32 of file permutationfunc.cpp.

References dim, fop, and N.

Referenced by ik().

00033 {
00034   assert(i<N);
00035   assert(k<N);
00036   for (uint w=0; w<dim; ++w)
00037     x[w] = fop[ i*dim + fop[ k*dim + w ] ];
00038 }

uintc permutationfunc::inverse ( bool found,
uintc x 
) const

Given a permutation find the index if it exists.

Definition at line 8 of file permutationfunc.cpp.

References dim, fop, and N.

Referenced by ik(), and binoppropertiestest::test03().

00009 {
00010   for (uint i=0; i<N; ++i)
00011   {
00012     found=true;
00013     for (uint k=0; k<dim; ++k)
00014     {
00015       if (x[k]!=fop[i*dim+k])
00016       {
00017         found=false;
00018         k=dim;
00019       }
00020     }
00021     
00022     if (found==false)
00023       continue;
00024 
00025     return i;
00026   }
00027 
00028   return 0;
00029 }

void permutationfunc::writeBinaryOperator ( bool result,
uint mat 
) const

Write the operator to matrix mat which is assumed to be N by N in length.

Definition at line 50 of file permutationfunc.cpp.

Referenced by binoppropertiestest::test05().

00054 {
00055   result=true;
00056   bool found;
00057   for (uint i=0; i<N; ++i)
00058     for (uint k=0; k<N; ++k)
00059     {
00060       mat[i*N+k] = ik(found,i,k);
00061       result &= found;
00062     }
00063 }


Member Data Documentation

The dimension of the permutation.

Definition at line 64 of file permutationfunc.h.

Referenced by fi(), ik(), and inverse().

A pointer to the matrix of size N by dim.

Definition at line 60 of file permutationfunc.h.

Referenced by fi(), ik(), and inverse().

The number of functions.

Definition at line 62 of file permutationfunc.h.

Referenced by ik(), and inverse().


The documentation for this class was generated from the following files:

Generated on Fri Mar 4 00:50:09 2011 for Chelton Evans Source by  doxygen 1.5.8