Index: /tlab/mixef_test.m
===================================================================
--- /matlab/mixef_test.m (revision 202)
+++  (revision )
@@ -1,12 +1,0 @@
-itload('../mixef_test.it');
-
-figure(1);
-hold off;
-plot(Smp(1,:), Smp(2,:),'.');
-hold on
-xv=-5:0.1:5;
-X = ones(size(xv))'*xv;
-Y = xv'*ones(size(xv));
-
-contour(X,Y,PPdf)
-
Index: /tlab/blas_test.m
===================================================================
--- /matlab/blas_test.m (revision 123)
+++  (revision )
@@ -1,59 +1,0 @@
-function test
-
-vn = [5,50,200,500]
-if 0
-	et =zeros(1,4);
-	et2 =zeros(1,4);
-
-	idn = 1;
-	vn = [5,50,200,500]
-	for n= vn
-		A=rand(n);B=rand(n);C=rand(n);
-		tic;
-		for i=1:10
-			C=matmult(A,B);
-		end
-		et(idn) = toc;
-
-		tic;
-		for i=1:10
-			C=A*B;
-		end
-		et2(idn) = toc;
-
-		idn =idn+1;
-	end
-	save blas_test
-else
-	load blas_test
-end
-
-itload('../blas_test.it')
-
-figure
-plot(vn,et)
-hold on
-plot(vn,et2,'r');
-plot(vn,exec_times,'--')
-plot(vn,exec_times_b,'r--')
-plot(vn,exec_times_c,'g--')
-title('For cycle vs. BLAS');
-ylabel('execution time');
-xlabel('matrix size');
-set(gca,'YScale','log')
-set(gca,'XScale','log')
-set(gcf,'PaperPositionMode','auto');
-
-legend('matlab for','matlab blas','IT++ for','IT++ blas','C array')
-
-
-function C=matmult(A,B)
-for i=1:size(A,1)
-	for j=1:size(A,2)
-		sum=0;
-		for k=1:size(A,2)
-			sum=sum+A(i,k)*B(k,j);
-		end
-		C(i,j)=sum;
-	end
-end
Index: /tlab/testKF.m
===================================================================
--- /matlab/testKF.m (revision 91)
+++  (revision )
@@ -1,84 +1,0 @@
-function testKF(skipgen)
-if nargin<1, skipgen=0; end
-
-if ~skipgen
-	A=[1 -0.5; 1 0];
-	B=[1;0.1];
-	C=[1 0];%; 0 1];
-	D=0.1;%[0.1; 0];
-	R=0.01;%[1 0; 0 0.1];
-	Q=[0.2 0 ; 0 0.2]; 
-
-	sQ = chol(Q)';
-	sR = chol(R)';
-
-	N =3000;
-	mu0 = [0;0];
-	P0 = 200*eye(2);
-
-	u = zeros(1,N);
-	x = zeros(2,N);
-	y = zeros(1,N);
-
-	x(:,1) = [10;10];
-	Et = sQ*randn(2,N);
-	Wt = sR*randn(1,N);
-	for i=2:N;
-		x(:,i) = A*x(:,i-1) + B*u(i) + Et(:,i);
-		y(:,i) = C*x(:,i) + D*u(i) + Wt(:,1);
-	end
-
-	d=[y;u];
-	itsave('testKF.it',d,A,B,C,D,Q,R,P0,mu0)
-	save testKF
-else
-	load testKF
-end
-% init 
-mu = mu0;
-P = P0;
-EP = [0;0];
-
-Oxt = mu0;
-OPt = P0;
-ll =0;
-oxt = mu0;
-oPt = chol(P0)';
-oll=0;
-
-tic;
-for t=2:N
-	mu = A*mu + B*u(t);
-	P  = A*P*A' + Q;
-
-	%Data update
-	Ry = C*P*C' + R;
-	iRy = inv(Ry);
-	K = P*C'*iRy; 
-	P = P- K*C*P; % P = P -KCP;
-	mu = mu + K*(y(:,t)-C*mu-D*u(t));
-	Mu(1:2,t)=mu;
-
-  	[Oxt,OPt,ll(t)] = Kalman(Oxt,y(:,t),A,C,Q,R,OPt);
-%	[oxt,oPt,oll(t)] = KalmanSq(oxt,y(:,t),A,C,sQ,sR,oPt);
-  	MuK(1:2,t) = Oxt;
-%	MuS(1:2,t) = oxt;
-end
-exec_matlab = toc
-%keyboard
-
-!cd ../;./tests/testKF
-itload('testKF_res.it');
-
-hold off
-plot(x');
-hold on
-plot([xth]','--'); % shift the predldmatictions
-plot(xth2','+');
-plot(xthE','o');
-plot([zeros(size(xth,1),1) MuK]','d'); % shift the predictions
-
-exec_times
-exec_matlab./exec_times
-keyboard
-end
Index: /tlab/emix_test.m
===================================================================
--- /matlab/emix_test.m (revision 202)
+++  (revision )
@@ -1,5 +1,0 @@
-itload('../emix_test.it');
-
-figure(1);
-hold off;
-plot(Smp(1,:), Smp(2,:),'.');
Index: /tlab/testKF_big.m
===================================================================
--- /matlab/testKF_big.m (revision 91)
+++  (revision )
@@ -1,89 +1,0 @@
-function testKF(skipgen)
-if nargin<1, skipgen=0; end
-
-if ~skipgen
-	dimx = 30;
-	Apom=rand(dimx);
-	Apom2 = Apom*Apom';
-	A = Apom2/max(1.1*eig(Apom2));
-	B=ones(dimx,1);
-	C=eye(dimx);
-	D=ones(dimx,1);
-	R=0.1*eye(dimx);
-	Q=0.2*eye(dimx); 
-
-	sQ = chol(Q)';
-	sR = chol(R)';
-
-	N =1000;
-	mu0 = zeros(dimx,1);
-	P0 = 200*eye(dimx);
-
-	u = rand(1,N);
-	x = zeros(dimx,N);
-	y = zeros(dimx,N);
-
-	x(:,1) = 10*ones(dimx,1);
-	Et = sQ*randn(dimx,N);
-	Wt = sR*randn(dimx,N);
-	for i=2:N;
-		x(:,i) = A*x(:,i-1) + B*u(i) + Et(:,i);
-		y(:,i) = C*x(:,i) + D*u(i) + Wt(:,1);
-	end
-
-	d=[y;u];
-	itsave('testKF.it',d,A,B,C,D,Q,R,P0,mu0)
-	save testKF
-else
-	load testKF
-end
-% init 
-mu = mu0;
-P = P0;
-EP = [0;0];
-
-Oxt = mu0;
-OPt = P0;
-ll =0;
-Oxt2 = mu0;
-OPt2 = P0;
-ll2=0;
-
-tic;
-for t=2:N
-	mu = A*mu + B*u(t);
-	P  = A*P*A' + Q;
-
-	%Data update
-	Ry = C*P*C' + R;
-	iRy = inv(Ry);
-	K = P*C'*iRy; 
-	P = P- K*C*P; % P = P -KCP;
-	mu = mu + K*(y(:,t)-C*mu-D*u(t));
-	Mu(1:dimx,t)=mu;
-
-%	[Oxt,OPt,ll(t)] = Kalman(Oxt,y(:,t),A,C,Q,R,OPt);
-%	[Oxt2,OPt2,ll2(t)] = Kalman(Oxt2,y(:,t),A,C,Q,R/10000,OPt2);
-end
-exec_matlab = toc
-
-!cd ../;./tests/testKF
-itload('testKF_res.it');
-
-hold off
-plot(x');
-hold on
-plot(xth','--');
-plot(xth2','+');
-plot(xthE','o');
-plot(Mu','d');
-
-max(max(x(:,2:end) - xth(:,1:end-1)))
-max(max(x - xth2))
-max(max(x - xthE))
-max(max(x - Mu))
-
-exec_times
-exec_matlab./exec_times
-keyboard
-end
Index: /bdm/user_info.h
===================================================================
--- /bdm/user_info.h (revision 377)
+++ /bdm/user_info.h (revision 378)
@@ -17,4 +17,5 @@
 
 #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) 
 #else
Index: /bdm/stat/libBM.cpp
===================================================================
--- /bdm/stat/libBM.cpp (revision 377)
+++ /bdm/stat/libBM.cpp (revision 378)
@@ -255,5 +255,5 @@
 	RV rv; //empty rv
 	bool rvaddok;
-	for ( int i = 0;i < n;i++ ) {
+	for ( int i = 0;i < mpdfs.length();i++ ) {
 		rvaddok=rv.add ( mpdfs ( i )->_rv() ); //add rv to common rvs.
 		// If rvaddok==false, mpdfs overlap => assert error.
@@ -264,5 +264,5 @@
 
 void compositepdf::setrvc ( const RV &rv, RV &rvc ) {
-	for ( int i = 0;i < n;i++ ) {
+	for ( int i = 0;i < mpdfs.length();i++ ) {
 		RV rvx = mpdfs ( i )->_rvc().subt ( rv );
 		rvc.add ( rvx ); //add rv to common rvc
Index: /bdm/stat/libEF.h
===================================================================
--- /bdm/stat/libEF.h (revision 377)
+++ /bdm/stat/libEF.h (revision 378)
@@ -125,4 +125,5 @@
 			enorm ( const vec &mu,const sq_T &R ) {set_parameters ( mu,R );}
 			void set_parameters ( const vec &mu,const sq_T &R );
+			void from_setting(const Setting &root);
 			//!@}
 
@@ -141,5 +142,5 @@
 //	mlnorm<sq_T>* condition ( const RV &rvn ) const ; <=========== fails to cmpile. Why?
 			mpdf* condition ( const RV &rvn ) const ;
-	enorm<sq_T>* marginal ( const RV &rv ) const;
+			enorm<sq_T>* marginal ( const RV &rv ) const;
 //			epdf* marginal ( const RV &rv ) const;
 			//!@}
@@ -791,5 +792,5 @@
 	 only allow diagonal covariances!
 
-	Density of the form \f$ \log(x)\sim \mathcal{N}(\mu,\sigma^2), i.e.
+	Density of the form \f$ \log(x)\sim \mathcal{N}(\mu,\sigma^2) \f$ , i.e.
 	\f[
 	x \sim \frac{1}{x\sigma\sqrt{2\pi}}\exp{-\frac{1}{2\sigma^2}(\log(x)-\mu)}
@@ -1017,4 +1018,5 @@
 			//!@{
 			eEmp ( ) :epdf ( ),w ( ),samples ( ) {};
+			//! copy constructor
 			eEmp ( const eEmp &e ) : epdf ( e ), w ( e.w ), samples ( e.samples ) {};
 			//!@}
@@ -1087,4 +1089,17 @@
 
 	template<class sq_T>
+	void enorm<sq_T>::from_setting(const Setting &root){
+		vec mu;
+		UI::get(mu,root,"mu");
+		mat R;
+		UI::get(R,root,"R");
+		set_parameters(mu,R);
+		
+		RV* r = UI::build<RV>(root,"rv");
+		set_rv(*r); 
+		delete r;
+	}
+
+	template<class sq_T>
 	void enorm<sq_T>::dupdate ( mat &v, double nu )
 	{
Index: /bdm/stat/emix.h
===================================================================
--- /bdm/stat/emix.h (revision 361)
+++ /bdm/stat/emix.h (revision 378)
@@ -234,5 +234,10 @@
 	/*!\brief Constructor from list of mFacs,
 	*/
-	mprod ( Array<mpdf*> mFacs ) : compositepdf ( mFacs ), mpdf (), epdfs ( n ), dls ( n ) {
+	mprod (){};
+	mprod (Array<mpdf*> mFacs ){set_elements( mFacs );};
+	void set_elements(Array<mpdf*> mFacs ) {
+		
+		set_elements(mFacs);
+		
 		ep=&dummy;
 		RV rv=getrv ( true );
@@ -240,10 +245,10 @@
 		setrvc ( ep->_rv(),rvc );
 		// rv and rvc established = > we can link them with mpdfs
-		for ( int i = 0;i < n;i++ ) {
+		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<n;i++ ) {
+		for ( int i=0; i<mpdfs.length(); i++ ) {
 			epdfs ( i ) =& ( mpdfs ( i )->_epdf() );
 		}
@@ -253,5 +258,5 @@
 		int i;
 		double res = 0.0;
-		for ( i = n - 1;i >= 0;i-- ) {
+		for ( i = mpdfs.length() - 1;i >= 0;i-- ) {
 			/*			if ( mpdfs(i)->_rvc().count() >0) {
 							mpdfs ( i )->condition ( dls ( i )->get_cond ( val,cond ) );
@@ -272,5 +277,5 @@
 		vec smpi;
 		// Hard assumption here!!! We are going backwards, to assure that samples that are needed from smp are already generated!
-		for ( int i = ( n - 1 );i >= 0;i-- ) {
+		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!!
Index: /bdm/stat/libBM.h
===================================================================
--- /bdm/stat/libBM.h (revision 377)
+++ /bdm/stat/libBM.h (revision 378)
@@ -575,6 +575,7 @@
 };
 
-//!\brief Abstract composition of pdfs, will be used for specific classes
+//!\brief Chain rule of pdfs - abstract part common for mprod and merger. 
 //!this abstract class is common to epdf and mpdf
+//!\todo Think of better design - global functions rv=get_rv(Array<mpdf*> mpdfs); ??
 class compositepdf
 {
Index: /tests/mixef_test.m
===================================================================
--- /tests/mixef_test.m (revision 378)
+++ /tests/mixef_test.m (revision 378)
@@ -0,0 +1,12 @@
+itload('../mixef_test.it');
+
+figure(1);
+hold off;
+plot(Smp(1,:), Smp(2,:),'.');
+hold on
+xv=-5:0.1:5;
+X = ones(size(xv))'*xv;
+Y = xv'*ones(size(xv));
+
+contour(X,Y,PPdf)
+
Index: /tests/blas_test.m
===================================================================
--- /tests/blas_test.m (revision 378)
+++ /tests/blas_test.m (revision 378)
@@ -0,0 +1,59 @@
+function test
+
+vn = [5,50,200,500]
+if 0
+	et =zeros(1,4);
+	et2 =zeros(1,4);
+
+	idn = 1;
+	vn = [5,50,200,500]
+	for n= vn
+		A=rand(n);B=rand(n);C=rand(n);
+		tic;
+		for i=1:10
+			C=matmult(A,B);
+		end
+		et(idn) = toc;
+
+		tic;
+		for i=1:10
+			C=A*B;
+		end
+		et2(idn) = toc;
+
+		idn =idn+1;
+	end
+	save blas_test
+else
+	load blas_test
+end
+
+itload('../blas_test.it')
+
+figure
+plot(vn,et)
+hold on
+plot(vn,et2,'r');
+plot(vn,exec_times,'--')
+plot(vn,exec_times_b,'r--')
+plot(vn,exec_times_c,'g--')
+title('For cycle vs. BLAS');
+ylabel('execution time');
+xlabel('matrix size');
+set(gca,'YScale','log')
+set(gca,'XScale','log')
+set(gcf,'PaperPositionMode','auto');
+
+legend('matlab for','matlab blas','IT++ for','IT++ blas','C array')
+
+
+function C=matmult(A,B)
+for i=1:size(A,1)
+	for j=1:size(A,2)
+		sum=0;
+		for k=1:size(A,2)
+			sum=sum+A(i,k)*B(k,j);
+		end
+		C(i,j)=sum;
+	end
+end
Index: /tests/testKF.m
===================================================================
--- /tests/testKF.m (revision 378)
+++ /tests/testKF.m (revision 378)
@@ -0,0 +1,84 @@
+function testKF(skipgen)
+if nargin<1, skipgen=0; end
+
+if ~skipgen
+	A=[1 -0.5; 1 0];
+	B=[1;0.1];
+	C=[1 0];%; 0 1];
+	D=0.1;%[0.1; 0];
+	R=0.01;%[1 0; 0 0.1];
+	Q=[0.2 0 ; 0 0.2]; 
+
+	sQ = chol(Q)';
+	sR = chol(R)';
+
+	N =3000;
+	mu0 = [0;0];
+	P0 = 200*eye(2);
+
+	u = zeros(1,N);
+	x = zeros(2,N);
+	y = zeros(1,N);
+
+	x(:,1) = [10;10];
+	Et = sQ*randn(2,N);
+	Wt = sR*randn(1,N);
+	for i=2:N;
+		x(:,i) = A*x(:,i-1) + B*u(i) + Et(:,i);
+		y(:,i) = C*x(:,i) + D*u(i) + Wt(:,1);
+	end
+
+	d=[y;u];
+	itsave('testKF.it',d,A,B,C,D,Q,R,P0,mu0)
+	save testKF
+else
+	load testKF
+end
+% init 
+mu = mu0;
+P = P0;
+EP = [0;0];
+
+Oxt = mu0;
+OPt = P0;
+ll =0;
+oxt = mu0;
+oPt = chol(P0)';
+oll=0;
+
+tic;
+for t=2:N
+	mu = A*mu + B*u(t);
+	P  = A*P*A' + Q;
+
+	%Data update
+	Ry = C*P*C' + R;
+	iRy = inv(Ry);
+	K = P*C'*iRy; 
+	P = P- K*C*P; % P = P -KCP;
+	mu = mu + K*(y(:,t)-C*mu-D*u(t));
+	Mu(1:2,t)=mu;
+
+  	[Oxt,OPt,ll(t)] = Kalman(Oxt,y(:,t),A,C,Q,R,OPt);
+%	[oxt,oPt,oll(t)] = KalmanSq(oxt,y(:,t),A,C,sQ,sR,oPt);
+  	MuK(1:2,t) = Oxt;
+%	MuS(1:2,t) = oxt;
+end
+exec_matlab = toc
+%keyboard
+
+!cd ../;./tests/testKF
+itload('testKF_res.it');
+
+hold off
+plot(x');
+hold on
+plot([xth]','--'); % shift the predldmatictions
+plot(xth2','+');
+plot(xthE','o');
+plot([zeros(size(xth,1),1) MuK]','d'); % shift the predictions
+
+exec_times
+exec_matlab./exec_times
+keyboard
+end
Index: /tests/emix_test.m
===================================================================
--- /tests/emix_test.m (revision 378)
+++ /tests/emix_test.m (revision 378)
@@ -0,0 +1,5 @@
+itload('../emix_test.it');
+
+figure(1);
+hold off;
+plot(Smp(1,:), Smp(2,:),'.');
Index: /tests/testKF_big.m
===================================================================
--- /tests/testKF_big.m (revision 378)
+++ /tests/testKF_big.m (revision 378)
@@ -0,0 +1,89 @@
+function testKF(skipgen)
+if nargin<1, skipgen=0; end
+
+if ~skipgen
+	dimx = 30;
+	Apom=rand(dimx);
+	Apom2 = Apom*Apom';
+	A = Apom2/max(1.1*eig(Apom2));
+	B=ones(dimx,1);
+	C=eye(dimx);
+	D=ones(dimx,1);
+	R=0.1*eye(dimx);
+	Q=0.2*eye(dimx); 
+
+	sQ = chol(Q)';
+	sR = chol(R)';
+
+	N =1000;
+	mu0 = zeros(dimx,1);
+	P0 = 200*eye(dimx);
+
+	u = rand(1,N);
+	x = zeros(dimx,N);
+	y = zeros(dimx,N);
+
+	x(:,1) = 10*ones(dimx,1);
+	Et = sQ*randn(dimx,N);
+	Wt = sR*randn(dimx,N);
+	for i=2:N;
+		x(:,i) = A*x(:,i-1) + B*u(i) + Et(:,i);
+		y(:,i) = C*x(:,i) + D*u(i) + Wt(:,1);
+	end
+
+	d=[y;u];
+	itsave('testKF.it',d,A,B,C,D,Q,R,P0,mu0)
+	save testKF
+else
+	load testKF
+end
+% init 
+mu = mu0;
+P = P0;
+EP = [0;0];
+
+Oxt = mu0;
+OPt = P0;
+ll =0;
+Oxt2 = mu0;
+OPt2 = P0;
+ll2=0;
+
+tic;
+for t=2:N
+	mu = A*mu + B*u(t);
+	P  = A*P*A' + Q;
+
+	%Data update
+	Ry = C*P*C' + R;
+	iRy = inv(Ry);
+	K = P*C'*iRy; 
+	P = P- K*C*P; % P = P -KCP;
+	mu = mu + K*(y(:,t)-C*mu-D*u(t));
+	Mu(1:dimx,t)=mu;
+
+%	[Oxt,OPt,ll(t)] = Kalman(Oxt,y(:,t),A,C,Q,R,OPt);
+%	[Oxt2,OPt2,ll2(t)] = Kalman(Oxt2,y(:,t),A,C,Q,R/10000,OPt2);
+end
+exec_matlab = toc
+
+!cd ../;./tests/testKF
+itload('testKF_res.it');
+
+hold off
+plot(x');
+hold on
+plot(xth','--');
+plot(xth2','+');
+plot(xthE','o');
+plot(Mu','d');
+
+max(max(x(:,2:end) - xth(:,1:end-1)))
+max(max(x - xth2))
+max(max(x - xthE))
+max(max(x - Mu))
+
+exec_times
+exec_matlab./exec_times
+keyboard
+end
