Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Mantid::Geometry::BnId Class Reference

Tri-state variable. More...

#include <BnId.h>

Public Member Functions

 BnId ()
 Standard Constructor. More...
 
 BnId (const size_t, unsigned int)
 Constructer that creates a true/false mapping without the undetermined option. More...
 
std::string display () const
 Displays the value as a string. More...
 
int equivalent (const BnId &) const
 Equal but - is assume to be ok. More...
 
size_t expressCount () const
 Total requiring expression. More...
 
int intValue () const
 Integer from binary expression. More...
 
std::pair< int, BnIdmakeCombination (const BnId &) const
 Find if A and this can be differ by one 1/-1 bit and make a 0 value for that bit. More...
 
void mapState (const std::vector< int > &, std::map< int, int > &) const
 Sets the components within base with true/false. More...
 
int operator++ ()
 addition operator (returns !carry flag) More...
 
int operator++ (int)
 addition operator (returns !carry flag) More...
 
int operator-- ()
 subtraction operator (returns !carry flag) More...
 
int operator-- (int)
 subtraction operator (returns !carry flag) More...
 
bool operator< (const BnId &) const
 operator> for tri-state object More...
 
bool operator== (const BnId &) const
 Equals operator for tri-state object. More...
 
bool operator> (const BnId &) const
 operator> for tri-state object More...
 
int operator[] (int const) const
 Access operator. More...
 
int PIstatus () const
 PI accessor. More...
 
void reverse ()
 Swap -1 to 1 adn leaver the zeros. More...
 
void setPI (const int A)
 PI accessor. More...
 
size_t Size () const
 returns number of variables / size More...
 
int TrueCount () const
 Access true count. More...
 
void write (std::ostream &) const
 writes the value to a stream More...
 

Private Member Functions

void setCounters ()
 Calculates Tnum and Znum. More...
 

Private Attributes

int PI
 Prime Implicant. More...
 
size_t size
 number of variables More...
 
int Tnum
 True number (1 in Tval) More...
 
std::vector< int > Tval
 Truth values. More...
 
int Znum
 Zero number (0 in Tval) More...
 

Detailed Description

Tri-state variable.

Author
S. Ansell
Date
April 2005
Version
1.0

This class holds a tri-state variable of -1 (false) 0 (not-important) 1 (true) against each of the possible input desisions. It has arbitrary lenght (unlike using a long integer)

Todo:
Could be improved by using a set of unsigned integers.

Definition at line 37 of file BnId.h.

Constructor & Destructor Documentation

◆ BnId() [1/2]

Mantid::Geometry::BnId::BnId ( )

Standard Constructor.

Definition at line 32 of file BnId.cpp.

◆ BnId() [2/2]

Mantid::Geometry::BnId::BnId ( const size_t  A,
unsigned int  X 
)

Constructer that creates a true/false mapping without the undetermined option.

Parameters
A:: size of the vector Tval. (number of surfaces)
X:: interger for of the binary representation

Definition at line 39 of file BnId.cpp.

References size, Tnum, Tval, and Mantid::Geometry::X.

Member Function Documentation

◆ display()

std::string Mantid::Geometry::BnId::display ( ) const

Displays the value as a string.

Simple display to string 0 == false, - == any, 1 == true.

Returns
String value of true etc

Definition at line 323 of file BnId.cpp.

References Tnum, Tval, and Znum.

Referenced by Mantid::Geometry::operator<<(), and write().

◆ equivalent()

int Mantid::Geometry::BnId::equivalent ( const BnId A) const

Equal but - is assume to be ok.

Tri-state return of the equality.

Parameters
A:: BnId object to compare
Return values
1== absolutely identical
0== not equal

Definition at line 77 of file BnId.cpp.

◆ expressCount()

size_t Mantid::Geometry::BnId::expressCount ( ) const
inline

Total requiring expression.

Definition at line 69 of file BnId.h.

◆ intValue()

int Mantid::Geometry::BnId::intValue ( ) const

Integer from binary expression.

Returns the lowest int value associated with the string.

Returns
lowest bit in the BnId vector

Definition at line 231 of file BnId.cpp.

References Tval.

◆ makeCombination()

std::pair< int, BnId > Mantid::Geometry::BnId::makeCombination ( const BnId A) const

Find if A and this can be differ by one 1/-1 bit and make a 0 value for that bit.

Parameters
A:: value to check Output
  • 0 :: nothing to do.
  • 1 :: complement found
  • -1 :: items are too differnt
Returns
pair<status,BnId> of possible new PI BnId is valid only if status ==1

Definition at line 260 of file BnId.cpp.

References setCounters(), and Tval.

◆ mapState()

void Mantid::Geometry::BnId::mapState ( const std::vector< int > &  Index,
std::map< int, int > &  Base 
) const

Sets the components within base with true/false.

Parameters
Index:: vector of Literal/Surface numbers
Base:: map to be filled

Definition at line 247 of file BnId.cpp.

Referenced by Mantid::Geometry::Acomp::getCNFobject(), Mantid::Geometry::Acomp::getDNFobject(), and Mantid::Geometry::Acomp::logicalEqual().

◆ operator++() [1/2]

int Mantid::Geometry::BnId::operator++ ( )

addition operator (returns !carry flag)

Addition operator Carrys out a rotational addition (effective binary addition.

It ignores non-important flags (Tval[i]==0)

Return values
0:: the function has looped (carry flag)
1:: no loop occored

Definition at line 157 of file BnId.cpp.

References Tnum, and Tval.

Referenced by operator++().

◆ operator++() [2/2]

int Mantid::Geometry::BnId::operator++ ( int  )

addition operator (returns !carry flag)

convertion to ++operator (prefix) from operator++ (postfix)

Return values
0:: the function has looped (carry flag)
1:: no loop occored

Definition at line 146 of file BnId.cpp.

References operator++().

◆ operator--() [1/2]

int Mantid::Geometry::BnId::operator-- ( )

subtraction operator (returns !carry flag)

Subtraction operator Carrys out a rotational subtraction (effective binary addition.

It ignores non-important flags (Tval[i]==0)

Return values
0:: the function has looped (carry flag)
1:: no loop occored

Definition at line 192 of file BnId.cpp.

References Tnum, and Tval.

Referenced by operator--().

◆ operator--() [2/2]

int Mantid::Geometry::BnId::operator-- ( int  )

subtraction operator (returns !carry flag)

Convertion to –operator (prefix) from operator-- (postfix)

Return values
0:: the function has looped (carry flag)
1:: no loop occored

Definition at line 181 of file BnId.cpp.

References operator--().

◆ operator<()

bool Mantid::Geometry::BnId::operator< ( const BnId A) const

operator> for tri-state object

Tri-state return of the ordering of number of true states.

Parameters
A:: BnId object to compare
Returns
Size

Definition at line 107 of file BnId.cpp.

◆ operator==()

bool Mantid::Geometry::BnId::operator== ( const BnId A) const

Equals operator for tri-state object.

Tri-state return of the equality.

Parameters
A:: BnId object to compare
Return values
1== absolutely identical
0== not equal

Definition at line 57 of file BnId.cpp.

◆ operator>()

bool Mantid::Geometry::BnId::operator> ( const BnId A) const

operator> for tri-state object

Tri-state return of the ordering of number of true.

Parameters
A:: BnId object to compare
Returns
!(this

Definition at line 97 of file BnId.cpp.

◆ operator[]()

int Mantid::Geometry::BnId::operator[] ( int const  A) const

Access operator.

Returns the particular rule value.

Parameters
A:: array offset 0->size-1
Returns
-99 on err, Tval[A] normally

Definition at line 134 of file BnId.cpp.

◆ PIstatus()

int Mantid::Geometry::BnId::PIstatus ( ) const
inline

PI accessor.

Definition at line 63 of file BnId.h.

◆ reverse()

void Mantid::Geometry::BnId::reverse ( )

Swap -1 to 1 adn leaver the zeros.

Reverset the bits.

Transform 1 -> -1

Definition at line 312 of file BnId.cpp.

References setCounters(), and Tval.

◆ setCounters()

void Mantid::Geometry::BnId::setCounters ( )
private

Calculates Tnum and Znum.

Sets the counters Tnum and Znum.

Definition at line 215 of file BnId.cpp.

References Tnum, Tval, and Znum.

Referenced by makeCombination(), and reverse().

◆ setPI()

void Mantid::Geometry::BnId::setPI ( const int  A)
inline

PI accessor.

Definition at line 64 of file BnId.h.

Referenced by Mantid::Geometry::Acomp::makePI().

◆ Size()

size_t Mantid::Geometry::BnId::Size ( ) const
inline

returns number of variables / size

Definition at line 71 of file BnId.h.

Referenced by Mantid::Geometry::Acomp::addUnit().

◆ TrueCount()

int Mantid::Geometry::BnId::TrueCount ( ) const
inline

Access true count.

Definition at line 73 of file BnId.h.

◆ write()

void Mantid::Geometry::BnId::write ( std::ostream &  os) const

writes the value to a stream

Definition at line 345 of file BnId.cpp.

References display().

Member Data Documentation

◆ PI

int Mantid::Geometry::BnId::PI
private

Prime Implicant.

Definition at line 40 of file BnId.h.

◆ size

size_t Mantid::Geometry::BnId::size
private

number of variables

Definition at line 39 of file BnId.h.

Referenced by BnId().

◆ Tnum

int Mantid::Geometry::BnId::Tnum
private

True number (1 in Tval)

Definition at line 41 of file BnId.h.

Referenced by BnId(), display(), operator++(), operator--(), and setCounters().

◆ Tval

std::vector<int> Mantid::Geometry::BnId::Tval
private

Truth values.

Definition at line 43 of file BnId.h.

Referenced by BnId(), display(), intValue(), makeCombination(), operator++(), operator--(), reverse(), and setCounters().

◆ Znum

int Mantid::Geometry::BnId::Znum
private

Zero number (0 in Tval)

Definition at line 42 of file BnId.h.

Referenced by display(), and setCounters().


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