Mantid
|
Holds a state point in the decision tree. More...
#include <Acomp.h>
Public Member Functions | |
Acomp (int const =0) | |
Standard Constructor. More... | |
std::pair< Acomp, Acomp > | algDiv (const Acomp &) |
Carry out Algebric division. More... | |
void | complement () |
Take complement of component. More... | |
int | contains (const Acomp &) const |
Checks the Units of A to see if they are in this->Units. More... | |
std::string | display () const |
Pretty print statment. More... | |
std::string | displayDepth (int const =0) const |
Really pretty print statment of tree. More... | |
void | getAbsLiterals (std::map< int, int > &) const |
Get literals (positve) More... | |
std::vector< int > | getKeys () const |
Get the key numbers in the system. More... | |
void | getLiterals (std::map< int, int > &) const |
Get literals (+/- different) More... | |
int | isCNF () const |
is Units only in intersections More... | |
int | isDNF () const |
is Units only in union More... | |
int | isInter () const |
Deterimine if inter/union. More... | |
int | isNull () const |
is nothing in the comp. More... | |
int | isSimple () const |
true if only Units More... | |
int | isSingle () const |
only one part More... | |
int | isTrue (const std::map< int, int > &) const |
Determine if the rule is true. More... | |
const Acomp * | itemC (int const) const |
returns a pointer to Comp (or zero) More... | |
int | itemN (int const) const |
returns an integer to Units (or zero) More... | |
int | logicalEqual (const Acomp &) const |
Test that the system that is logically the same: More... | |
int | makeCNFobject () |
Make the object into CNF form (Product of Sums) More... | |
int | makeDNFobject () |
Make the object into DNF form (Sum of Products) More... | |
bool | operator!= (const Acomp &) const |
Complementary operator. More... | |
Acomp & | operator*= (const Acomp &) |
This carries out the intersection operation with A. More... | |
Acomp & | operator+= (const Acomp &) |
Operator + (union addition) More... | |
Acomp & | operator-= (const Acomp &) |
Operator - (removal) This operation can be carried out in many ways. More... | |
bool | operator< (const Acomp &) const |
Comparitor operator:: Comparies the unit list (which is already sorted) part by part. More... | |
bool | operator== (const Acomp &) const |
Equals operator requires that the Units are equal and the Comp units are equal. More... | |
bool | operator> (const Acomp &) const |
Operator> takes first to last precidence. More... | |
void | printImplicates (const std::vector< BnId > &, const Kernel::Matrix< int > &) const |
Debug function to print out PI and Grid : More... | |
void | setString (const std::string &) |
Processes a line of type abc'+efg. More... | |
std::pair< int, int > | size () const |
get the size of the units and the Acomp sub-comp More... | |
void | Sort () |
Sort the Units+Comp items. More... | |
void | writeFull (std::ostream &, int const =0) const |
Full write out to determine state. More... | |
Private Member Functions | |
void | addComp (const Acomp &) |
add a Component intelligently More... | |
void | addUnit (const std::vector< int > &, const BnId &) |
Adds a Binary state to the Component. More... | |
void | addUnitItem (int const) |
add an Unit intellgently More... | |
void | assignCNF (const std::vector< int > &, const std::vector< BnId > &) |
Assigns the Comp with the DNF. More... | |
void | assignDNF (const std::vector< int > &, const std::vector< BnId > &) |
Assigns the Comp with the DNF. More... | |
int | copySimilar (const Acomp &) |
Join two componenet of similar type. More... | |
void | deleteComp () |
delete all of the Comp list More... | |
int | getCNFobject (std::vector< int > &, std::vector< BnId > &) const |
Creates the CNF items (ie the binary list of false statements) It forms a sum of products. More... | |
int | getDNFobject (std::vector< int > &, std::vector< BnId > &) const |
Creates the DNF items (ie the binary list of true statements) It forms a sum of products. More... | |
int | getDNFpart (std::vector< Acomp > &) const |
get the DNF parts (as Acomp) More... | |
int | joinDepth () |
Search table to uplift objects. More... | |
int | makeEPI (std::vector< BnId > &, std::vector< BnId > &) const |
Creates an essentual PI list (note: this is not unique). More... | |
int | makePI (std::vector< BnId > &) const |
Calculate Principal Components. More... | |
int | makeReadOnce () |
Factorize into a read once function. More... | |
void | processIntersection (const std::string &) |
Helper function :: assumes that Ln has been checked for bracket consistency. More... | |
void | processUnion (const std::string &) |
Helper function :: assumes that Ln has been checked for bracket consistency Units are sorted after this function is returned. More... | |
int | removeEqComp () |
Remove non-unique items. More... | |
Private Attributes | |
std::vector< Acomp > | Comp |
Components in list. More... | |
int | Intersect |
Union/Intersection (0,1) More... | |
std::vector< int > | Units |
Units in list. More... | |
Holds a state point in the decision tree.
Holds the state of a logical unit. Either a state point and intersection or a unit A component, either a union or intersection. It has to have the ability to change the type from union/intersection in an instant. Hence the type flag. This currently works with forming disjunction form. The disjunction form is "or" [ v symbol ]. Thus is is a set of unions.
Mantid::Geometry::Acomp::Acomp | ( | int const | Tx = 0 | ) |
|
private |
add a Component intelligently
Adds a pointer to the Comp list.
If the pointer is singular, extracts the object and adds that componenet. Assumes that the component is sorted and inserts appropiately.
AX | :: Acomp component to add |
Definition at line 308 of file Acomp.cpp.
References Comp, Intersect, isSingle(), size(), and Units.
Referenced by algDiv(), assignCNF(), assignDNF(), copySimilar(), operator*=(), operator+=(), operator-=(), processIntersection(), and processUnion().
|
private |
Adds a Binary state to the Component.
Given a single BnId unit and an index adds it to the main Units object.
Index | :: number , surfNumber |
BX | :: binary component |
Definition at line 506 of file Acomp.cpp.
References Mantid::Geometry::BnId::Size(), Mantid::Geometry::split(), and Units.
Referenced by assignCNF(), assignDNF(), and getDNFpart().
|
private |
add an Unit intellgently
Adds a unit to the Unit list (if it doesn't exist).
Item | :: Unit to add |
Definition at line 346 of file Acomp.cpp.
References Units.
Referenced by algDiv(), getDNFpart(), and processIntersection().
Carry out Algebric division.
Carries out algebraic division.
G | :: The divisor |
Definition at line 1207 of file Acomp.cpp.
References addComp(), addUnitItem(), Comp, getDNFpart(), getLiterals(), isDNF(), isNull(), makeDNFobject(), and Units.
Referenced by Mantid::Geometry::Algebra::algDiv().
|
private |
Assigns the Comp with the DNF.
Assign the object to the Essentual PI in the vector A.
This will make the form DNF.
Index | :: SurfNumbers |
A | :: Vector of BnId's that are valid |
Definition at line 556 of file Acomp.cpp.
References addComp(), addUnit(), deleteComp(), Intersect, Units, and Mantid::Geometry::X.
Referenced by makeCNFobject().
|
private |
Assigns the Comp with the DNF.
Assign the object to the Essentual PI in the vector A.
This will make the form DNF.
Index | :: SurfNumbers |
A | :: Vector of BnId's that are valid |
Definition at line 527 of file Acomp.cpp.
References addComp(), addUnit(), deleteComp(), Intersect, and Units.
Referenced by makeDNFobject().
void Mantid::Geometry::Acomp::complement | ( | ) |
Take complement of component.
Take a complement of the current object This will reverse the type since union<->intersection as a+b -> a'b' and ab -> a'+b'.
Resort the list. use reverse?
Definition at line 1476 of file Acomp.cpp.
References Comp, complement(), Intersect, and Units.
Referenced by complement(), Mantid::Geometry::Algebra::Complement(), and setString().
int Mantid::Geometry::Acomp::contains | ( | const Acomp & | A | ) | const |
|
private |
Join two componenet of similar type.
Class to merge two list of similar objects.
Makes a full copy of the objects It requires that the Intersect is the same for both
A | :: Object to copy |
Definition at line 479 of file Acomp.cpp.
References addComp(), Comp, Intersect, and Units.
Referenced by operator*=(), and operator+=().
|
private |
delete all of the Comp list
Deletes everything in Composite.
Definition at line 300 of file Acomp.cpp.
References Comp.
Referenced by assignCNF(), assignDNF(), and setString().
std::string Mantid::Geometry::Acomp::display | ( | ) | const |
Pretty print statment.
Real pretty print out statement.
Definition at line 1513 of file Acomp.cpp.
References Comp, Intersect, Mantid::Geometry::split(), and Units.
Referenced by Mantid::Geometry::Algebra::display(), Mantid::Geometry::operator<<(), setString(), and Mantid::Geometry::Algebra::writeMCNPX().
std::string Mantid::Geometry::Acomp::displayDepth | ( | int const | dval = 0 | ) | const |
Really pretty print statment of tree.
Real pretty print out statement :-)
dval | :: parameter to keep track of depth |
Definition at line 1546 of file Acomp.cpp.
References Mantid::Geometry::split().
void Mantid::Geometry::Acomp::getAbsLiterals | ( | std::map< int, int > & | literalMap | ) | const |
Get literals (positve)
get a map of the literals and the frequency that they occur.
This does not keep the +/- part of the literals separate
literalMap | :: Map the get the frequency of the literals |
Definition at line 706 of file Acomp.cpp.
References Mantid::Geometry::split().
Referenced by getKeys().
|
private |
Creates the CNF items (ie the binary list of false statements) It forms a sum of products.
The original is not changed by the keynumbers and the DNF objects are output into the function parameters.
keyNumbers | :: index list of the CNFobj. The [bitNum]->rule/key number. |
CNFobj | :: write out the CNF object into BnId form |
0 | :: on success. |
-1 | :: on error. |
Definition at line 1125 of file Acomp.cpp.
References Mantid::Geometry::BnId::mapState().
Referenced by makeCNFobject().
|
private |
Creates the DNF items (ie the binary list of true statements) It forms a sum of products.
The original is not changed by the keynumbers and the DNF objects are output into the function parameters.
keyNumbers | :: index list of the DNFobj. The [bitNum]->rule/key number. |
DNFobj | :: write out the DNF object into BnId form |
0 | :: on success. |
-1 | :: on error. |
Definition at line 1014 of file Acomp.cpp.
References Mantid::Geometry::BnId::mapState().
Referenced by makeDNFobject().
|
private |
get the DNF parts (as Acomp)
Sets the object into parts of the DNF form then puts the object in the Parts section.
Parts,: | vector of the Parts found (Acomp units without component) |
Definition at line 1088 of file Acomp.cpp.
References addUnit(), addUnitItem(), and obj.
Referenced by algDiv(), and operator-=().
std::vector< int > Mantid::Geometry::Acomp::getKeys | ( | ) | const |
Get the key numbers in the system.
Definition at line 998 of file Acomp.cpp.
References getAbsLiterals().
void Mantid::Geometry::Acomp::getLiterals | ( | std::map< int, int > & | literalMap | ) | const |
Get literals (+/- different)
Get a map of the literals and the frequency that they occur.
This keeps + and - literals separate
literalMap | :: Map the get the frequency of the literals |
Definition at line 731 of file Acomp.cpp.
Referenced by algDiv(), Mantid::Geometry::Algebra::countLiterals(), and makeReadOnce().
int Mantid::Geometry::Acomp::isCNF | ( | ) | const |
int Mantid::Geometry::Acomp::isDNF | ( | ) | const |
|
inline |
int Mantid::Geometry::Acomp::isNull | ( | ) | const |
int Mantid::Geometry::Acomp::isSimple | ( | ) | const |
int Mantid::Geometry::Acomp::isSingle | ( | ) | const |
int Mantid::Geometry::Acomp::isTrue | ( | const std::map< int, int > & | Base | ) | const |
Determine if the rule is true.
Determines if the rule is true, given the Base state.
Base | :: map of <LiteralNumber, State> |
Definition at line 1166 of file Acomp.cpp.
References Mantid::Geometry::split().
const Acomp * Mantid::Geometry::Acomp::itemC | ( | int const | Index | ) | const |
returns a pointer to Comp (or zero)
Assessor function to get a Comp points.
Index | :: Number of Comp to aquire |
Definition at line 1464 of file Acomp.cpp.
Referenced by joinDepth().
int Mantid::Geometry::Acomp::itemN | ( | int const | Index | ) | const |
returns an integer to Units (or zero)
Assessor function to get a unit number.
Index | :: Number of Unit to aquire |
Definition at line 1452 of file Acomp.cpp.
Referenced by joinDepth().
|
private |
Search table to uplift objects.
Searchs down the tree to find if any singles exist and up-promotes them.
ColErr::ExBase | on mal-formed state |
Definition at line 1306 of file Acomp.cpp.
References Comp, Intersect, itemC(), itemN(), removeEqComp(), size(), Sort(), and Units.
Referenced by operator*=(), operator+=(), and operator-=().
int Mantid::Geometry::Acomp::logicalEqual | ( | const Acomp & | A | ) | const |
Test that the system that is logically the same:
A | :: Logical state to test |
0 | :: false |
1 | :: true |
Definition at line 626 of file Acomp.cpp.
References Mantid::Geometry::BnId::mapState().
int Mantid::Geometry::Acomp::makeCNFobject | ( | ) |
Make the object into CNF form (Product of Sums)
Sets the object to the CNF form.
0 | on failure |
Number | of CNF components |
Definition at line 1071 of file Acomp.cpp.
References assignCNF(), getCNFobject(), and makePI().
Referenced by Mantid::Geometry::Algebra::makeCNF().
int Mantid::Geometry::Acomp::makeDNFobject | ( | ) |
Make the object into DNF form (Sum of Products)
Sets the object to the DNF form.
0 | on failure |
Number | of DNF components |
Definition at line 1054 of file Acomp.cpp.
References assignDNF(), getDNFobject(), and makePI().
Referenced by algDiv(), and Mantid::Geometry::Algebra::makeDNF().
|
private |
Creates an essentual PI list (note: this is not unique).
Given the list form the EPI based on the Quine-McClusky method.
DNFobj | :: Object in DNF form |
PIform | :: List of rules in Prime Implicant form It is set on exit (to the EPI) |
Definition at line 867 of file Acomp.cpp.
References cm.
|
private |
Calculate Principal Components.
This method finds the principle implicants.
DNFobj | :: A vector of Binary ID from a true vectors of keyvalues. |
Definition at line 798 of file Acomp.cpp.
References Mantid::Geometry::BnId::setPI().
Referenced by makeCNFobject(), and makeDNFobject().
|
private |
Factorize into a read once function.
This function attempts to make the function a read one form.
Assumes that it is either DNF or CNF form
0 | if fails |
1 | if success (and sets it into the appropiate form) |
Definition at line 605 of file Acomp.cpp.
References getLiterals().
bool Mantid::Geometry::Acomp::operator!= | ( | const Acomp & | A | ) | const |
Complementary operator.
Inequality operator.
A | :: other Acomp item to compare |
Definition at line 72 of file Acomp.cpp.
References Mantid::Geometry::operator==().
This carries out the intersection operation with A.
e.g. (a+b) * (ced) == (a+b)ced
A | :: Acomp unit to intersect |
Definition at line 271 of file Acomp.cpp.
References addComp(), Comp, copySimilar(), Intersect, joinDepth(), removeEqComp(), and Units.
Referenced by operator-=().
Operator + (union addition)
A | :: Object to union with this |
Definition at line 168 of file Acomp.cpp.
References addComp(), Comp, copySimilar(), Intersect, joinDepth(), removeEqComp(), and Units.
Operator - (removal) This operation can be carried out in many ways.
It is by direct pattern subtraction followed by complementary subtraction or the remainder Complementary subtraction is by making A-B == A*B'
A | :: Object to subtract |
Definition at line 194 of file Acomp.cpp.
References addComp(), Comp, getDNFpart(), Intersect, joinDepth(), operator*=(), removeEqComp(), Sort(), and Units.
bool Mantid::Geometry::Acomp::operator< | ( | const Acomp & | A | ) | const |
Comparitor operator:: Comparies the unit list (which is already sorted) part by part.
The sort is ASSUMED. Then the Comp units (which are not) Order (low first)
A | :: Object to compare |
bool Mantid::Geometry::Acomp::operator== | ( | const Acomp & | A | ) | const |
bool Mantid::Geometry::Acomp::operator> | ( | const Acomp & | A | ) | const |
void Mantid::Geometry::Acomp::printImplicates | ( | const std::vector< BnId > & | PIform, |
const Kernel::Matrix< int > & | Grid | ||
) | const |
|
private |
Helper function :: assumes that Ln has been checked for bracket consistency.
Units are sorted after this function is returned.
Ln | :: String to processed as an intersection must not contain a toplevel + |
ExBase | on failure to pass string |
Definition at line 359 of file Acomp.cpp.
References addComp(), addUnitItem(), Mantid::Kernel::Strings::convPartNum(), and setString().
Referenced by setString().
|
private |
Helper function :: assumes that Ln has been checked for bracket consistency Units are sorted after this function is returned.
Ln | :: String to processed as a union (must contain one external +) |
ExBase | on failure to pass string |
Definition at line 421 of file Acomp.cpp.
References addComp(), and setString().
Referenced by setString().
|
private |
Remove non-unique items.
Remove identical items.
Definition at line 775 of file Acomp.cpp.
Referenced by joinDepth(), operator*=(), operator+=(), and operator-=().
void Mantid::Geometry::Acomp::setString | ( | const std::string & | Line | ) |
Processes a line of type abc'+efg.
Sort out stuff like abc'+efg given a inner bracket expand that etc.
Line | :: string of for abc'. |
Complementary object
Resort the list.
Definition at line 1378 of file Acomp.cpp.
References complement(), deleteComp(), display(), Intersect, processIntersection(), processUnion(), setString(), and Units.
Referenced by processIntersection(), processUnion(), Mantid::Geometry::Algebra::setFunction(), and setString().
std::pair< int, int > Mantid::Geometry::Acomp::size | ( | ) | const |
void Mantid::Geometry::Acomp::Sort | ( | ) |
Sort the Units+Comp items.
Function to sort the components of the lists.
Decends down the Comp Tree.
Definition at line 592 of file Acomp.cpp.
References Comp, Sort(), and Units.
Referenced by joinDepth(), operator-=(), and Sort().
void Mantid::Geometry::Acomp::writeFull | ( | std::ostream & | OXF, |
int const | Indent = 0 |
||
) | const |
|
private |
Components in list.
Definition at line 48 of file Acomp.h.
Referenced by addComp(), algDiv(), complement(), copySimilar(), deleteComp(), display(), isCNF(), isDNF(), isNull(), isSimple(), isSingle(), joinDepth(), operator*=(), operator+=(), operator-=(), removeEqComp(), size(), and Sort().
|
private |
Union/Intersection (0,1)
Definition at line 46 of file Acomp.h.
Referenced by addComp(), assignCNF(), assignDNF(), complement(), copySimilar(), display(), isCNF(), isDNF(), joinDepth(), operator*=(), operator+=(), operator-=(), and setString().
|
private |
Units in list.
Definition at line 47 of file Acomp.h.
Referenced by addComp(), addUnit(), addUnitItem(), algDiv(), assignCNF(), assignDNF(), complement(), copySimilar(), display(), isNull(), isSingle(), joinDepth(), operator*=(), operator+=(), operator-=(), removeEqComp(), setString(), size(), and Sort().