Index: library/bdm/stat/exp_family.h
===================================================================
--- library/bdm/stat/exp_family.h (revision 951)
+++ library/bdm/stat/exp_family.h (revision 956)
@@ -133,17 +133,7 @@
 			return std::numeric_limits< double >::max();
 		}
-		void from_setting(const Setting& set){
-			pdf::from_setting(set);
-			g=UI::build<fnc>(set,"g",UI::compulsory);
-			validate();
-		}
-		void to_setting(Setting &set) const{
-			pdf::to_setting(set);
-			UI::save(g.get(), set, "g");
-		}
-		void validate() {
-			dim = g->dimension();
-			dimc = g->dimensionc();
-		}
+		void from_setting(const Setting& set);
+		void to_setting(Setting &set) const;
+		void validate();
 };
 UIREGISTER(mgdirac);
@@ -186,8 +176,5 @@
 	void to_setting ( Setting &root ) const ;
 	
-	void validate() {
-		bdm_assert ( mu.length() == R.rows(), "mu and R parameters do not match" );
-		dim = mu.length();
-	}
+	void validate();
 	//!@}
 
@@ -336,4 +323,5 @@
 			}
 			void validate() {
+				eEF::validate();
 				dim = H.rows();
 			}
@@ -460,37 +448,7 @@
 	\sa log_level_enums
 	*/
-	void from_setting ( const Setting &set ) {
-		epdf::from_setting ( set );
-		UI::get ( dimx, set, "dimx", UI::compulsory );
-		if ( !UI::get ( nu, set, "nu", UI::optional ) ) {
-			nu = -1;
-		}
-		mat V;
-		if ( !UI::get ( V, set, "V", UI::optional ) ) {
-			vec dV;
-			UI::get ( dV, set, "dV", UI::compulsory );
-			set_parameters ( dimx, ldmat ( dV ), nu );
-			validate();
-
-		} else {
-			set_parameters ( dimx, V, nu );
-			validate();
-		}
-	}
-
-	void to_setting ( Setting& set ) const {
-		epdf::to_setting ( set );
-		UI::save ( dimx, set, "dimx" );
-		UI::save ( V.to_mat(), set, "V" );
-		UI::save ( nu, set, "nu" );
-	};
-
-	void validate() {
-	dim = dimx * ( dimx + nPsi ); 	
-	
-	    // check sizes, rvs etc.
-		// also check if RV are meaningful!!!
-		// meaningful =  rv for theta  and rv for r are split!
-	}
+	void from_setting ( const Setting &set );
+	void to_setting ( Setting& set ) const;
+	void validate();
 	void log_register ( bdm::logger& L, const string& prefix );
 
@@ -578,19 +536,7 @@
 	\endcode
 	*/
-	void from_setting ( const Setting &set ) {
-		epdf::from_setting ( set );
-		UI::get ( beta, set, "beta", UI::compulsory );
-		validate();
-	}
-	void validate() {
-		//check rv
-		dim = beta.length();
-	}
-
-	void to_setting ( Setting &set ) const
-	{			
-		eEF::to_setting( set );
-		UI::save( beta, set, "beta" );
-	} 
+	void from_setting ( const Setting &set );
+	void validate();
+	void to_setting ( Setting &set ) const;
 };
 UIREGISTER ( eDirich );
@@ -632,29 +578,7 @@
 	\endcode
 	*/
-	void from_setting ( const Setting &set ) {
-		pdf::from_setting ( set ); // reads rv and rvc
-		if ( _rv()._dsize() > 0 ) {
-			rvc = _rv().copy_t ( -1 );
-		}
-		vec beta0;
-		if ( !UI::get ( beta0, set, "beta0", UI::optional ) ) {
-			beta0 = ones ( _rv()._dsize() );
-		}
-		if ( !UI::get ( betac, set, "betac", UI::optional ) ) {
-			betac = 0.1 * ones ( _rv()._dsize() );
-		}
-		_beta = beta0;
-
-		UI::get ( k, set, "k", UI::compulsory );
-		validate();
-	}
-	void validate() {
-		pdf_internal<eDirich>::validate();
-		bdm_assert ( _beta.length() == betac.length(), "beta0 and betac are not compatible" );
-		if ( _rv()._dsize() > 0 ) {
-			bdm_assert ( ( _rv()._dsize() == dimension() ) , "Size of rv does not match with beta" );
-		}
-		dimc = _beta.length();
-	};
+	void from_setting ( const Setting &set );
+	void 	to_setting  (Setting  &set) const;
+	void validate();
 };
 UIREGISTER ( mDirich );
@@ -765,14 +689,7 @@
 	\endcode
 	*/
-	void from_setting ( const Setting &set ) {
-		epdf::from_setting ( set ); // reads rv
-		UI::get ( alpha, set, "alpha", UI::compulsory );
-		UI::get ( beta, set, "beta", UI::compulsory );
-		validate();
-	}
-	void validate() {
-		bdm_assert ( alpha.length() == beta.length(), "parameters do not match" );
-		dim = alpha.length();
-	}
+	void from_setting ( const Setting &set );
+	void to_setting ( Setting &set ) const;
+	void validate(); 
 };
 UIREGISTER ( egamma );
@@ -888,17 +805,7 @@
 	 \endcode
 	 */
-	void from_setting ( const Setting &set ) {
-		epdf::from_setting ( set ); // reads rv and rvc
-
-		UI::get ( high, set, "high", UI::compulsory );
-		UI::get ( low, set, "low", UI::compulsory );
-		set_parameters ( low, high );
-		validate();
-	}
-	void validate() {
-		bdm_assert ( high.length() == low.length(), "Incompatible high and low vectors" );
-		dim = high.length();
-		bdm_assert ( min ( distance ) > 0.0, "bad support" );
-	}
+	void from_setting ( const Setting &set );
+	void 	to_setting  (Setting  &set) const;
+	void validate();
 };
 UIREGISTER ( euni );
@@ -922,8 +829,13 @@
 		iepdf.set_parameters ( -delta, delta );
 	}
-	
+	void 	to_setting  (Setting  &set) const {
+		pdf::to_setting ( set ); 
+		UI::save( iepdf.mean(), set, "delta");
+		UI::save(mean, set, "mean");
+	}
 	void validate(){
+		pdf_internal<euni>::validate();
 		dimc = mean->dimensionc();
-		iepdf.validate();
+		
 	}
 
@@ -1006,7 +918,7 @@
 		UI::get ( R0, set, "R", UI::compulsory );
 		set_parameters ( A, mu_const, R0 );
-		validate();
-	};
-	void to_setting (Setting &set) const {
+	}
+
+void to_setting (Setting &set) const {
 		pdf::to_setting(set);
 		UI::save ( A, set, "A");
@@ -1014,5 +926,6 @@
 		UI::save ( _R(), set, "R");
 	}
-	void validate() {
+
+void validate() {
 		pdf_internal<TEpdf<sq_T> >::validate();
 		if (mu_const.length()==0) { // default in from_setting
@@ -1070,5 +983,6 @@
 	*/
 
-	void from_setting ( const Setting &set ) {
+
+void from_setting ( const Setting &set ) {
 		pdf::from_setting ( set );
 		shared_ptr<fnc> g = UI::build<fnc> ( set, "g", UI::compulsory );
@@ -1084,5 +998,15 @@
 		//validate();
 	}
-	void validate() {
+	
+
+void to_setting  (Setting  &set) const {
+		UI::save( g,set, "g");
+		UI::save(iepdf._R().to_mat(),set, "R");
+	
+	}
+
+
+
+void validate() {
 		this->iepdf.validate();
 		bdm_assert ( g->dimension() == this->iepdf.dimension(), "incompatible function" );
@@ -1091,4 +1015,5 @@
 		this->iepdf.validate();
 	}
+
 };
 
@@ -1128,4 +1053,5 @@
 
 	void validate() {
+		mlnorm<ldmat, enorm>::validate();
 		bdm_assert ( A.rows() == mu_const.length(), "mlstudent: A vs. mu mismatch" );
 		bdm_assert ( _R.rows() == A.rows(), "mlstudent: A vs. R mismatch" );
@@ -1175,18 +1101,7 @@
 	 \endcode
 	*/
-	void from_setting ( const Setting &set ) {
-		pdf::from_setting ( set ); // reads rv and rvc
-		vec betatmp; // ugly but necessary
-		UI::get ( betatmp, set, "beta", UI::compulsory );
-		UI::get ( k, set, "k", UI::compulsory );
-		set_parameters ( k, betatmp );
-		validate();
-	}
-	void validate() {
-		pdf_internal<egamma>::validate();
-
-		dim = _beta.length();
-		dimc = _beta.length();
-	}
+	void from_setting ( const Setting &set );
+	void 	to_setting  (Setting  &set) const;
+	void validate();
 };
 UIREGISTER ( mgamma );
@@ -1236,5 +1151,5 @@
 
 	void 	validate (){
-		iepdf.validate();
+		pdf_internal<eigamma>::validate();
 		dimc = dimension();
 };
@@ -1338,5 +1253,5 @@
 	 */
 	void from_setting ( const Setting &set );
-
+	void to_setting  (Setting  &set) const; 
 	// TODO dodelat void to_setting( Setting &set ) const;
 };
@@ -1395,5 +1310,5 @@
 	
 	void validate(){
-		iepdf.validate();
+		pdf_internal<elognorm>::validate();
 		dimc = iepdf.dimension();
 	}
@@ -1415,4 +1330,5 @@
 	*/
 	void from_setting ( const Setting &set );
+	void to_setting  (Setting  &set) const; 
 
 	// TODO dodelat void to_setting( Setting &set ) const;
@@ -1449,4 +1365,5 @@
 	
 	virtual void validate (){
+		epdf::validate();
 		dim = p * p;
 	}
@@ -1519,4 +1436,5 @@
 	
 	virtual void 	validate (){
+		epdf::validate();
 		W.validate();
 		dim = W.dimension();
@@ -1594,5 +1512,5 @@
 	
 	void validate(){
-		iepdf.validate();
+		pdf_internal<eiWishartCh>::validate();
 		dimc = iepdf.dimension();
 	}
@@ -1657,10 +1575,5 @@
 		samples = Av;
 	};
-	virtual void 	validate (){
-	  bdm_assert (samples.length()==w.length(),"samples and weigths are of different lengths");
-	  n = w.length();
-	  if (n>0)
-		pdf::dim = samples ( 0 ).length();
-	}
+	virtual void 	validate ();
 	//! Potentially dangerous, use with care.
 	vec& _w()  {
@@ -1709,17 +1622,6 @@
 	void qbounds ( vec &lb, vec &ub, double perc = 0.95 ) const;
 
-	void to_setting ( Setting &set ) const {
-		epdf::to_setting( set );
-		UI::save ( samples, set, "samples" );
-		UI::save ( w, set, "w" );
-	}
-
-	void from_setting ( const Setting &set ) {
-		epdf::from_setting( set );
-		
-		UI::get( samples, set, "samples", UI::compulsory );
-		UI::get ( w, set, "w", UI::compulsory );
-		validate();
-	}
+	void to_setting ( Setting &set ) const;
+	void from_setting ( const Setting &set );
 
 };
@@ -1745,6 +1647,12 @@
 	UI::get ( Rtmp, set, "R", UI::compulsory );
 	R = Rtmp; // conversion
-	validate();
 }
+
+template<class sq_T>
+void enorm<sq_T>::validate() {
+		eEF::validate();
+		bdm_assert ( mu.length() == R.rows(), "mu and R parameters do not match" );
+		dim = mu.length();
+	}
 
 template<class sq_T>
@@ -1754,4 +1662,6 @@
 	UI::save ( R.to_mat(), set, "R");
 }
+
+
 
 template<class sq_T>
