Index: /applications/robust/robustlib.cpp
===================================================================
--- /applications/robust/robustlib.cpp (revision 1171)
+++ /applications/robust/robustlib.cpp (revision 1172)
@@ -1,45 +1,2 @@
 #include "robustlib.h"
 
-point :: point(vec coordinates)
-{
-	this->coordinates = coordinates;
-	this->twinpoint   = NULL;
-}
-
-point :: point(vec coordinates, point *twinpoint)
-{
-	this->coordinates = coordinates;
-	this->twinpoint   = twinpoint;
-}
-
-segment :: segment(point *end1, point *end2)
-{
-	this->end1 = end1;
-	this->end2 = end2;
-}
-
-leaf :: leaf(vec condition, leaf *parent)                      
-{
-	this->condition  = condition;				
-	this->parent     = parent;
-}
-
-leaf :: evolvechildren(vec condition)
-{
-	this->condition = condition;
-
-
-}
-
-emlig :: emlig(leaf *tree) : eEF()
-{
-	this->tree = tree;
-}
-
-emlig :: emlig(vec [] conditions) : eEF()
-{
-	emlig::buildtree(conditions);
-}
-
-emlig :: buildtree()
-{}
Index: /applications/robust/robustlib.h
===================================================================
--- /applications/robust/robustlib.h (revision 1171)
+++ /applications/robust/robustlib.h (revision 1172)
@@ -10,54 +10,56 @@
 #include <stat/exp_family.h>
 #include <limits>
+#include <vector>
+#include <algorithm>
 	
 using namespace bdm;
 using namespace std;
 
-#include <vector>
-
-public const max_range = numeric_limits<double>::max( )/10e-5.0;
+const double max_range = numeric_limits<double>::max()/10e-5;
 
 class polyhedron;
 class vertex;
 
+/// A class describing a single polyhedron of the split complex. From a collection of such classes a Hasse diagram
+/// of the structure in the exponent of a Laplace-Inverse-Gamma density will be created.
 class polyhedron
 {
-	vector<&polyhedron> parents;
-
-	vector<&polyhedron> children;
-
-	vector<&vertex> vertices;
-
-	vector<&polyhedron> positivechildren;
-
-	vector<&polyhedron> negativechildren;
-
-	vector<&polyhedron> neutralchildren;
-
-	vector<vector<&vertex>> triangulations;
-
-	int multiplicity = 1;	
+	/// A property having a value of 1 usually, with higher value only if the polyhedron arises as a coincidence of
+	/// more than just the necessary number of conditions. For example if a newly created line passes through an already
+	/// existing point, the points multiplicity will rise by 1.
+	int multiplicity;	
 
 public:
-
+	/// A list of polyhedrons parents within the Hasse diagram.
+	vector<polyhedron*> parents;
+
+	/// A list of polyhedrons children withing the Hasse diagram.
+	vector<polyhedron*> children;
+
+	/// All the vertices of the given polyhedron
+	vector<vertex*> vertices;
+
+	/// A list used for storing children that lie in the positive region related to a certain condition
+	vector<polyhedron*> positivechildren;
+
+	/// A list used for storing children that lie in the negative region related to a certain condition
+	vector<polyhedron*> negativechildren;
+
+	/// Children intersecting the condition
+	vector<polyhedron*> neutralchildren;
+
+	/// List of triangulation polyhedrons of the polyhedron given by their relative vertices. 
+	vector<vector<vertex*>> triangulations;
+
+	/// A list of relative addresses serving for Hasse diagram construction.
 	vector<int> kids_rel_addresses;
 
+	/// Default constructor
 	polyhedron()
 	{
-		parents  = new vector<&polyhedron>();
-		children = new vector<&polyhedron>();
-		vertices = new vector<&vertex>();
-		
-		positivechildren = new vector(&polyhedron)();
-		negativechildren = new vector(&polyhedron)();
-		neutralchildren  = new vector(&polyhedron)();
-
-		triangulations = new vector<vector<&vertex>>();
-
-		kids_rel_addresses = new vector<int>();
-	
-	}
-	
-
+		multiplicity = 1;	
+	}
+	
+	/// Setter for raising multiplicity
 	void RaiseMultiplicity()
 	{
@@ -65,4 +67,5 @@
 	}
 
+	/// Setter for lowering multiplicity
 	void LowerMultiplicity()
 	{
@@ -70,8 +73,19 @@
 	}
 	
-	
-};
-
-class vertex : polyhedron
+	/// An obligatory operator, when the class is used within a C++ STL structure like a vector
+	int operator==(polyhedron polyhedron2)
+	{
+		return true;
+	}
+
+	/// An obligatory operator, when the class is used within a C++ STL structure like a vector
+	int operator<(polyhedron polyhedron2)
+	{
+		return false;
+	}
+};
+
+/// A
+class vertex : public polyhedron
 {
 	vector<double> coordinates;
@@ -83,5 +97,5 @@
 	vertex(vector<double> coordinates)
 	{
-		this.coordinates = coordinates;
+		this->coordinates = coordinates;
 	}
 
@@ -93,9 +107,13 @@
 	vector<double> get_coordinates()
 	{
-		return this.coordinates();
-	}
-}
-
-class toprow : polyhedron
+		vector<double> returned_vec;
+
+		copy(this->coordinates.begin(),this->coordinates.end(),returned_vec.begin());
+
+		return returned_vec;
+	}
+};
+
+class toprow : public polyhedron
 {
 	vector<double> condition;
@@ -105,10 +123,10 @@
 	toprow();
 
-	toprow(double condition)
-	{
-		this.condition = condition;
-	}
-
-}
+	toprow(vector<double> condition)
+	{
+		this->condition = condition;
+	}
+
+};
 
 
@@ -116,7 +134,8 @@
 
 //! Conditional(e) Multicriteria-Laplace-Inverse-Gamma distribution density
-class emlig : public eEF{
-
-	vector<vector<&polyhedron>> statistic;
+class emlig : public eEF
+{
+
+	vector<vector<polyhedron*>> statistic;
 	
 public:	
@@ -124,10 +143,10 @@
 	emlig(int number_of_parameters)
 	{
-		create_statistic(int number_of_parameters);
-	}
-
-	emlig(vector<vector<&polyhedron>> statistic)
-	{
-		this.statistic = statistic;
+		create_statistic(number_of_parameters);
+	}
+
+	emlig(vector<vector<polyhedron*>> statistic)
+	{
+		this->statistic = statistic;
 	}
 
@@ -136,98 +155,94 @@
 protected:
 
-	create_statistic(int number_of parameters)
-	{
-		vector<double> origin_coord = new vector<double>();	
-
-		origin = new vertex(origin_coord);
-
-		origin.vertices.push_back(origin);
-
-		vector<&polyhedron> origin_vec = new vector(&polyhedron)(1,);
+    void create_statistic(int number_of_parameters)
+	{
+		vector<double> origin_coord;	
+
+		vertex *origin = new vertex(origin_coord);
+
+		origin->vertices.push_back(origin);
+
+		vector<polyhedron*> origin_vec;
+
+		origin_vec.push_back(origin);
 
 		statistic.push_back(origin_vec);
 
-		for(int i=0;i++;i<number_of_parameters)
+		for(int i=0;i<number_of_parameters;i++)
 		{
-			vertex new_point1 = new vertex(origin.get_coordinates().push_back(max_range));
-			vertex new_point2 = new vertex(origin.get_coordinates().push_back(-max_range));	
-
-			vector(vector(&polyhedron)) new_statistic1 = new vector(vector(&polyhedron));
-			vector(vector(&polyhedron)) new_statistic2 = new vector(vector(&polyhedron));
+			vector<double> origin_coord1 = origin->get_coordinates();
+			vector<double> origin_coord2 = origin->get_coordinates();
+
+			origin->push_coordinate(0);
+
+			origin_coord1.push_back(max_range);
+			origin_coord2.push_back(-max_range);
+
+			vertex *new_point1 = new vertex(origin_coord1);
+			vertex *new_point2 = new vertex(origin_coord2);	
+
+			vector<vector<polyhedron*>> new_statistic1;
+			vector<vector<polyhedron*>> new_statistic2;
 
 			
-			for(int j=0;j++;j<statistic.size())
+			for(int j=0;j<statistic.size();j++)
 			{
-				vector<&polyhedron>::iterator horiz_ref = statistic[j].begin();
-
 				int element_number = 0;
 
-				do
+				for(vector<polyhedron*>::iterator horiz_ref = statistic[j].begin();horiz_ref<statistic[j].end();horiz_ref++)
 				{	
-					if(!horiz_ref.parents.empty())
-					{
-						vector<&polyhedron>::iterator end_ref = horiz_ref.parents.end();
-
-						vector<&polyhedron>::iterator parent_ref = horiz_ref.parents.begin();
-
-						do
+					if(!(*horiz_ref)->parents.empty())
+					{
+						for(vector<polyhedron*>::iterator parent_ref = (*horiz_ref)->parents.begin();parent_ref < (*horiz_ref)->parents.end();parent_ref++)
 						{
-							parent_ref.kids_rel_addresses.push_back(element_number);
-
-							parent_ref++;
-						}
-						while(parent_ref!=end_ref)
-					}
-
-					toprow current_copy1 = new toprow(new vector<int>(i+2,0));
-					toprow current_copy2 = new toprow(new vector<int>(i+2,0));
-
-					vector<&vertex>::iterator vert_ref = horiz_ref.vertices.begin();
-
-					do
-					{
-						current_copy1.vertices.push_back(vert_ref);
-						current_copy2.vertices.push_back(vert_ref);
-
-						vert_ref++;
-					}
-					while(!vert_ref!=horiz_ref.vertices.end())
-
-					current_copy1.vertices.push_back(new_point1);
-					current_copy2.vertices.push_back(new_point2);
-
-					current_copy1.triangulations.push_back(current_copy1.vertices);
-					current_copy2.triangulations.push_back(current_copy2.vertices);
-
-					vector<int>::iterator kid_ref = horiz_ref.kids_rel_addresses.begin();
-
-					if(!horiz_ref.kids_rel_addresses.empty())
-					{
-						do
+							(*parent_ref)->kids_rel_addresses.push_back(element_number);							
+						}						
+					}
+
+					vector<double> vec1(i+2,0);
+					vector<double> vec2(i+2,0);
+
+					toprow *current_copy1 = new toprow(vec1);
+					toprow *current_copy2 = new toprow(vec2);					
+
+					for(vector<vertex*>::iterator vert_ref = (*horiz_ref)->vertices.begin();vert_ref<(*horiz_ref)->vertices.end();vert_ref++)
+					{
+						current_copy1->vertices.push_back(*vert_ref);
+						current_copy2->vertices.push_back(*vert_ref);						
+					}
+					
+
+					current_copy1->vertices.push_back(new_point1);
+					current_copy2->vertices.push_back(new_point2);
+
+					current_copy1->triangulations.push_back(current_copy1->vertices);
+					current_copy2->triangulations.push_back(current_copy2->vertices);
+
+					
+
+					if(!(*horiz_ref)->kids_rel_addresses.empty())
+					{
+						for(vector<int>::iterator kid_ref = (*horiz_ref)->kids_rel_addresses.begin();kid_ref<(*horiz_ref)->kids_rel_addresses.end();kid_ref++)
 						{						
-							current_copy1.children.push_back(new_statistic1[i,kid_ref]);
-							current_copy2.children.push_back(new_statistic2[i,kid_ref]);
-
-							new_statistic1[i,kid_ref].parents.push_back(current_copy1);
-							new_statistic2[i,kid_ref].parents.push_back(current_copy2);
-
-							kid_ref++;
-
-						}
-						while(kid_ref!=horiz_ref.kids_rel_addresses.end())
-
-						horiz_ref.kids_rel_addresses.clear();
+							current_copy1->children.push_back(new_statistic1[i][(*kid_ref)]);
+							current_copy2->children.push_back(new_statistic2[i][(*kid_ref)]);
+
+							new_statistic1[i][(*kid_ref)]->parents.push_back(current_copy1);
+							new_statistic2[i][(*kid_ref)]->parents.push_back(current_copy2);
+						}						
+
+						(*horiz_ref)->kids_rel_addresses.clear();
 					}
 					else
 					{
-						current_copy1.children.push_back(new_point1);
-						current_copy2.childern.push_back(new_point2);
-
-						new_point1.parents.push_back(current_copy1);
-						new_point2.parents.push_back(current_copy2);
-					}
-
-					current_copy1.children.push_back(horiz_ref);
-					current_copy2.children.push_back(horiz_ref);
+						current_copy1->children.push_back(new_point1);
+						current_copy2->children.push_back(new_point2);
+
+						new_point1->parents.push_back(current_copy1);
+						new_point2->parents.push_back(current_copy2);
+					}
+
+					current_copy1->children.push_back(*horiz_ref);
+					current_copy2->children.push_back(*horiz_ref);
 
 					new_statistic1[i+1].push_back(current_copy1);
@@ -235,6 +250,5 @@
 					
 					element_number++;
-				}
-				while(statistic[j].end() != horiz_ptr++)
+				}				
 			}				
 			
