Index: /library/bdm/estim/kalman.cpp
===================================================================
--- /library/bdm/estim/kalman.cpp (revision 739)
+++ /library/bdm/estim/kalman.cpp (revision 744)
@@ -264,6 +264,8 @@
 	int active_x = y_block_size;
 	for ( int r = 0; r < urv.length(); r++ ) {
-		diagonal_part ( this->A, active_x + urv.size ( r ), active_x, u_block_sizes ( r ) - urv.size ( r ) );
-		this->B.set_submatrix ( active_x, 0, eye ( urv.size ( r ) ) );
+		if (u_block_sizes(r)>0){
+			diagonal_part ( this->A, active_x + urv.size ( r ), active_x, u_block_sizes ( r ) - urv.size ( r ) );
+			this->B.set_submatrix ( active_x, 0, eye ( urv.size ( r ) ) );
+		}
 		active_x += u_block_sizes ( r );
 	}
Index: /library/bdm/estim/ekf_template.h
===================================================================
--- /library/bdm/estim/ekf_template.h (revision 477)
+++ /library/bdm/estim/ekf_template.h (revision 744)
@@ -22,6 +22,6 @@
 public:
 	void condition ( const vec &QR0 ) {
-		Q = diag ( QR0 ( 0, dimx - 1 ) );
-		R = diag ( QR0 ( dimx, dimx + dimy - 1 ) );
+		Q = diag ( QR0 ( 0, dimension() - 1 ) );
+		R = diag ( QR0 ( dimension(), dimension() + dimy - 1 ) );
 	};
 };
@@ -30,9 +30,19 @@
 class EKFCh_dQ : public EKFCh {
 public:
-	void condition ( const vec &Q0 ) {
-		Q.setD ( Q0, 0 );
+	BM* _copy_() const {return new EKFCh_dQ(*this);}
+	//! new bayes, expects cond = [ut, Qt]
+	void bayes( const vec &yt , const vec &cond) {
+		vec ut=cond.left(dimc-dimension());
+		vec dQt=cond.right(dimension());
+		Q.setD ( dQt, 0 );
 		//from EKF
-		preA.set_submatrix ( dimy + dimx, dimy, Q._Ch() );
+		preA.set_submatrix ( dimy + dimension(), dimy, Q._Ch() );
+		
+		EKFCh::bayes(yt,ut);
 	};
+	void validate() {
+		EKFCh::validate();
+		dimc += dimension();
+	}
 };
 
@@ -43,5 +53,5 @@
 		Q.setCh ( chQ0 );
 		//from EKF
-		preA.set_submatrix ( dimy + dimx, dimy, Q._Ch() );
+		preA.set_submatrix ( dimy + dimension(), dimension(), Q._Ch() );
 	};
 };
Index: /library/bdm/estim/kalman.h
===================================================================
--- /library/bdm/estim/kalman.h (revision 739)
+++ /library/bdm/estim/kalman.h (revision 744)
@@ -336,8 +336,5 @@
 	//! copy constructor duplicated - calls different set_parameters
 	BM* _copy_() const {
-		EKFCh* E = new EKFCh;
-		E->set_parameters ( pfxu, phxu, Q, R );
-		E->set_statistics ( est._mu(), est._R() );
-		return E;
+		return new EKFCh(*this);
 	}
 	//! Set nonlinear functions for mean values and covariance matrices.
Index: /library/bdm/estim/particles.h
===================================================================
--- /library/bdm/estim/particles.h (revision 739)
+++ /library/bdm/estim/particles.h (revision 744)
@@ -267,7 +267,9 @@
 	MPF () :  jest ( pf, BMs ) {};
 	//! set all parameters at once
-	void set_parameters ( shared_ptr<pdf> par0, shared_ptr<pdf> obs0, int n0, RESAMPLING_METHOD rm = SYSTEMATIC ) {
-		pf->set_model ( par0, obs0 );
+	void set_pf ( shared_ptr<pdf> par0, int n0, RESAMPLING_METHOD rm = SYSTEMATIC ) {
+		if (!pf) pf=new PF;
+		pf->set_model ( par0, par0 ); // <=== nasty!!!
 		pf->set_parameters ( n0, rm );
+		pf->set_rv(par0->_rv());
 		BMs.set_length ( n0 );
 	}
@@ -298,4 +300,5 @@
 		return BMs ( i );
 	}
+	PF& _pf() {return *pf;}
 
 	/*! configuration structure for basic PF
Index: /library/bdm/design/ctrlbase.cpp
===================================================================
--- /library/bdm/design/ctrlbase.cpp (revision 738)
+++ /library/bdm/design/ctrlbase.cpp (revision 744)
@@ -13,5 +13,5 @@
 	//penalization
 	qux.set_submatrix ( 0, 0, Qu._Ch() );
-	qux.set_submatrix ( 0, dimx + dimu + dimy, Qu._Ch() );
+	qux.set_submatrix ( 0, dimx + dimu + dimy, -Qu._Ch() );
 
 	qyx.set_submatrix ( 0, 0, S->_C() );
@@ -57,6 +57,6 @@
 
 void LQG::ricatti_step() {
-	pre_qr.set_submatrix ( 0, 0, s*pr );
-	pre_qr.set_submatrix ( dimx + dimu + dimy, dimu + dimx, -Qy.to_mat() *y_req );
+//	pre_qr.set_submatrix ( 0, 0, s*pr );
+//	pre_qr.set_submatrix ( dimx + dimu + dimy, dimu + dimx, -Qy.to_mat() *y_req );
 	if ( !qr ( pre_qr, post_qr ) ) {
 		bdm_warning ( "QR in LQG unstable" );
Index: /library/bdm/design/arx_ctrl.h
===================================================================
--- /library/bdm/design/arx_ctrl.h (revision 737)
+++ /library/bdm/design/arx_ctrl.h (revision 744)
@@ -124,4 +124,5 @@
 		lq.validate();
 
+		rv = urvm; // rv is not shifted to t+1!!
 		rvc = concat ( xrv, urvm );
 		rvc2ar_y.set_connection ( ar->_yrv(), rvc );
Index: /library/bdm/base/bdmbase.h
===================================================================
--- /library/bdm/base/bdmbase.h (revision 741)
+++ /library/bdm/base/bdmbase.h (revision 744)
@@ -1096,4 +1096,8 @@
 		yrv = rv;
 	}
+	//! access function
+	void set_rvc ( const RV &rv ) {
+		rvc = rv;
+	}
 	//! access to rv of the posterior
 	void set_rv ( const RV &rv ) {
Index: /library/bdm/base/bdmbase.cpp
===================================================================
--- /library/bdm/base/bdmbase.cpp (revision 738)
+++ /library/bdm/base/bdmbase.cpp (revision 744)
@@ -495,10 +495,10 @@
 void datalink_buffered::set_connection ( const RV &rv, const RV &rv_up ) {
 	// create link between up and down
-	datalink_part::set_connection ( rv, rv_up.remove_time() ); // only non-delayed version
+	datalink_part::set_connection ( rv, rv_up); // only non-delayed version
 
 	// create rvs of history
 	// we can store only what we get in rv_up - everything else is removed
-	ivec valid_ids = rv.findself_ids ( rv_up );
-	RV rv_hist = rv.subselect ( find ( valid_ids >= 0 ) ); // select only rvs that are in rv_up
+	ivec valid_ids = rv.findself_ids ( rv_up ); // return on which position each id is
+	RV rv_hist = rv.subselect ( find ( valid_ids >= 0 ) ); // select only rvs that are in rv_up, ie ind>0
 	RV rv_hist0 = rv_hist.remove_time(); // these RVs will form history at time =0
 	// now we need to know what is needed from Up
Index: /applications/bdmtoolbox/Doxyfile
===================================================================
--- /applications/bdmtoolbox/Doxyfile (revision 613)
+++ /applications/bdmtoolbox/Doxyfile (revision 744)
@@ -26,5 +26,5 @@
 INLINE_INHERITED_MEMB  = YES
 FULL_PATH_NAMES        = NO
-STRIP_FROM_PATH        = /home/smidl/
+STRIP_FROM_PATH        = /home/smidl/work/git/mixpp
 STRIP_FROM_INC_PATH    = 
 SHORT_NAMES            = NO
@@ -246,5 +246,5 @@
 # configuration options related to the XML output
 #---------------------------------------------------------------------------
-GENERATE_XML           = yes
+GENERATE_XML           = NO
 XML_OUTPUT             = xml
 XML_SCHEMA             = 
Index: /applications/bdmtoolbox/tutorial/merging/merge_frag.m
===================================================================
--- /applications/bdmtoolbox/tutorial/merging/merge_frag.m (revision 706)
+++ /applications/bdmtoolbox/tutorial/merging/merge_frag.m (revision 744)
@@ -16,5 +16,5 @@
 Merger.ncoms=20;
 Merger.stop_niter=50;
-Merger.effss_coef=1;
+Merger.effss_coef=0.9;
 %Merger.dbg_file='merger_mix_dbg';
 
@@ -32,6 +32,7 @@
     'R',1);
 % 2D support
-support2.grid={[-5,5],[0.001,9]};
-support2.nbins=[30,30];
+support2.class='rectangular_support';
+support2.ranges={[-5,5],[0.001,9]};
+support2.gridsizes=[30,30];
 
 % 2D
Index: /applications/bdmtoolbox/tutorial/userguide/arx_ctrl_example.m
===================================================================
--- /applications/bdmtoolbox/tutorial/userguide/arx_ctrl_example.m (revision 724)
+++ /applications/bdmtoolbox/tutorial/userguide/arx_ctrl_example.m (revision 744)
@@ -1,11 +1,12 @@
 % name random variables
 y = RV({'y'},1);
-u = RV({'u'},1);
+u1 = RV({'u1'},1);
+u2 = RV({'u2'},1);
 
 % create f(y_t| y_{t-3}, u_{t-1})
 fy.class = 'mlnorm<ldmat>';
 fy.rv    = y;
-fy.rvc   = RVtimes([y,u], [-3, -1]);
-fy.A     = [0.5, -0.9];
+fy.rvc   = RVtimes([y,u1,u2], [-3, 0, 0]);
+fy.A     = [0.5, -0.9, 0.9];
 fy.const = 0;
 fy.R     = 1e-2;
@@ -17,13 +18,16 @@
 A1.class = 'ARX';
 A1.rv = y;
-A1.rgr = RVtimes([y,u],[-3,-1]) ; % correct structure is {y,y}
+A1.rgr = RVtimes([y,u1,u2],[-3,0,0]) ; % correct structure is {y,y}
 A1.options ='logbounds,logll';
 
 C1.class = 'LQG_ARX';
 C1.ARX = A1;
-C1.Qu = 0.1*eye(1);
+C1.Qu = 0.1*eye(2);
 C1.Qy = eye(1);
 C1.yreq = 1;
 C1.horizon = 100;
 
+% participant 1
+Cp1.
+
 M= controlloop(DS,{C1});
Index: /applications/bdmtoolbox/tutorial/userguide/dist_ctrl_example.m
===================================================================
--- /applications/bdmtoolbox/tutorial/userguide/dist_ctrl_example.m (revision 744)
+++ /applications/bdmtoolbox/tutorial/userguide/dist_ctrl_example.m (revision 744)
@@ -0,0 +1,66 @@
+% name random variables
+y = RV({'y'},1);
+u1 = RV({'u1'},1);
+u2 = RV({'u2'},1);
+
+% create f(y_t| y_{t-3}, u_{t-1})
+fy.class = 'mlnorm<ldmat>';
+fy.rv    = y;
+fy.rvc   = RVtimes([y,u1,u2], [-3, 0, 0]);
+fy.A     = [0.5, -0.9, 0.9];
+fy.const = 0;
+fy.R     = 1e-2;
+
+DS.class = 'PdfDS';
+DS.pdf = fy;
+
+% create ARX estimator
+A1.class = 'ARX';
+A1.rv = y;
+A1.rgr = RVtimes([y,u1],[-3,0]) ; % correct structure is {y,y}
+A1.options ='logbounds,logll';
+A1.frg = 0.95;
+
+A2=A1;
+A2.rgr = RVtimes([y,u2],[-3,0]) ; % correct structure is {y,y}
+
+
+C1.class = 'LQG_ARX';
+C1.ARX = A1;
+C1.Qu = 0.1*eye(1);
+C1.Qy = 1*eye(1);
+C1.yreq = 1;
+C1.horizon = 100;
+
+C2=C1;
+C2.ARX = A2;
+
+M= controlloop(DS,{C1,C2});
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%       PLOTS
+
+figure(1);
+hold off
+subplot(1,2,1);
+plot(M.DS_y);
+subplot(1,2,2);
+plot(M.DS_u1); hold on;
+plot(M.DS_u2); 
+
+figure(2);
+hold off
+plot(M.Ctrl0_apost_mean_theta);
+hold on
+plot(M.Ctrl0_apost_ub_theta,':');
+plot(M.Ctrl0_apost_lb_theta,':');
+set(gca,'YLim',[-4,2]);
+
+figure(3);
+hold off
+plot(M.Ctrl1_apost_mean_theta);
+hold on
+plot(M.Ctrl1_apost_ub_theta,':');
+plot(M.Ctrl1_apost_lb_theta,':');
+set(gca,'YLim',[-2,3]);
Index: /applications/bdmtoolbox/mex/controlloop.cpp
===================================================================
--- /applications/bdmtoolbox/mex/controlloop.cpp (revision 723)
+++ /applications/bdmtoolbox/mex/controlloop.cpp (revision 744)
@@ -7,7 +7,10 @@
 digraph estimation{
 	node [shape=box];
-	{rank="same"; "Data Source"; "Bayesian Model"}
-	"Data Source" -> "Bayesian Model" [label="data"];
-	"Bayesian Model" -> "Result Logger" [label="estimated\n statistics"];
+	subgraph cl0 {
+	"Data Source" -> "Controller" [label="observations"];
+	"Controller" -> "Data Source" [label="actions"];
+	}
+	{rank="same"; "Controller"; "Result Logger"}
+	"Controller" -> "Result Logger" [label="internals"];
 	"Data Source" -> "Result Logger" [label="Simulated\n data"];
 }
@@ -87,15 +90,5 @@
 		if ( n_input>3 ) {
 			Cfg.addGroup ( input[3],"logger" );
-		}/*else{
-		// define logger as mexlog
-		Setting &S=Cfg.getRoot();
-		S.add("logger",Setting::TypeGroup);
-		S["logger"].add("class",Setting::TypeString);
-		S["logger"]["class"]="mexlog";
-		S["logger"].add("maxlen",Setting::TypeInt);
-		int maxlen;
-		S["experiment"].lookupValue("ndat",maxlen);
-		S["logger"]["maxlen"]=maxlen;
-	}*/
+		}
 	} catch ( SettingException e ) {
 		it_error ( "error: "+string ( e.getPath() ) );
@@ -116,8 +109,11 @@
 #endif
 
+	RNG_randomize();
+	
 	shared_ptr<DS> Ds = UI::build<DS> ( Cfg, "system" );
 	Array<shared_ptr<Controller> > Cs;
 	UI::get ( Cs,Cfg, "controllers" );
 	int Ndat=100;
+	int burnin=10;
 	if ( Cfg.exists ( "experiment" ) ) {
 		if ( Cfg.getRoot().lookupValue ( "experiment.ndat",Ndat ) ) {
@@ -178,4 +174,5 @@
 	}
 
+	vec ut(Ds->_urv()._dsize());
 	for ( int tK=0;tK<Ndat;tK++ ) {
 		Ds->getdata ( dt );					// read data
@@ -186,12 +183,15 @@
 				Cs(i) -> redesign();
 				Cs(i) -> adapt( Dlsc(i) ->pushdown(dt));
-				vec ut=Cs ( i )->ctrlaction ( Dlsc(i) ->pushdown(dt) );		// update estimates
-				Ds->write(ut, vec_1(0));
+			}
+			if (tK > burnin){
+				vec uti=Cs ( i )->ctrlaction ( Dlsc(i) ->pushdown(dt) );		// update estimates
+				Dlsu(i)->filldown(uti, ut);
 			} else {
-				Ds->write(0.001*randn(Ds->_urv()._dsize()));
+				ut = 0.1*randn(Ds->_urv()._dsize());
 			}
 			
 			Cs ( i )->log_write ();
 		}
+		Ds->write(ut);
 		
 		L->step();
Index: /applications/pmsm/pmsmDS.h
===================================================================
--- /applications/pmsm/pmsmDS.h (revision 686)
+++ /applications/pmsm/pmsmDS.h (revision 744)
@@ -118,12 +118,12 @@
     void log_register ( logger &L )
     {
-        L_x = L.add ( rx, "x" );
-        L_oy = L.add ( ry, "o" );
-        L_ou = L.add ( ru, "o" );
-        L_iu = L.add ( ru, "t" );
+        L_x = L.add_vector ( rx, "x" );
+        L_oy = L.add_vector ( ry, "o" );
+        L_ou = L.add_vector ( ru, "o" );
+        L_iu = L.add_vector ( ru, "t" );
         // log differences
         if ( opt_modu )
         {
-            L_optu = L.add ( ru, "model" );
+            L_optu = L.add_vector ( ru, "model" );
         }
     }
@@ -131,8 +131,8 @@
     void log_write ( logger &L )
     {
-        L.logit ( L_x, vec ( x,4 )	);
-        L.logit ( L_oy, vec_2 ( KalmanObs[2],KalmanObs[3] ) );
-        L.logit ( L_ou, vec_2 ( KalmanObs[0],KalmanObs[1] ) );
-        L.logit ( L_iu, vec_2 ( KalmanObs[4],KalmanObs[5] ) );
+        L.log_vector ( L_x, vec ( x,4 )	);
+        L.log_vector ( L_oy, vec_2 ( KalmanObs[2],KalmanObs[3] ) );
+        L.log_vector ( L_ou, vec_2 ( KalmanObs[0],KalmanObs[1] ) );
+        L.log_vector ( L_iu, vec_2 ( KalmanObs[4],KalmanObs[5] ) );
         if ( opt_modu )
         {
@@ -151,5 +151,5 @@
             ua = ( 2.0* ( u1-du1 )- ( u2-du2 )- ( u3-du3 ) ) /3.0;
             ub = ( ( u2-du2 )- ( u3-du3 ) ) /sq3;
-            L.logit ( L_optu , vec_2 ( ua,ub ) );
+            L.log_vector ( L_optu , vec_2 ( ua,ub ) );
         }
 
@@ -238,13 +238,13 @@
     void log_add(logger &L, const string &name="" )
     {
-        L_CRB=L.add(rx,"crb");
-        L_err=L.add(rx,"err");
-        L_sec=L.add(rx,"d2");
+        L_CRB=L.add_vector(rx,"crb");
+        L_err=L.add_vector(rx,"err");
+        L_sec=L.add_vector(rx,"d2");
     }
     void logit(logger &L)
     {
-        L.logit(L_err, interr);
-        L.logit(L_CRB,diag(_R()));
-        L.logit(L_sec,secder);
+        L.log_vector(L_err, interr);
+        L.log_vector(L_CRB,diag(_R()));
+        L.log_vector(L_sec,secder);
     }
 
@@ -322,9 +322,9 @@
     void log_add(logger &L, const string &name="" )
     {
-        L_CRB=L.add(concat(rx,RV("Mz",1,0)),"crbz");
+        L_CRB=L.add_vector(concat(rx,RV("Mz",1,0)),"crbz");
     }
     void logit(logger &L)
     {
-        L.logit(L_CRB,diag(_R()));
+        L.log_vector(L_CRB,diag(_R()));
     }
 
Index: /applications/pmsm/TR2245/unitsteps.cpp
===================================================================
--- /applications/pmsm/TR2245/unitsteps.cpp (revision 706)
+++ /applications/pmsm/TR2245/unitsteps.cpp (revision 744)
@@ -15,5 +15,5 @@
 #include <estim/particles.h>
 #include <estim/ekf_template.h>
-#include <stat/functions.h>
+#include <base/loggers.h>
 
 
@@ -21,6 +21,4 @@
 #include "simulator.h"
 #include "../sim_profiles.h"
-#include "user_info.h"
-#include "stat/loggers.h"
 
 using namespace bdm;
@@ -41,5 +39,5 @@
 	F.lookupValue ( "ndat", Ndat );
 	F.lookupValue ( "Npart",Npart );
-	pdf* evolQ = UI::build<pdf>( F, "Qrw" );
+	shared_ptr<pdf> evolQ = UI::build<pdf>( F, "Qrw" );
 	vec Qdiag;
 	vec Rdiag;
@@ -49,9 +47,9 @@
 	// internal model
 
-IMpmsm fxu;
+	shared_ptr<IMpmsm> fxu= new IMpmsm;
 //                  Rs    Ls        dt       Fmag(Ypm)    kp   p    J     Bf(Mz)
-fxu.set_parameters ( 0.28, 0.003465, Nsimstep*h, 0.1989, 1.5 ,4.0, 0.04, 0.0 );
+	fxu->set_parameters ( 0.28, 0.003465, Nsimstep*h, 0.1989, 1.5 ,4.0, 0.04, 0.0 );
 	// observation model
-	OMpmsm hxu;
+	shared_ptr<OMpmsm> hxu=new OMpmsm;
 
 	vec mu0= "0.0 0.0 0.0 0.0";
@@ -59,31 +57,38 @@
 	chmat R ( Rdiag );
 	EKFCh KFE ;
-	KFE.set_parameters ( &fxu,&hxu,Q,R );
-	KFE.set_est ( mu0, chmat ( zeros ( 4 ) ) );
+	KFE.set_parameters ( fxu,hxu,Q,R );
+	KFE.set_statistics ( mu0, chmat ( zeros ( 4 ) ) );
 	KFE.set_rv ( rx );
+	KFE.validate();
 
 	RV rQ ( "{Q }","4" );
+	RV rU ("{u }","2");
+	RV rY ("{y }","2");
 	EKFCh_dQ KFEp ;
-	KFEp.set_parameters ( &fxu,&hxu,Q,R );
-	KFEp.set_est ( mu0, chmat ( zeros ( 4 ) ) );
+	KFEp.set_parameters ( fxu,hxu,Q,R );
+	KFEp.set_statistics ( mu0, chmat ( zeros ( 4 ) ) );
+	KFEp.set_rv(rx);
+	KFEp.set_yrv(rY); 
+	KFEp.set_rvc(concat(rU, rQ)); 
+	KFEp.validate();
 
-	MPF<EKFCh_dQ> M;
-	M.set_parameters ( evolQ,evolQ,Npart );
-	// initialize
-	evolQ->condition ( 10*Qdiag ); //Zdenek default
-	M.set_statistics ( evolQ->_e() , &KFEp );
-	//
+	MPF M;
+	evolQ->set_rv(rQ);
+	M.set_pf ( evolQ,Npart );
+	M._pf().set_statistics(ones(Npart), euni(zeros(4),2*Qdiag));
+	M.set_BM(KFEp);
+	M.set_yrv ( rY   );
+	M.set_rvc ( rU   );
+	M.validate();
 
-	M.set_rv ( concat ( rQ,rx ) );
-
-	dirfilelog *L = UI::build<dirfilelog>( F, "logger" );// ( "exp/mpf_test",100 );
-	int l_X = L->add ( rx, "xt" );
-	int l_D = L->add ( concat ( ry,ru ), "" );
-	int l_Q= L->add ( rQ, "" );
+	shared_ptr<dirfilelog> L = UI::build<dirfilelog>( F, "logger" );// ( "exp/mpf_test",100 );
+	int l_X = L->add_vector ( rx, "xt" );
+	int l_D = L->add_vector ( concat ( ry,ru ), "" );
+	int l_Q= L->add_vector ( rQ, "" );
 
 	KFE.set_options ( "logbounds" );
-	KFE.log_add ( *L,"KF" );
+	KFE.log_register ( *L,"KF" );
 	M.set_options ( "logbounds" );
-	M.log_add ( *L,"M" );
+	M.log_register ( *L,"M" );
 	L->init();
 
@@ -107,6 +112,6 @@
 		ut ( 0 ) = KalmanObs[4];
 		ut ( 1 ) = KalmanObs[5];
-		xt = fxu.eval ( xtm,ut ) + diag ( sqrt ( Qdiag ) ) *randn ( 4 );
-		dt = hxu.eval ( xt,ut );
+		xt = fxu->eval ( xtm,ut ) + diag ( sqrt ( Qdiag ) ) *randn ( 4 );
+		dt = hxu->eval ( xt,ut ) + diag(sqrt(Rdiag))*randn(2);
 		xtm = xt;
 
@@ -122,13 +127,13 @@
 
 		//estimator
-		KFE.bayes ( concat ( dt,ut ) );
-		M.bayes ( concat ( dt,ut ) );
+		KFE.bayes (  dt,ut  );
+		M.bayes ( dt,ut );
 
-		L->logit ( l_X,xt );
-		L->logit ( l_D,concat ( dt,ut ) );
-		L->logit ( l_Q,Qdiag );
+		L->log_vector ( l_X,xt );
+		L->log_vector ( l_D,concat ( dt,ut ) );
+		L->log_vector ( l_Q,Qdiag );
 
-		KFE.logit ( *L );
-		M.logit ( *L );
+		KFE.log_write ( );
+		M.log_write (  );
 		L->step();
 	}
@@ -136,5 +141,4 @@
 	//Exit program:
 
-	delete L;
 	return 0;
 }
Index: /applications/pmsm/TR2245/unitsteps.cfg
===================================================================
--- /applications/pmsm/TR2245/unitsteps.cfg (revision 294)
+++ /applications/pmsm/TR2245/unitsteps.cfg (revision 744)
@@ -1,17 +1,17 @@
 ndat = 9000;
-Npart = 1000;
+Npart = 100;
 
 //simulator 
 profile = [1,2,4,9,4,2,0,-4,-9,-16,-4,0,0];
 
-logger = {type="dirfilelog"; dirname="exp/unitstep"; maxlen=100;};
+logger = {class="dirfilelog"; dirname="kst/unitstep"; maxlen=100;};
 
-Qrw = {type="migamma_ref";
-	ref = [1e-6, 1e-6, 1e-3, 1e-4];
+Qrw = {class="migamma_ref";
+	ref = [1e-4, 1e-4, 1e-3, 1e-4];
 	l = 0.999;
-	k = 0.1;
+	k = 0.06;
 };
 // For EKF
 dQ=[1e-5, 1e-5, 1e-4, 1e-5];
-dR=[1e-8, 1e-8];
+dR=[1e-10, 1e-10];
 
Index: /applications/pmsm/TR2245/CMakeLists.txt
===================================================================
--- /applications/pmsm/TR2245/CMakeLists.txt (revision 294)
+++ /applications/pmsm/TR2245/CMakeLists.txt (revision 744)
@@ -2,3 +2,3 @@
 EXEC (unitsteps pmsmsim)
 EXEC (wishart pmsmsim)
-EXEC (pmsm_wishart pmsmsim)
+#EXEC (pmsm_wishart pmsmsim)
Index: /applications/pmsm/CMakeLists.txt
===================================================================
--- /applications/pmsm/CMakeLists.txt (revision 654)
+++ /applications/pmsm/CMakeLists.txt (revision 744)
@@ -33,3 +33,3 @@
 #EXEC (sim_var pmsmsim)
 
-#add_subdirectory (TR2245)
+add_subdirectory (TR2245)
