Index: library/bdm/estim/mixtures.h
===================================================================
--- library/bdm/estim/mixtures.h (revision 384)
+++ library/bdm/estim/mixtures.h (revision 394)
@@ -11,11 +11,11 @@
 */
 
-#ifndef ESTIM_MIXTURES_H
-#define ESTIM_MIXTURES_H
+#ifndef MIXTURES_H
+#define MIXTURES_H
 
 
 #include "../math/functions.h"
 #include "../stat/exp_family.h"
-#include "../stat/mixtures.h"
+#include "../stat/emix.h"
 
 namespace bdm {
Index: library/bdm/base/user_info.h
===================================================================
--- library/bdm/base/user_info.h (revision 392)
+++ library/bdm/base/user_info.h (revision 394)
@@ -17,92 +17,100 @@
 using namespace libconfig;
 
+namespace bdm
+{
+	
+/*!
+  \def UIREGISTER(class_name)
+  Macro for registration of class into map of UserInfos -- registered class is scriptable 
+
+  TODO napsat i to, ze UIREG musi byt v hacku..
+*/
 #ifndef BDMLIB 
-//!Macro for registration of classes into map of UserInfos -- registered class is scriptable 
-#define UIREGISTER(class_name) template<> const Particular_UI<class_name>& Particular_UI<class_name>::ui = Particular_UI<class_name>(#class_name) 
+#define UIREGISTER(class_name) template<> const ParticularUI<class_name>& ParticularUI<class_name>::ui = ParticularUI<class_name>(#class_name) 
 #else
 #define UIREGISTER(class_name)
 #endif
 
-#define ASSERT_UITYPE(S,Type) it_assert_debug(S.getType()==Setting::Type, string("Wrong setting type, see input path \"")+string(S.getPath())+string("\""))
-
-namespace bdm
-{
-	
-	//! exception used in UI::build if it fails it can be caught and handled - see merger_mex.h
+//!  macro assertting that the setting SET is of the SettingType TYPE
+#define ASSERT_UITYPE(SET,TYPE) it_assert_debug(SET.getType()==Setting::TYPE, string("Wrong setting type, see input path \"")+string(SET.getPath())+string("\""))
+
+//! exception used in UI::build if it fails it can be caught and handled - see merger_mex.h
 class UIbuildException : public std::invalid_argument {
 	public:
 		UIbuildException() : std::invalid_argument("class name") { }
 };
-	
-class UI_File : public Config
-{
-private:
-	const string file_name;
-
-public:
-	//! create empty object prepared to store Settings
-	UI_File();
-
-	//! creates object and fills it from a file
-	UI_File( const string &file_name );
-
-	//! save UserInfo to the file 
-	void save(const string &file_name);
-
-	operator Setting&();
-};
 
 /*!
-@brief This class serves to load and/or save DOMElements into/from files
-stored on a hard-disk.
-
-Firstly, you associate new RootElement instance with some filename during a time of its 
-construtcion. Then, you save some object into the new RootElement instance,
-and save it into the file this way:
+@brief This class serves to load and/or save user-infos into/from 
+configuration files stored on a hard-disk.
+
+Firstly, save some user-infos into the new UIFile instance. Then, 
+call the save method with a filename as its only argument:
+
 \code
 	CAudi audi;
-	RootElement root("cars.xml");
-	UserInfo::save( audi, root, "TT");
-	root.save();
+	UIFile file;
+	UI::save( audi, file, "TT");
+	file.save("cars.cfg");
 \endcode
 
-In the other way round, when loading object from a XML file, the appropriate code looks like this:
+In the other way round, when loading object from a configuration file, 
+the appropriate code looks like this:
+
 \code
-	RootElement root("cars.xml");
-	root.load();
-	UserInfo::build<T>(root,"TT");
+	UIFile file("cars.cfg");
+	CAudi *audi = UI::build<CAudi>(file,"TT");
 \endcode
 */
+class UIFile : public Config
+{
+public:
+	//! create empty file instance prepared to store Settings
+	UIFile();
+
+	//! creates instance and fills it from the configuration file file_name
+	UIFile( const string &file_name );
+
+	//! save all the stored Settings into the configuration file file_name
+	void save(const string &file_name);
+
+	//! this operator allows the ability of substituting Setting parameter by UIFile instance
+	operator Setting&();
+};
+
 
 
 /*!
-@brief UserInfo is an abstract is for internal purposes only. Use CompoundUserInfo<T> or Particular_UI<T> instead.
-The raison d'etre of this class is to allow pointers to its templated descendants. 
-
-Also, the main functions of the whole UserInfo library are included within this class, see
-static methods 'build' and 'save'.
-
+@brief UI is an abstract class and it is intended for internal purposes only
+
+This class exists mainly to allow pointers to its templated descendant ParticularUI<T>. Next, 
+it collects all the auxiliary functions useful to prepare some concret user-infos, see static 
+methods 'build', 'get' and 'save'. 
 */
 class UI 
 {
 private:
-	//! static class encalupsating map of names to related UserInfos
+	//! Atatic class encalupsating two maps, one mapping names to UI instances and the other mapping type_infos to class names
 	//! 
-	//! The key property of this class is that it initilaized the internal map immediately
-	//! when it is used for a first time.
-	class Mapped_UI
+	//! The key property of this class is that it initilaize the internal map immediately
+	//! when it is used for a first time. Therefore, we do not have to care about the 
+	//! order of calls to UIREGISTER macro, which operates with both these mappings.
+	class MappedUI
 	{
 	private:
-		//! Type definition of mapping which transforms type names to the related user infors
-		typedef map< const string, const UI* const > String_To_UI_Map;
-
-		//! Type definition of mapping which transforms type names to the related user infors
-		typedef map< const type_info * const, const string > Type_Info_To_String_Map;
-
-		//! immediately initialized instance of type String_To_UI_Map
-		static String_To_UI_Map& mapped_strings();
-
-		//! immediately initialized instance of type String_To_UI_Map
-		static Type_Info_To_String_Map& mapped_type_infos();
+		//! Type definition of mapping which transforms class names to the related UI instances
+		typedef map< const string, const UI* const > StringToUIMap;
+
+		//! Type definition of mapping which transforms RTTI type_infos to the related class names
+		typedef map< const type_info * const, const string > TypeInfoToStringMap;
+
+		//! immediately initialized instance of type StringToUIMap
+		static StringToUIMap& mapped_strings();
+
+		//! immediately initialized instance of type TypeInfoToStringMap
+		static TypeInfoToStringMap& mapped_type_infos();
+
+		//! method for reporting a error when an attempt to operate with an unregistered class occures
+		static void unregistered_class_error( const string &unregistered_class_name );
 
 	public:
@@ -110,38 +118,33 @@
 		static void add_class( const string &class_name, const type_info * const class_type_info, const UI* const ui );
 
-		//! search for an userinfo related to the passed key within the internal map
+		//! search for an userinfo related to the passed class name within the internal map
 		static const UI& retrieve_ui( const string &class_name );
 
-		//! search for an userinfo related to the passed key within the internal map
+		//! search for an class name related to the passed type_info within the internal map
 		static const string& retrieve_class_name( const type_info* const class_type_info );
 	};
 
-
-
-
-	//! internal method assembling a typeless instance from components obtained by the 'AssemblyComponentsFromSetting()' method
+	//! Method assembling a typeless instance, it is implemented in descendant class ParticularUI<T>
 	virtual root* new_instance() const = 0;
 	
-   	//! This methods tries to save an instance of type T (or some of its descendant types)
-	//! and build DOM tree accordingly. Then, it creates a new DOMNode named according class_name
-	//! and connecti it to the passed Setting as a new child node.
+   	//! Method switching from the \a element to its child Setting according the passed \a index, it also does all the necessary error-checking 
 	static const Setting& to_child_setting( const Setting &element, const int index );
 
+   	//! Method switching from the \a element to its child Setting according the passed \a name, it also does all the necessary error-checking 
 	static const Setting& to_child_setting( const Setting &element, const string &name );
 
-
-	//! \name Matematical Operations TODO
-	//!@{
-
-	//! This methods tries to build a new double matrix 
+	//! This methods converts a Setting into a matrix 
 	static void from_setting( mat& matrix, const Setting &element );	
-	//! This methods tries to build a new integer vector
+	//! This methods converts a Setting into an integer vector
 	static void from_setting( ivec &vector, const Setting &element );
-	// jednak kvuli pretypovani, apak taky proto, ze na string nefunguje link_expander..
+	//! This methods converts a Setting into a string
 	static void from_setting( string &str, const Setting &element );
-	//! This methods tries to build a new templated array 
-
+	//! This methods converts a Setting into a real vector
 	static void from_setting( vec &vector, const Setting &element );
-
+	//! This methods converts a Setting into a integer scalar 
+	static void from_setting( int &integer, const Setting &element );
+	//! This methods converts a Setting into a real scalar 
+	static void from_setting( double &real, const Setting &element );
+	//! This methods converts a Setting into a class T descendant
 	template<class T> static void from_setting( T* &instance, const Setting &element )
 	{			
@@ -155,6 +158,6 @@
 			ui_error( "the obligatory ""class"" identifier is missing", link.result );
 	
-		// and finally we find a UserInfo related to this type
-		const UI& related_UI = Mapped_UI::retrieve_ui( class_name );
+		// then we find a user-info related to this type
+		const UI& related_UI = MappedUI::retrieve_ui( class_name );
 		
 		root* typeless_instance = related_UI.new_instance();
@@ -168,4 +171,5 @@
 // 		catch(...)
 // 		{
+			// TODO pouzit ui_error? 
 // 			it_error ( "UI error: class " + class_name + " is not a descendant of the desired output class. Try to call the UI::build function with a different type parameter." );
 // 		}
@@ -177,11 +181,11 @@
 		catch(SettingException xcptn)
 		{
+			// TODO pouzit ui_error? 
 			it_error ( "UI error: the method " + class_name + ".from_setting(Setting&) has thrown an exception when parsing the setting " + xcptn.getPath() + ". Try to correct this method." );
 		}
 	}	
 
-
-	//! This methods tries to build a new templated array , 
-	// efektivne jen pro vect, mat a string, pro dalsi je nutne pridat from_setting metodu.. ale to asi necceme
+	//! This methods converts a Setting into a new templated array , 
+	// TODO efektivne jen pro vect, mat a string, pro dalsi je nutne pridat from_setting metodu.. ale to asi necceme
 	template<class T> static void from_setting( Array<T> &array_to_load, const Setting &element )
 	{
@@ -198,44 +202,62 @@
 	}
 
-	  //!@}
-
-
+	//! Method for reporting user-info errors related to some concrete Setting
 	static void ui_error( string message, const Setting &element );
 
 protected:
-	//! default constructor 
+	//! Default constructor for internal use only, see \sa ParticularUI<T>
 	UI( const string& class_name, const type_info * const class_type_info ) 
 	{	
-		Mapped_UI::add_class( class_name, class_type_info, this );
-	}
-
-	//! Virtual destructor for future use;
-	virtual ~UI(){};
+		MappedUI::add_class( class_name, class_type_info, this );
+	}
 
 public: 
-	//! This methods tries to build a new instance of type T (or some of its descendant types)
-	//! according to a data stored in a DOMNode named class_name within a child nodes of the passed element.
-	//! If an error occurs, it returns a NULL pointer.
-
-	// vraci true, kdyz to byl platny link, jinak false.. v pripade chyby konci it_errorem..
-	// do elementu vrati setting prislusny po rozbaleni linku, jinak ponecha beze zmeny
+
+	/*!
+	@brief This class serves to expand links used in configuration file. 
+
+	TODO - napsat co dela, a hlavne proc je to takhle implementovany.. otevreny soubor!
+
+	ABSOLUTE PATH.. 
+
+	Firstly, save some user-infos into the new UIFile instance. Then, 
+	call the save method with a filename as its only argument:
+
+	\code
+		CAudi audi;
+		UIFile file;
+		UI::save( audi, file, "TT");
+		file.save("cars.cfg");
+	\endcode
+
+	*/
 	class SettingResolver	
 	{
 	private:
-		UI_File *file;
-
-		const Setting &initialize_reference( UI_File* &file, const Setting &potential_link);
+		//! If necessary, this pointer stores an addres of an opened UIFile, else it equals NULL
+		UIFile *file;
+
+		//! This method initialize result reference, i.e., it executes the main code of SettingResolver class
+		//!
+		//! This code could be also located directly in constructor. The only reason why we made this 
+		//! method is the keyword 'const' within the declaration of result reference (TODO funguje odkaz?). Such a reference
+		//! have to be intialized before any other constructor command, exactly in the way it is implemented now.
+		const Setting &initialize_reference( UIFile* &file, const Setting &potential_link);
 
 	public:
+		//! Reference to a resolved link or to the original Setting in the case it does not contain a link
 		const Setting &result;
 
+		//! If potential_link contains a link to some other setting, it is resolved here. Anyway, the Setting reference result is prepared for use.
 		SettingResolver( const Setting &potential_link );
 		
+		//! An opened UIFile file is closed here if necessary.
 		~SettingResolver();		
 	};
 
-
-
-	//! Prototype of a UI builder. Return value is by the second argument since it type checking via \c dynamic_cast.
+	//TODO
+	//! \name Initialization of bdm::root descendant classes according the values stored in a Setting variable
+	//!@{
+	//! Return value is by the second argument since it type checking via \c dynamic_cast.
 	template<class T> static T* build( const Setting &element, const int index )
 	{
@@ -258,5 +280,8 @@
 		return instance;
 	}
-
+	//!@}
+
+	//! \name Initialization of structures according the values stored in a Setting variable - TODO VYCET?!
+	//!@{
 	//! This methods tries to build a new double matrix 
 	template<class T> static void get( T &instance, const Setting &element, const string &name )
@@ -272,4 +297,10 @@
 
 	//! This methods tries to build a new double matrix 
+	template<class T> static void get( T &instance, const Setting &element  )
+	{
+		from_setting( instance, element );
+	}
+
+	//! This methods tries to build a new double matrix 
 	template<class T> static void get( Array<T> &array_to_load, const Setting &element, const string &name )
 	{
@@ -282,4 +313,11 @@
 		from_setting( array_to_load, to_child_setting( element, index ) );
 	}
+
+	//! This methods tries to build a new double matrix 
+	template<class T> static void get( Array<T> &array_to_load, const Setting &element  )
+	{
+		from_setting( array_to_load, element );
+	}
+	//!@}
 
 	template< class T> static void save( const T * const instance, Setting &element, const string &name = "")
@@ -288,5 +326,5 @@
 									 : element.add( name, Setting::TypeGroup );		
 
-		const string &class_name = Mapped_UI::retrieve_class_name( &typeid(*instance) );
+		const string &class_name = MappedUI::retrieve_class_name( &typeid(*instance) );
 			
 		// add attribute "class" 
@@ -321,9 +359,11 @@
 	static void save( const ivec &vec, Setting &element, const string &name = "" );
 	
-	static void save( const vec &vector, Setting &element, const string &name);
-
-	private: 
+	static void save( const vec &vector, Setting &element, const string &name = "" );
 	//! This methods tries to save a double vec 
-	static void save( const string &str, Setting &element);	
+	static void save( const string &str, Setting &element, const string &name = "" );
+
+	static void save( const int &integer, Setting &element, const string &name = "" );
+
+	static void save( const double &real, Setting &element, const string &name = "" );	
 
 };
@@ -335,10 +375,10 @@
 own userinfo class prepared).
 */
-template<typename T> class Particular_UI : private UI
+template<typename T> class ParticularUI : private UI
 {
 	public:
 
 	//! default constructor, which is intentionally declared as private
-	Particular_UI<T>( const string &class_name) : UI( class_name, &typeid(T) ) 
+	ParticularUI<T>( const string &class_name) : UI( class_name, &typeid(T) ) 
 	{	cout << class_name << endl;
 	};
@@ -346,5 +386,5 @@
 	//! the only instance of this class (each type T has its own instance)
 	//! which is used as a factory for processing related UI
-	static const Particular_UI<T>& ui;	
+	static const ParticularUI<T>& ui;	
 
 	root* new_instance() const
Index: library/bdm/base/user_info.cpp
===================================================================
--- library/bdm/base/user_info.cpp (revision 392)
+++ library/bdm/base/user_info.cpp (revision 394)
@@ -15,18 +15,17 @@
 namespace bdm
 {
-///////////////////////// UI FILE /////////////////////////////////////////////
-
-UI_File::UI_File ()
-{
-    setAutoConvert( true );
-}
-
-//! loads root element from a file
-UI_File::UI_File ( const string &file_name )
+///////////////////////////// Class UIFile /////////////////////////////////////////////
+
+UIFile::UIFile()
+{
+}
+
+UIFile::UIFile ( const string &file_name )
 {
     try
     {
         readFile( file_name.c_str()  );
-	setAutoConvert( true );
+		// this flag has to be set AFTER each file load, that is why it is right here
+		setAutoConvert( true );
     }
     catch ( FileIOException f )
@@ -43,6 +42,5 @@
 
 
-//! save UserInfo to the file (typically with an XML extension)
-void UI_File::save(  const string &file_name )
+void UIFile::save(const string &file_name )
 {
     try
@@ -56,23 +54,28 @@
 }
 
-UI_File::operator Setting&()
+UIFile::operator Setting&()
 {
     return getRoot();
 }
-///////////////////////// INTERNAL MAPPED_UI /////////////////////////////////////////////
-
-UI::Mapped_UI::String_To_UI_Map& UI::Mapped_UI::mapped_strings()
-{
-    static String_To_UI_Map var;
+
+///////////////////////////// Class UI::MappedUI /////////////////////////////////////////////
+
+UI::MappedUI::StringToUIMap& UI::MappedUI::mapped_strings()
+{
+	// this way it is ensured that there is only one instance of StringTpUIMap, and 
+	// what is more, this declaration leaves its allocation/deallocation on the compiler
+    static StringToUIMap var;
     return var;
 }
 
-UI::Mapped_UI::Type_Info_To_String_Map& UI::Mapped_UI::mapped_type_infos()
-{
-    static Type_Info_To_String_Map var;
+UI::MappedUI::TypeInfoToStringMap& UI::MappedUI::mapped_type_infos()
+{
+	// this way it is ensured that there is only one instance of TypeInfoToStringMap, and 
+	// what is more, this declaration leaves its allocation/deallocation on the compiler
+    static TypeInfoToStringMap var;
     return var;
 }
 
-void UI::Mapped_UI::add_class( const string &class_name, const type_info * const class_type_info, const UI* const ui )
+void UI::MappedUI::add_class( const string &class_name, const type_info * const class_type_info, const UI* const ui )
 {
     pair< const string, const UI* const > new_pair = make_pair( class_name, ui );
@@ -81,28 +84,48 @@
 }
 
-const UI& UI::Mapped_UI::retrieve_ui( const string &class_name )
-{
-    String_To_UI_Map::const_iterator iter = mapped_strings().find( class_name );
+void UI::MappedUI::unregistered_class_error( const string &unregistered_class_name )
+{
+	stringstream msg;
+    msg << "UI error: class " + unregistered_class_name + " was not properly registered. Use the macro ""UIREGISTER([class name]);"" within your code." << endl;
+
+	if( mapped_strings().size() )
+	{
+	    StringToUIMap::const_iterator iter = mapped_strings().begin();
+		msg << "These classes are already registered: " << iter->first;
+		for(; iter != mapped_strings().end(); iter++)
+			msg << ", " << iter->first;
+		msg << "." << endl;
+	}			
+	else
+		msg << "There is not any registered class yet!" << endl;
+	
+    it_error ( msg.str() );		
+}
+
+const UI& UI::MappedUI::retrieve_ui( const string &class_name )
+{
+    StringToUIMap::const_iterator iter = mapped_strings().find( class_name );
     if ( iter == mapped_strings().end())
-		// TODO dat sem vypis seznamu registrovanych trid
-        it_error ( "UI error: class " + class_name + " was not properly registered. Use the macro ""UIREGISTER([class name]);"" within your code." );
-    return *iter->second;
-}
-
-const string& UI::Mapped_UI::retrieve_class_name( const type_info * const class_type_info )
-{
-    Type_Info_To_String_Map::const_iterator iter = mapped_type_infos().find( class_type_info );
+		unregistered_class_error( class_name );
+	    
+	return *iter->second;
+}
+
+const string& UI::MappedUI::retrieve_class_name( const type_info * const class_type_info )
+{
+    TypeInfoToStringMap::const_iterator iter = mapped_type_infos().find( class_type_info );
     if ( iter == mapped_type_infos().end())
-        it_error ( "UI error: class with RTTI name " + string(class_type_info->name()) + " was not properly registered. Use the macro ""UIREGISTER([class name]);"" within your code." );
+		unregistered_class_error( "with RTTI name " + string(class_type_info->name()) );
     return iter->second;
 }
 
-///////////////////////// INTERNAL LINK EXPANDER /////////////////////////////////////////////
-
-UI::SettingResolver::SettingResolver( const Setting &potential_link ): result( initialize_reference( file, potential_link ) )
-{
-}
-
-const Setting& UI::SettingResolver::initialize_reference(UI_File *&file, const Setting &potential_link)
+///////////////////////////// Class UI::SettingResolver /////////////////////////////////////////////
+
+UI::SettingResolver::SettingResolver( const Setting &potential_link )
+	: result( initialize_reference( file, potential_link ) )
+{
+}
+
+const Setting& UI::SettingResolver::initialize_reference(UIFile *&file, const Setting &potential_link)
 {
 	file = NULL;
@@ -118,5 +141,5 @@
     {
         string file_name = link.substr( aerobase + 1, link.length() );
-        file = new UI_File( file_name );
+        file = new UIFile( file_name );
         result = &(Setting&)(*file);
         link = link.substr( 0, aerobase );
@@ -130,5 +153,5 @@
 
     if ( !result->exists( link ) )
-        ui_error( "linked Setting was not found", potential_link );
+        ui_error( "linked setting was not found", potential_link );
 
     return (*result)[link];
@@ -140,5 +163,5 @@
 }
 
-///////////////////////// UI /////////////////////////////////////////////
+///////////////////////////// Class UI /////////////////////////////////////////////
 
 void UI::ui_error( string message, const Setting &element )
@@ -149,8 +172,44 @@
 }
 
-//! This methods - kvuli ukladani pole stringu, dat jen privatne?
-void UI::save( const string &str, Setting &element )
-{
-    Setting &set = element.add( Setting::TypeString );
+const Setting& UI::to_child_setting( const Setting &element, const int index )
+{
+    if ( !element.isList())
+        ui_error( "only TypeList elements could be indexed by integers", element );
+
+    if ( element.getLength() <= index )
+        ui_error( "there is not any child with index " + index, element );
+
+    return element[index];
+}
+
+const Setting& UI::to_child_setting( const Setting &element, const string &name )
+{
+    if ( !element.isGroup())
+        ui_error( "only TypeGroup elements could be indexed by strings", element );
+
+    if ( !element.exists( name ) )
+        ui_error( "there is not any child named """ + name, element );
+
+    return element[name];
+}
+
+void UI::save( const int &integer, Setting &element, const string &name)
+{
+    Setting &set = (name == "") ? element.add( Setting::TypeInt )
+			                    : element.add( name, Setting::TypeInt );
+    set = integer;
+}
+
+void UI::save( const double &real, Setting &element, const string &name)
+{
+    Setting &set = (name == "") ? element.add( Setting::TypeFloat )
+			                    : element.add( name, Setting::TypeFloat );
+    set = real;
+}
+
+void UI::save( const string &str, Setting &element, const string &name)
+{
+    Setting &set = (name == "") ? element.add( Setting::TypeString )
+			                    : element.add( name, Setting::TypeString );
     set = str;
 }
@@ -158,7 +217,6 @@
 void UI::save( const mat &matrix, Setting &element, const string &name)
 {
-
     Setting &set = (name == "") ? element.add( Setting::TypeList )
-                    : element.add( name, Setting::TypeList );
+			                    : element.add( name, Setting::TypeList );
 
     Setting &cols = set.add( Setting::TypeInt );
@@ -179,9 +237,6 @@
 }
 
-
-//! This methods tries to save a integer vector
 void UI::save( const ivec &vector, Setting &element, const string &name)
 {
-
     Setting &set = (name == "") ? element.add( Setting::TypeArray )
                     : element.add( name, Setting::TypeArray );
@@ -193,6 +248,4 @@
 }
 
-
-//! This methods tries to save a double vector
 void UI::save( const vec &vector, Setting &element, const string &name)
 {
@@ -205,7 +258,4 @@
     }
 }
-
-
-//! This methods tries to build a new double matrix
 
 void UI::from_setting( mat& matrix, const Setting &element )
@@ -274,5 +324,4 @@
 }
 
-//! This methods tries to build a new integer vector
 void UI::from_setting( ivec &vector, const Setting &element )
 {
@@ -301,5 +350,4 @@
 		Setting &elements = link.result[2];
         // ASSERT_UITYPE(elements[0],TypeInt); -- spolehame an autoconvert
-
 
         if ( matrix.cols() == 1 )
@@ -328,5 +376,4 @@
 }
 
-//! This methods tries to build a new double vector
 void UI::from_setting( vec &vector, const Setting &element )
 {
@@ -379,5 +426,4 @@
 }
 
-
 void UI::from_setting( string &str, const Setting &element )
 {
@@ -386,29 +432,15 @@
 }
 
-
-///////////////////////// UI FILE /////////////////////////////////////////////
-//! This methods tries to save an instance of type T (or some of its descendant types)
-//! and build DOM tree accordingly. Then, it creates a new DOMNode named according class_name
-//! and connecti it to the passed Setting as a new child node.
-const Setting& UI::to_child_setting( const Setting &element, const int index )
-{
-    if ( !element.isList())
-        ui_error( "only TypeList elements could be indexed by integers", element );
-
-    if ( element.getLength() <= index )
-        ui_error( "there is not any child with index " + index, element );
-
-    return element[index];
-}
-
-const Setting& UI::to_child_setting( const Setting &element, const string &name )
-{
-    ASSERT_UITYPE(element,TypeGroup);
-    if ( !element.exists( name ) )
-        ui_error( "there is not any child named """ + name, element );
-    return element[name];
-}
-
-
-}
-
+void UI::from_setting( int &integer, const Setting &element )
+{
+    ASSERT_UITYPE(element,TypeInt);
+    integer = element;
+}
+
+void UI::from_setting( double &real, const Setting &element )
+{
+    ASSERT_UITYPE(element,TypeFloat);
+    real = element;
+}
+
+}
Index: library/bdm/stat/emix.cpp
===================================================================
--- library/bdm/stat/emix.cpp (revision 394)
+++ library/bdm/stat/emix.cpp (revision 394)
@@ -0,0 +1,211 @@
+#include "emix.h"
+
+namespace bdm{
+
+void emix::set_parameters ( const vec &w0, const Array<epdf*> &Coms0, bool copy ) {
+	w = w0/sum ( w0 );
+	dim = Coms0(0)->dimension();
+	int i;
+	for ( i=0;i<w.length();i++ ) {
+		it_assert_debug ( dim== ( Coms0 ( i )->dimension() ),"Component sizes do not match!" );
+	}
+	if ( copy ) {
+		Coms.set_length(Coms0.length());
+		for ( i=0;i<w.length();i++ ) {it_error("Not imp...");
+			*Coms ( i ) =*Coms0 ( i );}
+		destroyComs=true;
+	}
+	else {
+		Coms = Coms0;
+		destroyComs=false;
+	}
+}
+
+vec emix::sample() const {
+	//Sample which component
+	vec cumDist = cumsum ( w );
+	double u0;
+	#pragma omp critical
+	u0 = UniRNG.sample();
+
+	int i=0;
+	while ( ( cumDist ( i ) <u0 ) && ( i< ( w.length()-1 ) ) ) {i++;}
+
+	return Coms ( i )->sample();
+}
+
+emix* emix::marginal(const RV &rv) const{
+	it_assert_debug(isnamed(), "rvs are not assigned");
+			
+	Array<epdf*> Cn(Coms.length());
+	for(int i=0;i<Coms.length();i++){Cn(i)=Coms(i)->marginal(rv);}
+	emix* tmp = new emix();
+	tmp->set_parameters(w,Cn,false);
+	tmp->ownComs();
+	return tmp;
+}
+
+mratio* emix::condition(const RV &rv) const{
+	it_assert_debug(isnamed(), "rvs are not assigned");
+	return new mratio(this,rv);
+};
+
+void egiwmix::set_parameters ( const vec &w0, const Array<egiw*> &Coms0, bool copy ) {
+	w = w0/sum ( w0 );
+	dim = Coms0(0)->dimension();
+	int i;
+	for ( i=0;i<w.length();i++ ) {
+		it_assert_debug ( dim== ( Coms0 ( i )->dimension() ),"Component sizes do not match!" );
+	}
+	if ( copy ) {
+		Coms.set_length(Coms0.length());
+		for ( i=0;i<w.length();i++ ) {it_error("Not imp...");
+			*Coms ( i ) =*Coms0 ( i );}
+		destroyComs=true;
+	}
+	else {
+		Coms = Coms0;
+		destroyComs=false;
+	}
+}
+
+vec egiwmix::sample() const {
+	//Sample which component
+	vec cumDist = cumsum ( w );
+	double u0;
+	#pragma omp critical
+	u0 = UniRNG.sample();
+
+	int i=0;
+	while ( ( cumDist ( i ) <u0 ) && ( i< ( w.length()-1 ) ) ) {i++;}
+
+	return Coms ( i )->sample();
+}
+
+vec egiwmix::mean() const {
+	int i; vec mu = zeros ( dim );
+	for ( i = 0;i < w.length();i++ ) {mu += w ( i ) * Coms ( i )->mean(); }
+	return mu;
+}
+
+vec egiwmix::variance() const {
+	// non-central moment
+	vec mom2 = zeros ( dim );
+	for ( int i = 0;i < w.length();i++ ) {
+		// pow is overloaded, we have to use another approach
+		mom2 += w ( i ) * (Coms(i)->variance() + elem_mult ( Coms(i)->mean(), Coms(i)->mean() )); 
+	}
+	// central moment
+	// pow is overloaded, we have to use another approach
+	return mom2 - elem_mult( mean(), mean() );
+}
+
+emix* egiwmix::marginal(const RV &rv) const{
+	it_assert_debug(isnamed(), "rvs are not assigned");
+			
+	Array<epdf*> Cn(Coms.length());
+	for(int i=0;i<Coms.length();i++){Cn(i)=Coms(i)->marginal(rv);}
+	emix* tmp = new emix();
+	tmp->set_parameters(w,Cn,false);
+	tmp->ownComs();
+	return tmp;
+}
+
+egiw* 	egiwmix::approx() {
+	// NB: dimx == 1 !!!
+	// The following code might look a bit spaghetti-like,
+	// consult Dedecius, K. et al.: Partial forgetting in AR models.
+
+	double sumVecCommon;			      	// common part for many terms in eq.
+	int len = w.length();				// no. of mix components	
+	int dimLS = Coms(1)->_V()._D().length() - 1; 	// dim of LS
+	vec vecNu(len);					// vector of dfms of components
+	vec vecD(len);					// vector of LS reminders of comps.
+	vec vecCommon(len);				// vector of common parts
+	mat matVecsTheta;				// matrix which rows are theta vects.
+
+	// fill in the vectors vecNu, vecD and matVecsTheta
+	for ( int i=0; i<len; i++ ) {
+		vecNu.shift_left( Coms(i)->_nu() );
+		vecD.shift_left( Coms(i)->_V()._D()(0) );
+		matVecsTheta.append_row( Coms(i)->est_theta()  );
+	}
+
+	// calculate the common parts and their sum
+	vecCommon = elem_mult ( w, elem_div(vecNu, vecD) );
+	sumVecCommon = sum(vecCommon);
+
+	// LS estimator of theta
+	vec aprEstTheta(dimLS);  aprEstTheta.zeros();
+	for ( int i=0; i<len; i++ ) {
+		aprEstTheta +=  matVecsTheta.get_row( i ) * vecCommon ( i );
+	}
+	aprEstTheta /= sumVecCommon;
+	
+	
+	// LS estimator of dfm
+	double aprNu;
+	double A = log( sumVecCommon );		// Term 'A' in equation
+
+	for ( int i=0; i<len; i++ ) {
+		A += w(i) * ( log( vecD(i) ) - psi( 0.5 * vecNu(i) ) );
+	}
+
+	aprNu = ( 1 + sqrt(1 + 2 * (A - LOG2)/3 ) ) / ( 2 * (A - LOG2) );
+
+
+	// LS reminder (term D(0,0) in C-syntax)
+	double aprD = aprNu / sumVecCommon;
+
+	// Aproximation of cov
+	// the following code is very numerically sensitive, thus
+	// we have to eliminate decompositions etc. as much as possible
+	mat aprC = zeros(dimLS, dimLS);
+	for ( int i=0; i<len; i++ ) {
+		aprC += Coms(i)->est_theta_cov().to_mat() * w(i); 
+		vec tmp = ( matVecsTheta.get_row(i) - aprEstTheta );
+		aprC += vecCommon(i) * outer_product( tmp, tmp);
+	}
+
+	// Construct GiW pdf :: BEGIN
+	ldmat aprCinv ( inv(aprC) );
+	vec D = concat( aprD, aprCinv._D() );
+	mat L = eye(dimLS+1);
+	L.set_submatrix(1,0, aprCinv._L() * aprEstTheta);
+	L.set_submatrix(1,1, aprCinv._L());
+	ldmat aprLD (L, D);
+
+	egiw* aprgiw = new egiw(1, aprLD, aprNu);
+	return aprgiw;
+};
+
+}
+// mprod::mprod ( Array<mpdf*> mFacs, bool overlap) : mpdf ( RV(), RV() ), n ( mFacs.length() ), epdfs ( n ), mpdfs ( mFacs ), rvinds ( n ), rvcinrv ( n ), irvcs_rvc ( n ) {
+// 		int i;
+// 		bool rvaddok;
+// 		// Create rv
+// 		for ( i = 0;i < n;i++ ) {
+// 			rvaddok=rv.add ( mpdfs ( i )->_rv() ); //add rv to common rvs.
+// 			// If rvaddok==false, mpdfs overlap => assert error.
+// 			it_assert_debug(rvaddok||overlap,"mprod::mprod() input mpdfs overlap in rv!");
+// 			epdfs ( i ) = & ( mpdfs ( i )->posterior() ); // add pointer to epdf
+// 		};
+// 		// Create rvc
+// 		for ( i = 0;i < n;i++ ) {
+// 			rvc.add ( mpdfs ( i )->_rvc().subt ( rv ) ); //add rv to common rvs.
+// 		};
+//
+// //		independent = true;
+// 		//test rvc of mpdfs and fill rvinds
+// 		for ( i = 0;i < n;i++ ) {
+// 			// find ith rv in common rv
+// 			rvsinrv ( i ) = mpdfs ( i )->_rv().dataind ( rv );
+// 			// find ith rvc in common rv
+// 			rvcinrv ( i ) = mpdfs ( i )->_rvc().dataind ( rv );
+// 			// find ith rvc in common rv
+// 			irvcs_rvc ( i ) = mpdfs ( i )->_rvc().dataind ( rvc );
+// 			//
+// /*			if ( rvcinrv ( i ).length() >0 ) {independent = false;}
+// 			if ( irvcs_rvc ( i ).length() >0 ) {independent = false;}*/
+// 		}
+// 	};
Index: library/bdm/stat/emix.h
===================================================================
--- library/bdm/stat/emix.h (revision 394)
+++ library/bdm/stat/emix.h (revision 394)
@@ -0,0 +1,407 @@
+/*!
+  \file
+  \brief Probability distributions for Mixtures of pdfs
+  \author Vaclav Smidl.
+
+  -----------------------------------
+  BDM++ - C++ library for Bayesian Decision Making under Uncertainty
+
+  Using IT++ for numerical operations
+  -----------------------------------
+*/
+
+#ifndef EMIX_H
+#define EMIX_H
+
+#define LOG2  0.69314718055995	
+
+#include "exp_family.h"
+
+namespace bdm {
+
+//this comes first because it is used inside emix!
+
+/*! \brief Class representing ratio of two densities
+which arise e.g. by applying the Bayes rule.
+It represents density in the form:
+\f[
+f(rv|rvc) = \frac{f(rv,rvc)}{f(rvc)}
+\f]
+where \f$ f(rvc) = \int f(rv,rvc) d\ rv \f$.
+
+In particular this type of arise by conditioning of a mixture model.
+
+At present the only supported operation is evallogcond().
+ */
+class mratio: public mpdf {
+protected:
+	//! Nominator in the form of mpdf
+	const epdf* nom;
+	//!Denominator in the form of epdf
+	epdf* den;
+	//!flag for destructor
+	bool destroynom;
+	//!datalink between conditional and nom
+	datalink_m2e dl;
+public:
+	//!Default constructor. By default, the given epdf is not copied!
+	//! It is assumed that this function will be used only temporarily.
+	mratio ( const epdf* nom0, const RV &rv, bool copy=false ) :mpdf ( ), dl ( ) {
+		// adjust rv and rvc
+		rvc = nom0->_rv().subt ( rv );
+		dimc = rvc._dsize();
+		ep = new epdf;
+		ep->set_parameters(rv._dsize());
+		ep->set_rv(rv);
+		
+		//prepare data structures
+		if ( copy ) {it_error ( "todo" ); destroynom=true; }
+		else { nom = nom0; destroynom = false; }
+		it_assert_debug ( rvc.length() >0,"Makes no sense to use this object!" );		
+		
+		// build denominator
+		den = nom->marginal ( rvc );
+		dl.set_connection(rv,rvc,nom0->_rv());
+	};
+	double evallogcond ( const vec &val, const vec &cond ) {
+		double tmp;
+		vec nom_val ( ep->dimension() + dimc );
+		dl.pushup_cond ( nom_val,val,cond );
+		tmp = exp ( nom->evallog ( nom_val ) - den->evallog ( cond ) );
+		it_assert_debug ( std::isfinite ( tmp ),"Infinite value" );
+		return tmp;
+	}
+	//! Object takes ownership of nom and will destroy it
+	void ownnom() {destroynom=true;}
+	//! Default destructor
+	~mratio() {delete den; if ( destroynom ) {delete nom;}}
+};
+
+/*!
+* \brief Mixture of epdfs
+
+Density function:
+\f[
+f(x) = \sum_{i=1}^{n} w_{i} f_i(x), \quad \sum_{i=1}^n w_i = 1.
+\f]
+where \f$f_i(x)\f$ is any density on random variable \f$x\f$, called \a component,
+
+*/
+class emix : public epdf {
+protected:
+	//! weights of the components
+	vec w;
+	//! Component (epdfs)
+	Array<epdf*> Coms;
+	//!Flag if owning Coms
+	bool destroyComs;
+public:
+	//!Default constructor
+	emix ( ) : epdf ( ) {};
+	//! Set weights \c w and components \c Coms
+	//!By default Coms are copied inside. Parameter \c copy can be set to false if Coms live externally. Use method ownComs() if Coms should be destroyed by the destructor.
+	void set_parameters ( const vec &w, const Array<epdf*> &Coms, bool copy=false );
+
+	vec sample() const;
+	vec mean() const {
+		int i; vec mu = zeros ( dim );
+		for ( i = 0;i < w.length();i++ ) {mu += w ( i ) * Coms ( i )->mean(); }
+		return mu;
+	}
+	vec variance() const {
+		//non-central moment
+		vec mom2 = zeros ( dim );
+		for ( int i = 0;i < w.length();i++ ) {mom2 += w ( i ) * (Coms(i)->variance() + pow ( Coms ( i )->mean(),2 )); }
+		//central moment
+		return mom2-pow ( mean(),2 );
+	}
+	double evallog ( const vec &val ) const {
+		int i;
+		double sum = 0.0;
+		for ( i = 0;i < w.length();i++ ) {sum += w ( i ) * exp ( Coms ( i )->evallog ( val ) );}
+		if ( sum==0.0 ) {sum=std::numeric_limits<double>::epsilon();}
+		double tmp=log ( sum );
+		it_assert_debug ( std::isfinite ( tmp ),"Infinite" );
+		return tmp;
+	};
+	vec evallog_m ( const mat &Val ) const {
+		vec x=zeros ( Val.cols() );
+		for ( int i = 0; i < w.length(); i++ ) {
+			x+= w ( i ) *exp ( Coms ( i )->evallog_m ( Val ) );
+		}
+		return log ( x );
+	};
+	//! Auxiliary function that returns pdflog for each component
+	mat evallog_M ( const mat &Val ) const {
+		mat X ( w.length(), Val.cols() );
+		for ( int i = 0; i < w.length(); i++ ) {
+			X.set_row ( i, w ( i ) *exp ( Coms ( i )->evallog_m ( Val ) ) );
+		}
+		return X;
+	};
+
+	emix* marginal ( const RV &rv ) const;
+	mratio* condition ( const RV &rv ) const; //why not mratio!!
+
+//Access methods
+	//! returns a pointer to the internal mean value. Use with Care!
+	vec& _w() {return w;}
+	virtual ~emix() {if ( destroyComs ) {for ( int i=0;i<Coms.length();i++ ) {delete Coms ( i );}}}
+	//! Auxiliary function for taking ownership of the Coms()
+	void ownComs() {destroyComs=true;}
+
+	//!access function
+	epdf* _Coms ( int i ) {return Coms ( i );}
+	void set_rv(const RV &rv){
+		epdf::set_rv(rv);
+		for(int i=0;i<Coms.length();i++){Coms(i)->set_rv(rv);}
+	}
+};
+
+
+/*!
+* \brief Mixture of egiws
+
+*/
+class egiwmix : public egiw {
+protected:
+	//! weights of the components
+	vec w;
+	//! Component (epdfs)
+	Array<egiw*> Coms;
+	//!Flag if owning Coms
+	bool destroyComs;
+public:
+	//!Default constructor
+	egiwmix ( ) : egiw ( ) {};
+
+	//! Set weights \c w and components \c Coms
+	//!By default Coms are copied inside. Parameter \c copy can be set to false if Coms live externally. Use method ownComs() if Coms should be destroyed by the destructor.
+	void set_parameters ( const vec &w, const Array<egiw*> &Coms, bool copy=false );
+
+	//!return expected value
+	vec mean() const;
+
+	//!return a sample from the density
+	vec sample() const;
+
+	//!return the expected variance
+ 	vec variance() const;
+
+	// TODO!!! Defined to follow ANSI and/or for future development
+	void mean_mat ( mat &M, mat&R ) const {};
+	double evallog_nn ( const vec &val ) const {return 0;};
+	double lognc () const {return 0;};
+	emix* marginal ( const RV &rv ) const;
+
+//Access methods
+	//! returns a pointer to the internal mean value. Use with Care!
+	vec& _w() {return w;}
+	virtual ~egiwmix() {if ( destroyComs ) {for ( int i=0;i<Coms.length();i++ ) {delete Coms ( i );}}}
+	//! Auxiliary function for taking ownership of the Coms()
+	void ownComs() {destroyComs=true;}
+
+	//!access function
+	egiw* _Coms ( int i ) {return Coms ( i );}
+
+	void set_rv(const RV &rv){
+		egiw::set_rv(rv);
+		for(int i=0;i<Coms.length();i++){Coms(i)->set_rv(rv);}
+	}
+
+	//! Approximation of a GiW mix by a single GiW pdf
+	egiw* approx();
+};
+
+/*! \brief Chain rule decomposition of epdf
+
+Probability density in the form of Chain-rule decomposition:
+\[
+f(x_1,x_2,x_3) = f(x_1|x_2,x_3)f(x_2,x_3)f(x_3)
+\]
+Note that
+*/
+class mprod: public compositepdf, public mpdf {
+protected:
+	//! pointers to epdfs - shortcut to mpdfs().posterior()
+	Array<epdf*> epdfs;
+	//! Data link for each mpdfs
+	Array<datalink_m2m*> dls;
+	//! dummy ep
+	epdf dummy;
+public:
+	/*!\brief Constructor from list of mFacs,
+	*/
+	mprod (){};
+	mprod (Array<mpdf*> mFacs ){set_elements( mFacs );};
+	void set_elements(Array<mpdf*> mFacs ) {
+		
+		set_elements(mFacs);
+		
+		ep=&dummy;
+		RV rv=getrv ( true );
+		set_rv ( rv );dummy.set_parameters ( rv._dsize() );
+		setrvc ( ep->_rv(),rvc );
+		// rv and rvc established = > we can link them with mpdfs
+		for ( int i = 0;i < mpdfs.length(); i++ ) {
+			dls ( i ) = new datalink_m2m;
+			dls(i)->set_connection( mpdfs ( i )->_rv(), mpdfs ( i )->_rvc(), _rv(), _rvc() );
+		}
+
+		for ( int i=0; i<mpdfs.length(); i++ ) {
+			epdfs ( i ) =& ( mpdfs ( i )->_epdf() );
+		}
+	};
+
+	double evallogcond ( const vec &val, const vec &cond ) {
+		int i;
+		double res = 0.0;
+		for ( i = mpdfs.length() - 1;i >= 0;i-- ) {
+			/*			if ( mpdfs(i)->_rvc().count() >0) {
+							mpdfs ( i )->condition ( dls ( i )->get_cond ( val,cond ) );
+						}
+						// add logarithms
+						res += epdfs ( i )->evallog ( dls ( i )->pushdown ( val ) );*/
+			res += mpdfs ( i )->evallogcond (
+			           dls ( i )->pushdown ( val ),
+			           dls ( i )->get_cond ( val, cond )
+			       );
+		}
+		return res;
+	}
+	//TODO smarter...
+	vec samplecond ( const vec &cond ) {
+		//! Ugly hack to help to discover if mpfs are not in proper order. Correct solution = check that explicitely.
+		vec smp= std::numeric_limits<double>::infinity() * ones ( ep->dimension() );
+		vec smpi;
+		// Hard assumption here!!! We are going backwards, to assure that samples that are needed from smp are already generated!
+		for ( int i = ( mpdfs.length() - 1 );i >= 0;i-- ) {
+			if ( mpdfs ( i )->dimensionc() ) {
+				mpdfs ( i )->condition ( dls ( i )->get_cond ( smp ,cond ) ); // smp is val here!!
+			}
+			smpi = epdfs ( i )->sample();
+			// copy contribution of this pdf into smp
+			dls ( i )->pushup ( smp, smpi );
+			// add ith likelihood contribution
+		}
+		return smp;
+	}
+	mat samplecond ( const vec &cond,  int N ) {
+		mat Smp ( dimension(),N );
+		for ( int i=0;i<N;i++ ) {Smp.set_col ( i,samplecond ( cond ) );}
+		return Smp;
+	}
+
+	~mprod() {};
+};
+
+//! Product of independent epdfs. For dependent pdfs, use mprod.
+class eprod: public epdf {
+protected:
+	//! Components (epdfs)
+	Array<const epdf*> epdfs;
+	//! Array of indeces
+	Array<datalink*> dls;
+public:
+	eprod () : epdfs ( 0 ),dls ( 0 ) {};
+	void set_parameters ( const Array<const epdf*> &epdfs0, bool named=true ) {
+		epdfs=epdfs0;//.set_length ( epdfs0.length() );
+		dls.set_length ( epdfs.length() );
+
+		bool independent=true;
+		if ( named ) {
+			for ( int i=0;i<epdfs.length();i++ ) {
+				independent=rv.add ( epdfs ( i )->_rv() );
+				it_assert_debug ( independent==true, "eprod:: given components are not independent." );
+			}
+			dim=rv._dsize();
+		}
+		else {
+			dim =0; for ( int i=0;i<epdfs.length();i++ ) {
+				dim+=epdfs ( i )->dimension();
+			}
+		}
+		//
+		int cumdim=0;
+		int dimi=0;
+		int i;
+		for ( i=0;i<epdfs.length();i++ ) {
+			dls ( i ) = new datalink;
+			if ( named ) {dls ( i )->set_connection ( epdfs ( i )->_rv() , rv );}
+			else {
+				dimi = epdfs ( i )->dimension();
+				dls ( i )->set_connection ( dimi, dim, linspace ( cumdim,cumdim+dimi-1 ) );
+				cumdim+=dimi;
+			}
+		}
+	}
+
+	vec mean() const {
+		vec tmp ( dim );
+		for ( int i=0;i<epdfs.length();i++ ) {
+			vec pom = epdfs ( i )->mean();
+			dls ( i )->pushup ( tmp, pom );
+		}
+		return tmp;
+	}
+	vec variance() const {
+		vec tmp ( dim ); //second moment
+		for ( int i=0;i<epdfs.length();i++ ) {
+			vec pom = epdfs ( i )->mean();
+			dls ( i )->pushup ( tmp, pow ( pom,2 ) );
+		}
+		return tmp-pow ( mean(),2 );
+	}
+	vec sample() const {
+		vec tmp ( dim );
+		for ( int i=0;i<epdfs.length();i++ ) {
+			vec pom = epdfs ( i )->sample();
+			dls ( i )->pushup ( tmp, pom );
+		}
+		return tmp;
+	}
+	double evallog ( const vec &val ) const {
+		double tmp=0;
+		for ( int i=0;i<epdfs.length();i++ ) {
+			tmp+=epdfs ( i )->evallog ( dls ( i )->pushdown ( val ) );
+		}
+		it_assert_debug ( std::isfinite ( tmp ),"Infinite" );
+		return tmp;
+	}
+	//!access function
+	const epdf* operator () ( int i ) const {it_assert_debug ( i<epdfs.length(),"wrong index" );return epdfs ( i );}
+
+	//!Destructor
+	~eprod() {for ( int i=0;i<epdfs.length();i++ ) {delete dls ( i );}}
+};
+
+
+/*! \brief Mixture of mpdfs with constant weights, all mpdfs are of equal type
+
+*/
+class mmix : public mpdf {
+protected:
+	//! Component (epdfs)
+	Array<mpdf*> Coms;
+	//!Internal epdf
+	emix Epdf;
+public:
+	//!Default constructor
+	mmix ( ) : mpdf ( ), Epdf () {ep = &Epdf;};
+	//! Set weights \c w and components \c R
+	void set_parameters ( const vec &w, const Array<mpdf*> &Coms ) {
+		Array<epdf*> Eps ( Coms.length() );
+
+		for ( int i = 0;i < Coms.length();i++ ) {
+			Eps ( i ) = & ( Coms ( i )->_epdf() );
+		}
+		Epdf.set_parameters ( w, Eps );
+	};
+
+	void condition ( const vec &cond ) {
+		for ( int i = 0;i < Coms.length();i++ ) {Coms ( i )->condition ( cond );}
+	};
+};
+
+}
+#endif //MX_H
Index: library/bdm/stat/mixtures.cpp
===================================================================
--- library/bdm/stat/mixtures.cpp (revision 384)
+++  (revision )
@@ -1,211 +1,0 @@
-#include "mixtures.h"
-
-namespace bdm{
-
-void emix::set_parameters ( const vec &w0, const Array<epdf*> &Coms0, bool copy ) {
-	w = w0/sum ( w0 );
-	dim = Coms0(0)->dimension();
-	int i;
-	for ( i=0;i<w.length();i++ ) {
-		it_assert_debug ( dim== ( Coms0 ( i )->dimension() ),"Component sizes do not match!" );
-	}
-	if ( copy ) {
-		Coms.set_length(Coms0.length());
-		for ( i=0;i<w.length();i++ ) {it_error("Not imp...");
-			*Coms ( i ) =*Coms0 ( i );}
-		destroyComs=true;
-	}
-	else {
-		Coms = Coms0;
-		destroyComs=false;
-	}
-}
-
-vec emix::sample() const {
-	//Sample which component
-	vec cumDist = cumsum ( w );
-	double u0;
-	#pragma omp critical
-	u0 = UniRNG.sample();
-
-	int i=0;
-	while ( ( cumDist ( i ) <u0 ) && ( i< ( w.length()-1 ) ) ) {i++;}
-
-	return Coms ( i )->sample();
-}
-
-emix* emix::marginal(const RV &rv) const{
-	it_assert_debug(isnamed(), "rvs are not assigned");
-			
-	Array<epdf*> Cn(Coms.length());
-	for(int i=0;i<Coms.length();i++){Cn(i)=Coms(i)->marginal(rv);}
-	emix* tmp = new emix();
-	tmp->set_parameters(w,Cn,false);
-	tmp->ownComs();
-	return tmp;
-}
-
-mratio* emix::condition(const RV &rv) const{
-	it_assert_debug(isnamed(), "rvs are not assigned");
-	return new mratio(this,rv);
-};
-
-void egiwmix::set_parameters ( const vec &w0, const Array<egiw*> &Coms0, bool copy ) {
-	w = w0/sum ( w0 );
-	dim = Coms0(0)->dimension();
-	int i;
-	for ( i=0;i<w.length();i++ ) {
-		it_assert_debug ( dim== ( Coms0 ( i )->dimension() ),"Component sizes do not match!" );
-	}
-	if ( copy ) {
-		Coms.set_length(Coms0.length());
-		for ( i=0;i<w.length();i++ ) {it_error("Not imp...");
-			*Coms ( i ) =*Coms0 ( i );}
-		destroyComs=true;
-	}
-	else {
-		Coms = Coms0;
-		destroyComs=false;
-	}
-}
-
-vec egiwmix::sample() const {
-	//Sample which component
-	vec cumDist = cumsum ( w );
-	double u0;
-	#pragma omp critical
-	u0 = UniRNG.sample();
-
-	int i=0;
-	while ( ( cumDist ( i ) <u0 ) && ( i< ( w.length()-1 ) ) ) {i++;}
-
-	return Coms ( i )->sample();
-}
-
-vec egiwmix::mean() const {
-	int i; vec mu = zeros ( dim );
-	for ( i = 0;i < w.length();i++ ) {mu += w ( i ) * Coms ( i )->mean(); }
-	return mu;
-}
-
-vec egiwmix::variance() const {
-	// non-central moment
-	vec mom2 = zeros ( dim );
-	for ( int i = 0;i < w.length();i++ ) {
-		// pow is overloaded, we have to use another approach
-		mom2 += w ( i ) * (Coms(i)->variance() + elem_mult ( Coms(i)->mean(), Coms(i)->mean() )); 
-	}
-	// central moment
-	// pow is overloaded, we have to use another approach
-	return mom2 - elem_mult( mean(), mean() );
-}
-
-emix* egiwmix::marginal(const RV &rv) const{
-	it_assert_debug(isnamed(), "rvs are not assigned");
-			
-	Array<epdf*> Cn(Coms.length());
-	for(int i=0;i<Coms.length();i++){Cn(i)=Coms(i)->marginal(rv);}
-	emix* tmp = new emix();
-	tmp->set_parameters(w,Cn,false);
-	tmp->ownComs();
-	return tmp;
-}
-
-egiw* 	egiwmix::approx() {
-	// NB: dimx == 1 !!!
-	// The following code might look a bit spaghetti-like,
-	// consult Dedecius, K. et al.: Partial forgetting in AR models.
-
-	double sumVecCommon;			      	// common part for many terms in eq.
-	int len = w.length();				// no. of mix components	
-	int dimLS = Coms(1)->_V()._D().length() - 1; 	// dim of LS
-	vec vecNu(len);					// vector of dfms of components
-	vec vecD(len);					// vector of LS reminders of comps.
-	vec vecCommon(len);				// vector of common parts
-	mat matVecsTheta;				// matrix which rows are theta vects.
-
-	// fill in the vectors vecNu, vecD and matVecsTheta
-	for ( int i=0; i<len; i++ ) {
-		vecNu.shift_left( Coms(i)->_nu() );
-		vecD.shift_left( Coms(i)->_V()._D()(0) );
-		matVecsTheta.append_row( Coms(i)->est_theta()  );
-	}
-
-	// calculate the common parts and their sum
-	vecCommon = elem_mult ( w, elem_div(vecNu, vecD) );
-	sumVecCommon = sum(vecCommon);
-
-	// LS estimator of theta
-	vec aprEstTheta(dimLS);  aprEstTheta.zeros();
-	for ( int i=0; i<len; i++ ) {
-		aprEstTheta +=  matVecsTheta.get_row( i ) * vecCommon ( i );
-	}
-	aprEstTheta /= sumVecCommon;
-	
-	
-	// LS estimator of dfm
-	double aprNu;
-	double A = log( sumVecCommon );		// Term 'A' in equation
-
-	for ( int i=0; i<len; i++ ) {
-		A += w(i) * ( log( vecD(i) ) - psi( 0.5 * vecNu(i) ) );
-	}
-
-	aprNu = ( 1 + sqrt(1 + 2 * (A - LOG2)/3 ) ) / ( 2 * (A - LOG2) );
-
-
-	// LS reminder (term D(0,0) in C-syntax)
-	double aprD = aprNu / sumVecCommon;
-
-	// Aproximation of cov
-	// the following code is very numerically sensitive, thus
-	// we have to eliminate decompositions etc. as much as possible
-	mat aprC = zeros(dimLS, dimLS);
-	for ( int i=0; i<len; i++ ) {
-		aprC += Coms(i)->est_theta_cov().to_mat() * w(i); 
-		vec tmp = ( matVecsTheta.get_row(i) - aprEstTheta );
-		aprC += vecCommon(i) * outer_product( tmp, tmp);
-	}
-
-	// Construct GiW pdf :: BEGIN
-	ldmat aprCinv ( inv(aprC) );
-	vec D = concat( aprD, aprCinv._D() );
-	mat L = eye(dimLS+1);
-	L.set_submatrix(1,0, aprCinv._L() * aprEstTheta);
-	L.set_submatrix(1,1, aprCinv._L());
-	ldmat aprLD (L, D);
-
-	egiw* aprgiw = new egiw(1, aprLD, aprNu);
-	return aprgiw;
-};
-
-}
-// mprod::mprod ( Array<mpdf*> mFacs, bool overlap) : mpdf ( RV(), RV() ), n ( mFacs.length() ), epdfs ( n ), mpdfs ( mFacs ), rvinds ( n ), rvcinrv ( n ), irvcs_rvc ( n ) {
-// 		int i;
-// 		bool rvaddok;
-// 		// Create rv
-// 		for ( i = 0;i < n;i++ ) {
-// 			rvaddok=rv.add ( mpdfs ( i )->_rv() ); //add rv to common rvs.
-// 			// If rvaddok==false, mpdfs overlap => assert error.
-// 			it_assert_debug(rvaddok||overlap,"mprod::mprod() input mpdfs overlap in rv!");
-// 			epdfs ( i ) = & ( mpdfs ( i )->posterior() ); // add pointer to epdf
-// 		};
-// 		// Create rvc
-// 		for ( i = 0;i < n;i++ ) {
-// 			rvc.add ( mpdfs ( i )->_rvc().subt ( rv ) ); //add rv to common rvs.
-// 		};
-//
-// //		independent = true;
-// 		//test rvc of mpdfs and fill rvinds
-// 		for ( i = 0;i < n;i++ ) {
-// 			// find ith rv in common rv
-// 			rvsinrv ( i ) = mpdfs ( i )->_rv().dataind ( rv );
-// 			// find ith rvc in common rv
-// 			rvcinrv ( i ) = mpdfs ( i )->_rvc().dataind ( rv );
-// 			// find ith rvc in common rv
-// 			irvcs_rvc ( i ) = mpdfs ( i )->_rvc().dataind ( rvc );
-// 			//
-// /*			if ( rvcinrv ( i ).length() >0 ) {independent = false;}
-// 			if ( irvcs_rvc ( i ).length() >0 ) {independent = false;}*/
-// 		}
-// 	};
Index: library/bdm/stat/mixtures.h
===================================================================
--- library/bdm/stat/mixtures.h (revision 384)
+++  (revision )
@@ -1,407 +1,0 @@
-/*!
-  \file
-  \brief Probability distributions for Mixtures of pdfs
-  \author Vaclav Smidl.
-
-  -----------------------------------
-  BDM++ - C++ library for Bayesian Decision Making under Uncertainty
-
-  Using IT++ for numerical operations
-  -----------------------------------
-*/
-
-#ifndef STAT_MIXTURES_H
-#define STAT_MIXTURES_H
-
-#define LOG2  0.69314718055995	
-
-#include "exp_family.h"
-
-namespace bdm {
-
-//this comes first because it is used inside emix!
-
-/*! \brief Class representing ratio of two densities
-which arise e.g. by applying the Bayes rule.
-It represents density in the form:
-\f[
-f(rv|rvc) = \frac{f(rv,rvc)}{f(rvc)}
-\f]
-where \f$ f(rvc) = \int f(rv,rvc) d\ rv \f$.
-
-In particular this type of arise by conditioning of a mixture model.
-
-At present the only supported operation is evallogcond().
- */
-class mratio: public mpdf {
-protected:
-	//! Nominator in the form of mpdf
-	const epdf* nom;
-	//!Denominator in the form of epdf
-	epdf* den;
-	//!flag for destructor
-	bool destroynom;
-	//!datalink between conditional and nom
-	datalink_m2e dl;
-public:
-	//!Default constructor. By default, the given epdf is not copied!
-	//! It is assumed that this function will be used only temporarily.
-	mratio ( const epdf* nom0, const RV &rv, bool copy=false ) :mpdf ( ), dl ( ) {
-		// adjust rv and rvc
-		rvc = nom0->_rv().subt ( rv );
-		dimc = rvc._dsize();
-		ep = new epdf;
-		ep->set_parameters(rv._dsize());
-		ep->set_rv(rv);
-		
-		//prepare data structures
-		if ( copy ) {it_error ( "todo" ); destroynom=true; }
-		else { nom = nom0; destroynom = false; }
-		it_assert_debug ( rvc.length() >0,"Makes no sense to use this object!" );		
-		
-		// build denominator
-		den = nom->marginal ( rvc );
-		dl.set_connection(rv,rvc,nom0->_rv());
-	};
-	double evallogcond ( const vec &val, const vec &cond ) {
-		double tmp;
-		vec nom_val ( ep->dimension() + dimc );
-		dl.pushup_cond ( nom_val,val,cond );
-		tmp = exp ( nom->evallog ( nom_val ) - den->evallog ( cond ) );
-		it_assert_debug ( std::isfinite ( tmp ),"Infinite value" );
-		return tmp;
-	}
-	//! Object takes ownership of nom and will destroy it
-	void ownnom() {destroynom=true;}
-	//! Default destructor
-	~mratio() {delete den; if ( destroynom ) {delete nom;}}
-};
-
-/*!
-* \brief Mixture of epdfs
-
-Density function:
-\f[
-f(x) = \sum_{i=1}^{n} w_{i} f_i(x), \quad \sum_{i=1}^n w_i = 1.
-\f]
-where \f$f_i(x)\f$ is any density on random variable \f$x\f$, called \a component,
-
-*/
-class emix : public epdf {
-protected:
-	//! weights of the components
-	vec w;
-	//! Component (epdfs)
-	Array<epdf*> Coms;
-	//!Flag if owning Coms
-	bool destroyComs;
-public:
-	//!Default constructor
-	emix ( ) : epdf ( ) {};
-	//! Set weights \c w and components \c Coms
-	//!By default Coms are copied inside. Parameter \c copy can be set to false if Coms live externally. Use method ownComs() if Coms should be destroyed by the destructor.
-	void set_parameters ( const vec &w, const Array<epdf*> &Coms, bool copy=false );
-
-	vec sample() const;
-	vec mean() const {
-		int i; vec mu = zeros ( dim );
-		for ( i = 0;i < w.length();i++ ) {mu += w ( i ) * Coms ( i )->mean(); }
-		return mu;
-	}
-	vec variance() const {
-		//non-central moment
-		vec mom2 = zeros ( dim );
-		for ( int i = 0;i < w.length();i++ ) {mom2 += w ( i ) * (Coms(i)->variance() + pow ( Coms ( i )->mean(),2 )); }
-		//central moment
-		return mom2-pow ( mean(),2 );
-	}
-	double evallog ( const vec &val ) const {
-		int i;
-		double sum = 0.0;
-		for ( i = 0;i < w.length();i++ ) {sum += w ( i ) * exp ( Coms ( i )->evallog ( val ) );}
-		if ( sum==0.0 ) {sum=std::numeric_limits<double>::epsilon();}
-		double tmp=log ( sum );
-		it_assert_debug ( std::isfinite ( tmp ),"Infinite" );
-		return tmp;
-	};
-	vec evallog_m ( const mat &Val ) const {
-		vec x=zeros ( Val.cols() );
-		for ( int i = 0; i < w.length(); i++ ) {
-			x+= w ( i ) *exp ( Coms ( i )->evallog_m ( Val ) );
-		}
-		return log ( x );
-	};
-	//! Auxiliary function that returns pdflog for each component
-	mat evallog_M ( const mat &Val ) const {
-		mat X ( w.length(), Val.cols() );
-		for ( int i = 0; i < w.length(); i++ ) {
-			X.set_row ( i, w ( i ) *exp ( Coms ( i )->evallog_m ( Val ) ) );
-		}
-		return X;
-	};
-
-	emix* marginal ( const RV &rv ) const;
-	mratio* condition ( const RV &rv ) const; //why not mratio!!
-
-//Access methods
-	//! returns a pointer to the internal mean value. Use with Care!
-	vec& _w() {return w;}
-	virtual ~emix() {if ( destroyComs ) {for ( int i=0;i<Coms.length();i++ ) {delete Coms ( i );}}}
-	//! Auxiliary function for taking ownership of the Coms()
-	void ownComs() {destroyComs=true;}
-
-	//!access function
-	epdf* _Coms ( int i ) {return Coms ( i );}
-	void set_rv(const RV &rv){
-		epdf::set_rv(rv);
-		for(int i=0;i<Coms.length();i++){Coms(i)->set_rv(rv);}
-	}
-};
-
-
-/*!
-* \brief Mixture of egiws
-
-*/
-class egiwmix : public egiw {
-protected:
-	//! weights of the components
-	vec w;
-	//! Component (epdfs)
-	Array<egiw*> Coms;
-	//!Flag if owning Coms
-	bool destroyComs;
-public:
-	//!Default constructor
-	egiwmix ( ) : egiw ( ) {};
-
-	//! Set weights \c w and components \c Coms
-	//!By default Coms are copied inside. Parameter \c copy can be set to false if Coms live externally. Use method ownComs() if Coms should be destroyed by the destructor.
-	void set_parameters ( const vec &w, const Array<egiw*> &Coms, bool copy=false );
-
-	//!return expected value
-	vec mean() const;
-
-	//!return a sample from the density
-	vec sample() const;
-
-	//!return the expected variance
- 	vec variance() const;
-
-	// TODO!!! Defined to follow ANSI and/or for future development
-	void mean_mat ( mat &M, mat&R ) const {};
-	double evallog_nn ( const vec &val ) const {return 0;};
-	double lognc () const {return 0;};
-	emix* marginal ( const RV &rv ) const;
-
-//Access methods
-	//! returns a pointer to the internal mean value. Use with Care!
-	vec& _w() {return w;}
-	virtual ~egiwmix() {if ( destroyComs ) {for ( int i=0;i<Coms.length();i++ ) {delete Coms ( i );}}}
-	//! Auxiliary function for taking ownership of the Coms()
-	void ownComs() {destroyComs=true;}
-
-	//!access function
-	egiw* _Coms ( int i ) {return Coms ( i );}
-
-	void set_rv(const RV &rv){
-		egiw::set_rv(rv);
-		for(int i=0;i<Coms.length();i++){Coms(i)->set_rv(rv);}
-	}
-
-	//! Approximation of a GiW mix by a single GiW pdf
-	egiw* approx();
-};
-
-/*! \brief Chain rule decomposition of epdf
-
-Probability density in the form of Chain-rule decomposition:
-\[
-f(x_1,x_2,x_3) = f(x_1|x_2,x_3)f(x_2,x_3)f(x_3)
-\]
-Note that
-*/
-class mprod: public compositepdf, public mpdf {
-protected:
-	//! pointers to epdfs - shortcut to mpdfs().posterior()
-	Array<epdf*> epdfs;
-	//! Data link for each mpdfs
-	Array<datalink_m2m*> dls;
-	//! dummy ep
-	epdf dummy;
-public:
-	/*!\brief Constructor from list of mFacs,
-	*/
-	mprod (){};
-	mprod (Array<mpdf*> mFacs ){set_elements( mFacs );};
-	void set_elements(Array<mpdf*> mFacs ) {
-		
-		set_elements(mFacs);
-		
-		ep=&dummy;
-		RV rv=getrv ( true );
-		set_rv ( rv );dummy.set_parameters ( rv._dsize() );
-		setrvc ( ep->_rv(),rvc );
-		// rv and rvc established = > we can link them with mpdfs
-		for ( int i = 0;i < mpdfs.length(); i++ ) {
-			dls ( i ) = new datalink_m2m;
-			dls(i)->set_connection( mpdfs ( i )->_rv(), mpdfs ( i )->_rvc(), _rv(), _rvc() );
-		}
-
-		for ( int i=0; i<mpdfs.length(); i++ ) {
-			epdfs ( i ) =& ( mpdfs ( i )->_epdf() );
-		}
-	};
-
-	double evallogcond ( const vec &val, const vec &cond ) {
-		int i;
-		double res = 0.0;
-		for ( i = mpdfs.length() - 1;i >= 0;i-- ) {
-			/*			if ( mpdfs(i)->_rvc().count() >0) {
-							mpdfs ( i )->condition ( dls ( i )->get_cond ( val,cond ) );
-						}
-						// add logarithms
-						res += epdfs ( i )->evallog ( dls ( i )->pushdown ( val ) );*/
-			res += mpdfs ( i )->evallogcond (
-			           dls ( i )->pushdown ( val ),
-			           dls ( i )->get_cond ( val, cond )
-			       );
-		}
-		return res;
-	}
-	//TODO smarter...
-	vec samplecond ( const vec &cond ) {
-		//! Ugly hack to help to discover if mpfs are not in proper order. Correct solution = check that explicitely.
-		vec smp= std::numeric_limits<double>::infinity() * ones ( ep->dimension() );
-		vec smpi;
-		// Hard assumption here!!! We are going backwards, to assure that samples that are needed from smp are already generated!
-		for ( int i = ( mpdfs.length() - 1 );i >= 0;i-- ) {
-			if ( mpdfs ( i )->dimensionc() ) {
-				mpdfs ( i )->condition ( dls ( i )->get_cond ( smp ,cond ) ); // smp is val here!!
-			}
-			smpi = epdfs ( i )->sample();
-			// copy contribution of this pdf into smp
-			dls ( i )->pushup ( smp, smpi );
-			// add ith likelihood contribution
-		}
-		return smp;
-	}
-	mat samplecond ( const vec &cond,  int N ) {
-		mat Smp ( dimension(),N );
-		for ( int i=0;i<N;i++ ) {Smp.set_col ( i,samplecond ( cond ) );}
-		return Smp;
-	}
-
-	~mprod() {};
-};
-
-//! Product of independent epdfs. For dependent pdfs, use mprod.
-class eprod: public epdf {
-protected:
-	//! Components (epdfs)
-	Array<const epdf*> epdfs;
-	//! Array of indeces
-	Array<datalink*> dls;
-public:
-	eprod () : epdfs ( 0 ),dls ( 0 ) {};
-	void set_parameters ( const Array<const epdf*> &epdfs0, bool named=true ) {
-		epdfs=epdfs0;//.set_length ( epdfs0.length() );
-		dls.set_length ( epdfs.length() );
-
-		bool independent=true;
-		if ( named ) {
-			for ( int i=0;i<epdfs.length();i++ ) {
-				independent=rv.add ( epdfs ( i )->_rv() );
-				it_assert_debug ( independent==true, "eprod:: given components are not independent." );
-			}
-			dim=rv._dsize();
-		}
-		else {
-			dim =0; for ( int i=0;i<epdfs.length();i++ ) {
-				dim+=epdfs ( i )->dimension();
-			}
-		}
-		//
-		int cumdim=0;
-		int dimi=0;
-		int i;
-		for ( i=0;i<epdfs.length();i++ ) {
-			dls ( i ) = new datalink;
-			if ( named ) {dls ( i )->set_connection ( epdfs ( i )->_rv() , rv );}
-			else {
-				dimi = epdfs ( i )->dimension();
-				dls ( i )->set_connection ( dimi, dim, linspace ( cumdim,cumdim+dimi-1 ) );
-				cumdim+=dimi;
-			}
-		}
-	}
-
-	vec mean() const {
-		vec tmp ( dim );
-		for ( int i=0;i<epdfs.length();i++ ) {
-			vec pom = epdfs ( i )->mean();
-			dls ( i )->pushup ( tmp, pom );
-		}
-		return tmp;
-	}
-	vec variance() const {
-		vec tmp ( dim ); //second moment
-		for ( int i=0;i<epdfs.length();i++ ) {
-			vec pom = epdfs ( i )->mean();
-			dls ( i )->pushup ( tmp, pow ( pom,2 ) );
-		}
-		return tmp-pow ( mean(),2 );
-	}
-	vec sample() const {
-		vec tmp ( dim );
-		for ( int i=0;i<epdfs.length();i++ ) {
-			vec pom = epdfs ( i )->sample();
-			dls ( i )->pushup ( tmp, pom );
-		}
-		return tmp;
-	}
-	double evallog ( const vec &val ) const {
-		double tmp=0;
-		for ( int i=0;i<epdfs.length();i++ ) {
-			tmp+=epdfs ( i )->evallog ( dls ( i )->pushdown ( val ) );
-		}
-		it_assert_debug ( std::isfinite ( tmp ),"Infinite" );
-		return tmp;
-	}
-	//!access function
-	const epdf* operator () ( int i ) const {it_assert_debug ( i<epdfs.length(),"wrong index" );return epdfs ( i );}
-
-	//!Destructor
-	~eprod() {for ( int i=0;i<epdfs.length();i++ ) {delete dls ( i );}}
-};
-
-
-/*! \brief Mixture of mpdfs with constant weights, all mpdfs are of equal type
-
-*/
-class mmix : public mpdf {
-protected:
-	//! Component (epdfs)
-	Array<mpdf*> Coms;
-	//!Internal epdf
-	emix Epdf;
-public:
-	//!Default constructor
-	mmix ( ) : mpdf ( ), Epdf () {ep = &Epdf;};
-	//! Set weights \c w and components \c R
-	void set_parameters ( const vec &w, const Array<mpdf*> &Coms ) {
-		Array<epdf*> Eps ( Coms.length() );
-
-		for ( int i = 0;i < Coms.length();i++ ) {
-			Eps ( i ) = & ( Coms ( i )->_epdf() );
-		}
-		Epdf.set_parameters ( w, Eps );
-	};
-
-	void condition ( const vec &cond ) {
-		for ( int i = 0;i < Coms.length();i++ ) {Coms ( i )->condition ( cond );}
-	};
-};
-
-}
-#endif //MX_H
Index: library/bdm/CMakeLists.txt
===================================================================
--- library/bdm/CMakeLists.txt (revision 384)
+++ library/bdm/CMakeLists.txt (revision 394)
@@ -3,5 +3,5 @@
 SET(bdm_base base/bdmbase.cpp base/bdmbase.h base/datasources.cpp base/datasources.h base/loggers.cpp base/loggers.h)
 SET(bdm_math math/square_mat.cpp math/square_mat.h math/chmat.cpp math/chmat.h math/functions.cpp math/functions.h)
-SET(bdm_stat stat/exp_family.cpp stat/exp_family.h stat/mixtures.cpp stat/mixtures.h stat/merger.h stat/merger.cpp)
+SET(bdm_stat stat/exp_family.cpp stat/exp_family.h stat/emix.cpp stat/emix.h stat/merger.h stat/merger.cpp)
 SET(bdm_estim estim/kalman.cpp estim/kalman.h estim/particles.cpp estim/particles.h estim/arx.cpp estim/arx.h estim/mixtures.cpp estim/mixtures.h)
 SET(bdm_user_info base/libconfig/libconfigcpp.cc base/libconfig/grammar.c base/libconfig/libconfig.c base/libconfig/scanner.c base/user_info.cpp base/user_info.h )
Index: library/tests/emix_test.cpp
===================================================================
--- library/tests/emix_test.cpp (revision 394)
+++ library/tests/emix_test.cpp (revision 394)
@@ -0,0 +1,110 @@
+#include "stat/exp_family.h"
+#include "stat/emix.h"
+using namespace bdm;
+
+//These lines are needed for use of cout and endl
+using std::cout;
+using std::endl;
+
+double normcoef ( const epdf* ep,const vec &xb, const vec &yb, int Ngr=100 ) {
+	mat PPdf ( Ngr+1,Ngr+1 );
+	vec rgr ( 2 );
+
+	int i=0,j=0;
+	double xstep= ( xb ( 1 )-xb ( 0 ) ) /Ngr;
+	double ystep= ( yb ( 1 )-yb ( 0 ) ) /Ngr;
+
+	for ( double x=xb ( 0 );x<=xb ( 1 );x+= xstep,i++ ) {
+		rgr ( 0 ) =x;j=0;
+		for ( double y=yb ( 0 );y<=yb ( 1 );y+=ystep,j++ ) {
+			rgr ( 1 ) =y;
+			PPdf ( i,j ) =exp ( ep->evallog ( rgr ) );
+		}
+	}
+	return sumsum ( PPdf ) *xstep*ystep;
+}
+
+int main() {
+	RNG_randomize();
+
+	RV x ( "{x }" );
+	RV y ( "{y }" );
+	RV xy=concat(x,y);
+	
+	enorm<ldmat> E1; E1.set_rv ( xy );
+		
+	it_file iti("xxx");
+	mat R; vec mu;
+	iti >> Name("R") >>R;
+	iti >> Name("mu") >>mu;
+
+	cout << mu << R <<endl;
+	E1.set_parameters( mu, R);//"1.00054 1.0455" , mat ( "0.740142 -0.259015; -0.259015 1.0302" ));
+	enorm<ldmat> E2;E2.set_rv ( xy );
+	E2.set_parameters( "-1.2 -0.1" , mat ( "1 0.4; 0.4 0.5" ));
+
+	Array<epdf*> A1(1);
+	A1(0) = &E1;
+	
+	emix M1; M1.set_rv(xy);
+	M1.set_parameters(vec("1"), A1, false);
+	cout << "======== test if ARX and emix with one ARX are the same ==="<<endl;
+	
+	epdf* Mm = M1.marginal(y);
+	epdf* Am = E1.marginal(y);
+	mpdf* Mc = M1.condition(y);
+	mpdf* Ac = E1.condition(y);
+	
+	cout << *((mlnorm<ldmat>*)Ac) <<endl;
+	
+	cout << "Mix marg at 0: " << Mm->evallog(vec_1(0.0)) <<endl;
+	cout << "ARX marg at 0: " << Am->evallog(vec_1(0.0)) <<endl;
+	cout << "Mix cond at 0,0: " << Mc->evallogcond(vec_1(0.0),vec_1(0.0)) <<endl;
+	cout << "ARX cond at 0,0: " << Ac->evallogcond(vec_1(0.0),vec_1(0.0)) <<endl;
+	
+	cout << "======== Mixture with two components ==="<<endl;
+	Array<epdf*> A2(2);
+	A2(0) = &E1;
+	A2(1) = &E2;
+	
+	emix M2; M2.set_rv(xy);
+	M2.set_parameters(vec("1"), A2, false);
+	
+	
+	cout << "Mixture normalization: " << normcoef(&M2, vec("-3 3 "), vec("-3 3 ")) <<endl;
+	
+	int N=3;
+	vec ll ( N );
+	vec ll2 ( N );
+	mat Smp=M2.sample_m ( N );
+	ll = M2.evallog_m(Smp);
+	
+	vec Emu = sum ( Smp,2 ) /N;
+	mat Er = ( Smp*Smp.transpose() ) /N - outer_product ( Emu,Emu );
+
+	cout << "original empirical mean: " <<Emu <<endl;
+	cout << "original empirical variance: " <<Er <<endl;
+
+	epdf* Mg = (epdf*)M2.marginal ( y );
+	mpdf* Cn = (mpdf*)M2.condition ( x );
+
+	it_file it("emix_test.it");
+	it << Name("Smp") << Smp;
+
+	cout<< "marginal mean: " << Mg->mean() <<endl;
+
+	cout << "========== putting them back together ======= "<<endl;
+	mepdf mMg ( Mg );
+	Array<mpdf*> AA ( 2 );
+	AA ( 0 ) = Cn;
+	AA ( 1 ) = &mMg;
+	mprod mEp ( AA );
+
+	for (int j=0; j<N; j++){
+		ll2(j)=mEp.evallogcond (Smp.get_col(j), vec ( 0 ));
+	}
+	it << Name("ll") << ll;
+	it << Name("ll2") << ll2;
+	
+	
+}
Index: library/tests/test_user_info.cpp
===================================================================
--- library/tests/test_user_info.cpp (revision 390)
+++ library/tests/test_user_info.cpp (revision 394)
@@ -197,5 +197,5 @@
 {
   //////////////////////////////////// LOADING ////////////////////////////////
-  UI_File in("test_user_info_input.cfg");
+  UIFile in("test_user_info_input.cfg");
   Transport *pepikovo = UI::build<Transport>(in, "pepikovo");
   cout << "pepikovo: " << pepikovo->to_string() << endl;
@@ -216,5 +216,5 @@
   Car liaz(1989, "skoda", 1000);
   Bike author(2001, "noname", false);
-  UI_File out;
+  UIFile out;
 
   UI::save(&audi, out, "marty");
Index: library/tests/CMakeLists.txt
===================================================================
--- library/tests/CMakeLists.txt (revision 386)
+++ library/tests/CMakeLists.txt (revision 394)
@@ -19,5 +19,5 @@
 EXEC(enorm_test)
 EXEC(egiw_test)
-EXEC(stat_mixtures_test)
+EXEC(emix_test)
 EXEC(test0)
 EXEC(testResample)
@@ -29,5 +29,5 @@
 EXEC(merger_2d_test)
 EXEC(merger_iter_test)
-EXEC(estim_mixtures_test)
+EXEC(mixtures_test)
 
 EXEC(test_kalman)
Index: library/tests/testSmp.cpp
===================================================================
--- library/tests/testSmp.cpp (revision 386)
+++ library/tests/testSmp.cpp (revision 394)
@@ -1,5 +1,5 @@
 
 #include "stat/exp_family.h"
-#include "stat/mixtures.h"
+#include "stat/emix.h"
 
 using namespace bdm;
Index: library/tests/emix_test.m
===================================================================
--- library/tests/emix_test.m (revision 394)
+++ library/tests/emix_test.m (revision 394)
@@ -0,0 +1,5 @@
+itload('../emix_test.it');
+
+figure(1);
+hold off;
+plot(Smp(1,:), Smp(2,:),'.');
Index: library/tests/enorm_test.cpp
===================================================================
--- library/tests/enorm_test.cpp (revision 386)
+++ library/tests/enorm_test.cpp (revision 394)
@@ -1,4 +1,4 @@
 #include "stat/exp_family.h"
-#include "stat/mixtures.h"
+#include "stat/emix.h"
 using namespace bdm;
 
Index: library/tests/mixtures_test.cpp
===================================================================
--- library/tests/mixtures_test.cpp (revision 394)
+++ library/tests/mixtures_test.cpp (revision 394)
@@ -0,0 +1,120 @@
+#include "estim/mixtures.h"
+#include "estim/arx.h"
+#include "stat/exp_family.h"
+using namespace bdm;
+
+//These lines are needed for use of cout and endl
+using std::cout;
+using std::endl;
+
+void disp_mix2D ( const MixEF &Mi ) {
+	const eprod &ep=((const eprod&)(Mi.posterior()));
+	int i;
+	mat Var ( 2,2 ),M ( 1,2 );
+	for ( i=0; i<ep._rv().length() - 1; i++ ) { // -1 => last one is the weight
+		( ( egiw* ) ep ( i ) )->mean_mat ( M,Var );
+		cout << "Mean: "<< M <<endl << "Variance: "<<endl <<Var<<endl;
+	}
+	cout <<"Weights: "<< ep ( i )->mean() <<endl;
+}
+
+mat grid2D ( const MixEF &M,const vec &xb, const vec &yb, int Ngr=100 ) {
+	mat PPdf ( Ngr+1,Ngr+1 );
+	vec rgr ( 3 );
+
+	rgr ( 2 ) =1;
+	int i=0,j=0;
+	double xstep=( xb ( 1 )-xb ( 0 ) ) /Ngr;
+	double ystep=( yb ( 1 )-yb ( 0 ) ) /Ngr;
+	
+	for ( double x=xb ( 0 );x<=xb ( 1 );x+= xstep,i++ ) {
+		rgr ( 0 ) =x;j=0;
+		for ( double y=yb(0);y<=yb(1);y+=ystep,j++ ) {
+			rgr ( 1 ) =y;
+			PPdf ( i,j ) =exp ( M.logpred ( rgr ) );
+		}
+	}
+	return PPdf;
+}
+
+int main() {
+	RV x ( "{x }","2" );
+
+	
+	cout << "Test for estimation of a 2D Gaussian mixture" << endl;
+	///////////////////////////////////
+	// Setup model
+
+	vec m1 ( "-2 -2" );
+	vec m2 ( "2 2" );
+
+	fsqmat V1 ( mat ( "1 0.5; 0.5 1" ) );
+	fsqmat V2 ( mat ( "2 -0.1; -0.1 2" ) );
+
+	enorm<fsqmat> C1; C1.set_rv ( x );
+	C1.set_parameters ( m1,V1 );
+	enorm<fsqmat> C2; C2.set_rv ( x );
+	C2.set_parameters ( m2,V2 );
+
+	Array<epdf*> Sim ( 2 ); Sim ( 0 ) =&C1;Sim ( 1 ) =&C2;
+	emix Simul;Simul.set_rv ( x );
+	Simul.set_parameters ( "0.5 0.6", Sim, false );
+
+	// Sample parameters
+	int ndat = 100;
+	mat Smp =Simul.sample_m ( ndat );
+
+	cout << "Simulated means: " << m1 <<" and " << m2 <<endl;
+	cout << "Simulated covariances: " << endl<<V1 <<" and " <<endl<< V2 <<endl;
+
+	//////////////////////////////
+	// Prepare estimator manually
+
+	// Initial values of components
+	mat V0=1e-4*eye ( 3 ); V0 ( 0,0 ) *=100;V0 ( 1,1 ) *=100;
+	mat Vp="0 0 1; 0 0 1; 1 1 0";
+	Vp*=5*1e-5;
+
+	ARX M1;M1.set_statistics(2,V0 - Vp,8 );
+	ARX M2;M2.set_statistics (2, V0 + Vp,8 );
+	
+	// Build mixture model
+	Array<BMEF*> A ( 2 ); A ( 0 ) =&M1; A ( 1 ) =&M2;
+	MixEF Post ( A,"0.5 0.5" );
+	cout << "Initial mixture:"<<endl;
+	disp_mix2D(Post);
+	
+	// Add ones for constant coefficients
+	mat Data = concat_vertical ( Smp, ones ( 1,Smp.cols() ) );
+	Post.bayes ( Data );
+
+	cout << "Posterior mixture:" <<endl;
+	disp_mix2D(Post);
+
+	//TEST random initialization
+	RNG_randomize();
+	ARX Aflat;
+	Aflat.set_statistics(2,V0,7);
+	MixEF RND;
+	RND.init(&Aflat,Data,10); // already initialized!
+	cout << endl<< "== Randomly initialized mixture ==" <<endl;
+	cout << endl<< "== INIT ==" <<endl;
+	disp_mix2D(RND);
+	mat PPdf_I=grid2D(RND, vec_2(-5.0,5.0), vec_2(-5.0,5.0));;
+	
+	RND.bayes(Data);
+	cout << endl<< "== BAYES ==" <<endl;
+	disp_mix2D(RND);
+
+	
+	it_file of ( "mixef_test.it",true );
+	of<< Name ( "Smp" ) <<Smp;
+	of<<Name ( "PPdf" ) <<grid2D(Post, vec_2(-5.0,5.0), vec_2(-5.0,5.0));
+	of<<Name ( "PPdf_I" ) <<PPdf_I;
+	of<<Name ( "PPdf_RND" ) <<grid2D(RND, vec_2(-5.0,5.0), vec_2(-5.0,5.0));
+
+	cout << endl <<"Variables written to file mixef_test.it:"<<endl;
+	cout << "Smp  : data sampled from the simulator " <<endl;
+	cout << "PPdf : posterior density on a grid <-5,5><-5,5>"<<endl;
+	cout << "PPdf_RND : posterior density of randomly initilaized mixture on a grid <-5,5><-5,5>"<<endl;
+}
Index: library/tests/estim_mixtures_test.cpp
===================================================================
--- library/tests/estim_mixtures_test.cpp (revision 386)
+++  (revision )
@@ -1,120 +1,0 @@
-#include "estim/mixtures.h"
-#include "estim/arx.h"
-#include "stat/exp_family.h"
-using namespace bdm;
-
-//These lines are needed for use of cout and endl
-using std::cout;
-using std::endl;
-
-void disp_mix2D ( const MixEF &Mi ) {
-	const eprod &ep=((const eprod&)(Mi.posterior()));
-	int i;
-	mat Var ( 2,2 ),M ( 1,2 );
-	for ( i=0; i<ep._rv().length() - 1; i++ ) { // -1 => last one is the weight
-		( ( egiw* ) ep ( i ) )->mean_mat ( M,Var );
-		cout << "Mean: "<< M <<endl << "Variance: "<<endl <<Var<<endl;
-	}
-	cout <<"Weights: "<< ep ( i )->mean() <<endl;
-}
-
-mat grid2D ( const MixEF &M,const vec &xb, const vec &yb, int Ngr=100 ) {
-	mat PPdf ( Ngr+1,Ngr+1 );
-	vec rgr ( 3 );
-
-	rgr ( 2 ) =1;
-	int i=0,j=0;
-	double xstep=( xb ( 1 )-xb ( 0 ) ) /Ngr;
-	double ystep=( yb ( 1 )-yb ( 0 ) ) /Ngr;
-	
-	for ( double x=xb ( 0 );x<=xb ( 1 );x+= xstep,i++ ) {
-		rgr ( 0 ) =x;j=0;
-		for ( double y=yb(0);y<=yb(1);y+=ystep,j++ ) {
-			rgr ( 1 ) =y;
-			PPdf ( i,j ) =exp ( M.logpred ( rgr ) );
-		}
-	}
-	return PPdf;
-}
-
-int main() {
-	RV x ( "{x }","2" );
-
-	
-	cout << "Test for estimation of a 2D Gaussian mixture" << endl;
-	///////////////////////////////////
-	// Setup model
-
-	vec m1 ( "-2 -2" );
-	vec m2 ( "2 2" );
-
-	fsqmat V1 ( mat ( "1 0.5; 0.5 1" ) );
-	fsqmat V2 ( mat ( "2 -0.1; -0.1 2" ) );
-
-	enorm<fsqmat> C1; C1.set_rv ( x );
-	C1.set_parameters ( m1,V1 );
-	enorm<fsqmat> C2; C2.set_rv ( x );
-	C2.set_parameters ( m2,V2 );
-
-	Array<epdf*> Sim ( 2 ); Sim ( 0 ) =&C1;Sim ( 1 ) =&C2;
-	emix Simul;Simul.set_rv ( x );
-	Simul.set_parameters ( "0.5 0.6", Sim, false );
-
-	// Sample parameters
-	int ndat = 100;
-	mat Smp =Simul.sample_m ( ndat );
-
-	cout << "Simulated means: " << m1 <<" and " << m2 <<endl;
-	cout << "Simulated covariances: " << endl<<V1 <<" and " <<endl<< V2 <<endl;
-
-	//////////////////////////////
-	// Prepare estimator manually
-
-	// Initial values of components
-	mat V0=1e-4*eye ( 3 ); V0 ( 0,0 ) *=100;V0 ( 1,1 ) *=100;
-	mat Vp="0 0 1; 0 0 1; 1 1 0";
-	Vp*=5*1e-5;
-
-	ARX M1;M1.set_statistics(2,V0 - Vp,8 );
-	ARX M2;M2.set_statistics (2, V0 + Vp,8 );
-	
-	// Build mixture model
-	Array<BMEF*> A ( 2 ); A ( 0 ) =&M1; A ( 1 ) =&M2;
-	MixEF Post ( A,"0.5 0.5" );
-	cout << "Initial mixture:"<<endl;
-	disp_mix2D(Post);
-	
-	// Add ones for constant coefficients
-	mat Data = concat_vertical ( Smp, ones ( 1,Smp.cols() ) );
-	Post.bayes ( Data );
-
-	cout << "Posterior mixture:" <<endl;
-	disp_mix2D(Post);
-
-	//TEST random initialization
-	RNG_randomize();
-	ARX Aflat;
-	Aflat.set_statistics(2,V0,7);
-	MixEF RND;
-	RND.init(&Aflat,Data,10); // already initialized!
-	cout << endl<< "== Randomly initialized mixture ==" <<endl;
-	cout << endl<< "== INIT ==" <<endl;
-	disp_mix2D(RND);
-	mat PPdf_I=grid2D(RND, vec_2(-5.0,5.0), vec_2(-5.0,5.0));;
-	
-	RND.bayes(Data);
-	cout << endl<< "== BAYES ==" <<endl;
-	disp_mix2D(RND);
-
-	
-	it_file of ( "mixef_test.it",true );
-	of<< Name ( "Smp" ) <<Smp;
-	of<<Name ( "PPdf" ) <<grid2D(Post, vec_2(-5.0,5.0), vec_2(-5.0,5.0));
-	of<<Name ( "PPdf_I" ) <<PPdf_I;
-	of<<Name ( "PPdf_RND" ) <<grid2D(RND, vec_2(-5.0,5.0), vec_2(-5.0,5.0));
-
-	cout << endl <<"Variables written to file mixef_test.it:"<<endl;
-	cout << "Smp  : data sampled from the simulator " <<endl;
-	cout << "PPdf : posterior density on a grid <-5,5><-5,5>"<<endl;
-	cout << "PPdf_RND : posterior density of randomly initilaized mixture on a grid <-5,5><-5,5>"<<endl;
-}
Index: library/tests/stat_mixtures_test.m
===================================================================
--- library/tests/stat_mixtures_test.m (revision 386)
+++  (revision )
@@ -1,5 +1,0 @@
-itload('../emix_test.it');
-
-figure(1);
-hold off;
-plot(Smp(1,:), Smp(2,:),'.');
Index: library/tests/stat_mixtures_test.cpp
===================================================================
--- library/tests/stat_mixtures_test.cpp (revision 386)
+++  (revision )
@@ -1,110 +1,0 @@
-#include "stat/exp_family.h"
-#include "stat/mixtures.h"
-using namespace bdm;
-
-//These lines are needed for use of cout and endl
-using std::cout;
-using std::endl;
-
-double normcoef ( const epdf* ep,const vec &xb, const vec &yb, int Ngr=100 ) {
-	mat PPdf ( Ngr+1,Ngr+1 );
-	vec rgr ( 2 );
-
-	int i=0,j=0;
-	double xstep= ( xb ( 1 )-xb ( 0 ) ) /Ngr;
-	double ystep= ( yb ( 1 )-yb ( 0 ) ) /Ngr;
-
-	for ( double x=xb ( 0 );x<=xb ( 1 );x+= xstep,i++ ) {
-		rgr ( 0 ) =x;j=0;
-		for ( double y=yb ( 0 );y<=yb ( 1 );y+=ystep,j++ ) {
-			rgr ( 1 ) =y;
-			PPdf ( i,j ) =exp ( ep->evallog ( rgr ) );
-		}
-	}
-	return sumsum ( PPdf ) *xstep*ystep;
-}
-
-int main() {
-	RNG_randomize();
-
-	RV x ( "{x }" );
-	RV y ( "{y }" );
-	RV xy=concat(x,y);
-	
-	enorm<ldmat> E1; E1.set_rv ( xy );
-		
-	it_file iti("xxx");
-	mat R; vec mu;
-	iti >> Name("R") >>R;
-	iti >> Name("mu") >>mu;
-
-	cout << mu << R <<endl;
-	E1.set_parameters( mu, R);//"1.00054 1.0455" , mat ( "0.740142 -0.259015; -0.259015 1.0302" ));
-	enorm<ldmat> E2;E2.set_rv ( xy );
-	E2.set_parameters( "-1.2 -0.1" , mat ( "1 0.4; 0.4 0.5" ));
-
-	Array<epdf*> A1(1);
-	A1(0) = &E1;
-	
-	emix M1; M1.set_rv(xy);
-	M1.set_parameters(vec("1"), A1, false);
-	cout << "======== test if ARX and emix with one ARX are the same ==="<<endl;
-	
-	epdf* Mm = M1.marginal(y);
-	epdf* Am = E1.marginal(y);
-	mpdf* Mc = M1.condition(y);
-	mpdf* Ac = E1.condition(y);
-	
-	cout << *((mlnorm<ldmat>*)Ac) <<endl;
-	
-	cout << "Mix marg at 0: " << Mm->evallog(vec_1(0.0)) <<endl;
-	cout << "ARX marg at 0: " << Am->evallog(vec_1(0.0)) <<endl;
-	cout << "Mix cond at 0,0: " << Mc->evallogcond(vec_1(0.0),vec_1(0.0)) <<endl;
-	cout << "ARX cond at 0,0: " << Ac->evallogcond(vec_1(0.0),vec_1(0.0)) <<endl;
-	
-	cout << "======== Mixture with two components ==="<<endl;
-	Array<epdf*> A2(2);
-	A2(0) = &E1;
-	A2(1) = &E2;
-	
-	emix M2; M2.set_rv(xy);
-	M2.set_parameters(vec("1"), A2, false);
-	
-	
-	cout << "Mixture normalization: " << normcoef(&M2, vec("-3 3 "), vec("-3 3 ")) <<endl;
-	
-	int N=3;
-	vec ll ( N );
-	vec ll2 ( N );
-	mat Smp=M2.sample_m ( N );
-	ll = M2.evallog_m(Smp);
-	
-	vec Emu = sum ( Smp,2 ) /N;
-	mat Er = ( Smp*Smp.transpose() ) /N - outer_product ( Emu,Emu );
-
-	cout << "original empirical mean: " <<Emu <<endl;
-	cout << "original empirical variance: " <<Er <<endl;
-
-	epdf* Mg = (epdf*)M2.marginal ( y );
-	mpdf* Cn = (mpdf*)M2.condition ( x );
-
-	it_file it("emix_test.it");
-	it << Name("Smp") << Smp;
-
-	cout<< "marginal mean: " << Mg->mean() <<endl;
-
-	cout << "========== putting them back together ======= "<<endl;
-	mepdf mMg ( Mg );
-	Array<mpdf*> AA ( 2 );
-	AA ( 0 ) = Cn;
-	AA ( 1 ) = &mMg;
-	mprod mEp ( AA );
-
-	for (int j=0; j<N; j++){
-		ll2(j)=mEp.evallogcond (Smp.get_col(j), vec ( 0 ));
-	}
-	it << Name("ll") << ll;
-	it << Name("ll2") << ll2;
-	
-	
-}
