Index: /applications/pmsm/Barcelona/QandR.m
===================================================================
--- /applications/pmsm/Barcelona/QandR.m (revision 332)
+++ /applications/pmsm/Barcelona/QandR.m (revision 335)
@@ -27,2 +27,4 @@
 %R
 
+istep=0.085;
+R11 = (istep+istep)^2/12
Index: /applications/pmsm/Barcelona/pwm.cfg
===================================================================
--- /applications/pmsm/Barcelona/pwm.cfg (revision 332)
+++ /applications/pmsm/Barcelona/pwm.cfg (revision 335)
@@ -1,3 +1,3 @@
-# settings for pmsm_estim.cpp
+// settings for pmsm_estim.cpp
 
 experiment={
@@ -15,46 +15,46 @@
 
 estimator = (
-			 {type="EKF";
-			 IM = {type="pmsmIM";
-				params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";};
-				variant = "2o";
-			 };
-			 OM = {type="pmsmOM";};
-			 dQ=[0.17, 0.17, 0.0000004, 1e-11];
-			 dR=[0.0001, 0.0001];
-			 //connect
-			 drv = {type="rv"; names=["o_ia","o_ib","o_ua","o_ub"];};  // observed u
-			 //drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];}; // true u
-			 rv = {type="rv"; names=["EKF"]; sizes=[4];};
-			 options="logbounds";
-			 },
-				 ///////////
- 			 {type="pmsmCRB";
-			 IM = {type="pmsmIM";
-				params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";};
-				variant = "2o";// 2nd order Taylor
-			 };
-			 OM = {type="pmsmOM";};
-			 dQ=[0.017, 0.017, 0.00000004, 1e-12];
-			 dR=[0.0000000001, 0.000000001];
-			 //connect
-			 drv = {type="rv"; names=["o_ia","o_ib","o_ua","o_ub"];};  // observed u
-			 //drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];}; // true u
-			 rv = {type="rv"; names=["EKF"]; sizes=[4];};
-			 },
-				 ///////////
- 			 {type="EKF";
-			 IM = {type="pmsmIM";
-				params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";};
-				variant = "2o";// 2nd order Taylor
-			 };
-			 OM = {type="pmsmOM4";};
-			 dQ=[0.017, 0.017, 0.00000004, 1e-12];
-			 dR=[0.0000000001, 0.000000001, 0.000000001, 0.000000001];
-			 //connect
-			 drv = {type="rv"; names=["o_ia","o_ib","o_om","o_th","o_ua","o_ub"];};  // observed u
-			 //drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];}; // true u
-			 rv = {type="rv"; names=["ekff"]; sizes=[4];};
-			 }
+	{type="EKF";
+	IM = {type="pmsmIM";
+	  params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";};
+	  variant = "2o";
+	};
+	OM = {type="pmsmOM";};
+	dQ=[0.17, 0.17, 0.0000004, 1e-11];
+	dR=[0.0001, 0.0001];
+	//connect
+	drv = {type="rv"; names=["o_ia","o_ib","o_ua","o_ub"];};  // observed u
+	//drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];}; // true u
+	rv = {type="rv"; names=["EKF"]; sizes=[4];};
+	options="logbounds";
+	},
+		///////////
+	{type="pmsmCRB";
+	IM = {type="pmsmIM";
+	  params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";};
+	  variant = "2o";// 2nd order Taylor
+	};
+	OM = {type="pmsmOM";};
+	dQ=[0.017, 0.017, 0.00000004, 1e-12];
+	dR=[0.0000000001, 0.000000001];
+	//connect
+	drv = {type="rv"; names=["o_ia","o_ib","o_ua","o_ub"];};  // observed u
+	//drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];}; // true u
+	rv = {type="rv"; names=["EKF"]; sizes=[4];};
+	},
+		///////////
+	{type="EKF";
+	IM = {type="pmsmIM";
+	  params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";};
+	  variant = "2o";// 2nd order Taylor
+	};
+	OM = {type="pmsmOM4";};
+	dQ=[0.017, 0.017, 0.00000004, 1e-12];
+	dR=[0.0000000001, 0.000000001, 0.000000001, 0.000000001];
+	//connect
+	drv = {type="rv"; names=["o_ia","o_ib","o_om","o_th","o_ua","o_ub"];};  // observed u
+	//drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];}; // true u
+	rv = {type="rv"; names=["ekff"]; sizes=[4];};
+	}
 
 
Index: /applications/pmsm/Barcelona/Mz.cfg
===================================================================
--- /applications/pmsm/Barcelona/Mz.cfg (revision 332)
+++ /applications/pmsm/Barcelona/Mz.cfg (revision 335)
@@ -14,34 +14,52 @@
 
 estimator = (
-			 {type="EKF";
-			 IM = {type="pmsmIM";
-				params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";};
-				variant = "Mz";
-			 };
-			 OM = {type="pmsmOM";};
-			 dQ=[0.17, 0.17, 0.4, 1e-6, 1e-1];
-			 dR=[0.1, 0.1];
-			 dP0=[1., 1., 1., 1., 1e-2];
-			 //connect
-			 drv = {type="rv"; names=["o_ia","o_ib","o_ua","o_ub"];};  // observed u
-			 //drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];}; // true u
-			 rv = {type="rv"; names=["EKFMz"]; sizes=[5];};
-			 //options="logbounds";
-			 },
- 			 {type="EKF";
-			 IM = {type="pmsmIM";
-				params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";};
-				variant = "Stat";
-			 };
-			 OM = {type="pmsmOM";};
-			 dQ=[0.17, 0.17, 0.4, 1e-2];
-			 dR=[0.1, 0.1];
-			 dP0=[1., 1., 1., 1.];
-			 //connect
-			 drv = {type="rv"; names=["o_ia","o_ib","o_ua","o_ub"];};  // observed u
-			 //drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];}; // true u
-			 rv = {type="rv"; names=["EKF"]; sizes=[4];};
-			 //options="logbounds";
-			 }
+	 {type="EKF";
+	 IM = {type="pmsmIM";
+		params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";};
+		variant = "Mz";
+	 };
+	 OM = {type="pmsmOM";};
+	 dQ=[0.17, 0.17, 0.004, 1e-6, 1e-1];
+	 dR=[0.025, 0.025];
+	 dP0=[1., 1., 1., 1., 1e-2];
+	 //connect
+	 drv = {type="rv"; names=["o_ia","o_ib","o_ua","o_ub"];};  // observed u
+	 //drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];}; // true u
+	 rv = {type="rv"; names=["EKFMz"]; sizes=[5];};
+	 options="logll";
+	 },
+				 //
+	 {type="EKF";
+	 IM = {type="pmsmIM";
+		params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";};
+		variant = "2o";
+	 };
+	 OM = {type="pmsmOM";};
+	 dQ=[0.17, 0.17, 0.00004, 1e-8];
+	 dR=[0.025, 0.025];
+	 dP0=[1., 1., 1., 1.];
+	 //connect
+	 drv = {type="rv"; names=["o_ia","o_ib","o_ua","o_ub"];};  // observed u
+	 //drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];}; // true u
+	 rv = {type="rv"; names=["EKF"]; sizes=[4];};
+	 options="logll";
+	 },
+				 				 //
+	 {type="EKF";
+	 IM = {type="pmsmIM";
+		params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";};
+		variant = "Stat";
+	 };
+	 OM = {type="pmsmOM";};
+	 dQ=[0.17, 0.17, 0.004, 1e-5];
+	 dR=[0.025, 0.025];
+	 dP0=[1., 1., 1., 1.];
+	 //connect
+	 drv = {type="rv"; names=["o_ia","o_ib","o_ua","o_ub"];};  // observed u
+	 //drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];}; // true u
+	 rv = {type="rv"; names=["EKFw"]; sizes=[4];};
+	 options="logll";
+	 }
+
 
 );
Index: /plications/pmsm/old/mpf_u_delta.cpp
===================================================================
--- /applications/pmsm/old/mpf_u_delta.cpp (revision 279)
+++  (revision )
@@ -1,199 +1,0 @@
-/*!
-  \file
-  \brief TR 2525 file for testing Toy Problem of mpf for Covariance Estimation
-  \author Vaclav Smidl.
-
-  \ingroup PMSM
-
-  -----------------------------------
-  BDM++ - C++ library for Bayesian Decision Making under Uncertainty
-
-  Using IT++ for numerical operations
-  -----------------------------------
-*/
-
-
-
-#include <estim/libKF.h>
-#include <estim/libPF.h>
-#include <stat/libFN.h>
-
-#include "pmsm.h"
-#include "simulator.h"
-#include "sim_profiles.h"
-
-using namespace bdm;
-
-//!Extended Kalman filter with unknown \c Q and delta u
-class EKFCh_du_kQ : public EKFCh , public BMcond {
-	chmat Qref;
-public:
-	//! Default constructor
-	EKFCh_du_kQ ( ) :EKFCh ( ),BMcond (),Qref() {};
-	void set_ref(const chmat &Qref0){Qref=Qref0;}
-	void condition ( const vec &val ) {
-		pfxu->condition ( val.left(2) );
-		
-		Q = Qref*std::abs(val(2));
-		preA.set_submatrix ( dimy+dimx,dimy,Q._Ch() );
-	};
-};
-
-class IMpmsm_delta :  public IMpmsm {
-protected:
-	vec ud;
-public:
-	IMpmsm_delta() :IMpmsm(),ud ( 2 ) {ud=zeros ( 2 );};
-	//! Set mechanical and electrical variables
-
-	void condition ( const vec &val ) {ud = val;}
-	vec eval ( const vec &x0, const vec &u0 ) {
-		// last state
-		double iam = x0 ( 0 );
-		double ibm = x0 ( 1 );
-		double omm = x0 ( 2 );
-		double thm = x0 ( 3 );
-		double uam = u0 ( 0 );
-		double ubm = u0 ( 1 );
-
-		vec xk=zeros ( 4 );
-		//ia
-		xk ( 0 ) = ( 1.0- Rs/Ls*dt ) * iam + Ypm/Ls*dt*omm * sin ( thm ) + ( uam+ud ( 0 ) ) *dt/Ls;
-		//ib
-		xk ( 1 ) = ( 1.0- Rs/Ls*dt ) * ibm - Ypm/Ls*dt*omm * cos ( thm ) + ( ubm+ud ( 1 ) ) *dt/Ls;
-		//om
-		xk ( 2 ) = omm;// + kp*p*p * Ypm/J*dt* ( ibm * cos ( thm )-iam * sin ( thm ) ) - p/J*dt*Mz;
-		//th
-		xk ( 3 ) = thm + omm*dt; // <0..2pi>
-		if ( xk ( 3 ) >pi ) xk ( 3 )-=2*pi;
-		if ( xk ( 3 ) <-pi ) xk ( 3 ) +=2*pi;
-		return xk;
-	}
-
-};
-
-
-int main() {
-	// Kalman filter
-	int Ndat = 9000;
-	double h = 1e-6;
-	int Nsimstep = 125;
-	int Npart = 20;
-
-	mat Rnoise = randn ( 2,Ndat );
-
-	// internal model
-	IMpmsm2o fxu0;
-	IMpmsm_delta fxu;
-	//                  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 );
-	fxu0.set_parameters ( 0.28, 0.003465, Nsimstep*h, 0.1989, 1.5 ,4.0, 0.04, 0.0 );
-	// observation model
-	OMpmsm hxu;
-
-	vec mu0= "0.0 0.0 0.0 0.0";
-	vec Qdiag ( "0.4 0.4 0.1 0.000001" ); //zdenek: 0.01 0.01 0.0001 0.0001
-	vec Rdiag ( "0.1 0.1" ); //var(diff(xth)) = "0.034 0.034"
-	chmat Q ( Qdiag );
-	mat Q2o=diag(Qdiag);
-	chmat R ( Rdiag );
-	EKFCh KFE ;
-	KFE.set_parameters ( &fxu0,&hxu,Q,R );
-	KFE.set_est ( mu0, chmat ( ones ( 4 ) ) );
-
-	RV rUd ( "{ud k}", "2 1" );
-	EKFCh_du_kQ KFEp ;
-	KFEp.set_parameters ( &fxu,&hxu,Q,R );
-	KFEp.set_ref(Q);
-	KFEp.set_est ( mu0, chmat ( ones ( 4 ) ) );
-
-	mlnorm<ldmat> evolUd ;
-	MPF<EKFCh_du_kQ> M ( &evolUd,&evolUd,Npart,KFEp );
-	// initialize
-	vec Ud0="0 0 1.0";
-	evolUd.set_parameters ( eye ( 3 ), zeros(3), ldmat ( vec( "1e-4 1e-4 10e-4" )));
-	evolUd.condition ( Ud0 );
-	epdf& pfinit=evolUd._epdf();
-	M.set_est ( pfinit );
-	evolUd.set_parameters ( eye ( 3 ), zeros(3), ldmat ( vec(" 7e-4 7e-4 1e-5" )));
-
-	mat Xt=zeros ( Ndat ,4 ); //true state from simulator
-	mat Dt=zeros ( Ndat,2+2+2 ); //observation
-	mat XtE=zeros ( Ndat, 4 );
-	mat Qtr=zeros ( Ndat, 4 );
-	mat XtM=zeros ( Ndat, 3+4 ); //W + x
-	mat XtMTh=zeros ( Ndat,1 );
-
-	// SET SIMULATOR
-	pmsmsim_set_parameters ( 0.28,0.003465,0.1989,0.0,4,1.5,0.04, 200., 3e-6, h );
-	vec dt ( 2 );
-	vec ut ( 2 );
-	vec utm ( 2 );
-	vec xt ( 4 );
-	vec xtm=zeros ( 4 );
-	double Ww=0.0;
-	vec vecW="1 2 4 8 4 2 0 -4 -9 -16 -4 0 0 0";
-	vecW*=10.0;
-
-	for ( int tK=1;tK<Ndat;tK++ ) {
-		//Number of steps of a simulator for one step of Kalman
-		for ( int ii=0; ii<Nsimstep;ii++ ) {
-			//simulator
-			sim_profile_vec01t ( Ww,vecW );
-			pmsmsim_step ( Ww );
-		};
-		ut ( 0 ) = KalmanObs[0];
-		ut ( 1 ) = KalmanObs[1];
-		dt ( 0 ) = KalmanObs[2]+0.3*Rnoise ( 0,t );
-		dt ( 1 ) = KalmanObs[3]+0.3*Rnoise ( 1,t );
-		xt = vec ( x,4 );
-
-		vec x2o = fxu0.eval2o(utm-ut);
-		utm =ut;
-		
-		Q2o*=0.99;
-		Q2o+=outer_product(x2o,x2o);
-		//estimator
-		KFE.bayes ( concat ( dt,ut ) );
-		for (int ii=0; ii<Npart; ii++){dynamic_cast<EKFCh_du_kQ*>(M._BM(ii))->set_ref(chmat(elem_mult(Qdiag,Qdiag)));}
-		M.bayes ( concat ( dt,ut ) );
-
-		Xt.set_row ( tK, xt ); //vec from C-array
-		Dt.set_row ( tK, concat ( dt,ut.left(2), vec_2 ( KalmanObs[4],KalmanObs[5] ) ) );
-		Qtr.set_row ( tK, Qdiag );
-		XtE.set_row ( tK,KFE._e()->mean() );
-		XtM.set_row ( tK,M._e()->mean() );
-		// correction for theta
-
-		{
-			double sumSin=0.0;
-			double sumCos=0.0;
-			vec mea ( 4 );
-			vec* _w;
-
-			for ( int p=0; p<Npart;p++ ) {
-				mea = M._BM ( p )->_e()->mean();
-				_w = M.__w();
-				sumSin += ( *_w ) ( p ) *sin ( mea ( 3 ) );
-				sumCos += ( *_w ) ( p ) *cos ( mea ( 3 ) );
-			}
-			double Th = atan2 ( sumSin, sumCos );
-
-			XtMTh.set_row ( tK,vec_1 ( Th ) );
-		}
-
-	}
-
-	it_file fou ( "mpf_u_delta.it" );
-
-	fou << Name ( "xth" ) << Xt;
-	fou << Name ( "Dt" ) << Dt;
-	fou << Name ( "Qtr" ) << Qtr;
-	fou << Name ( "xthE" ) << XtE;
-	fou << Name ( "xthM" ) << XtM;
-	fou << Name ( "xthMTh" ) << XtMTh;
-	//Exit program:
-
-	return 0;
-}
-
Index: /plications/pmsm/old/pmsm_unkQpf.cpp
===================================================================
--- /applications/pmsm/old/pmsm_unkQpf.cpp (revision 279)
+++  (revision )
@@ -1,115 +1,0 @@
-/*!
-  \file 
-  \brief A test for Kalman with unknown Q
-  \author Vaclav Smidl.
-
-  -----------------------------------
-  BDM++ - C++ library for Bayesian Decision Making under Uncertainty
-
-  Using IT++ for numerical operations
-  -----------------------------------
-*/
-
-
-#include <estim/libKF.h>
-#include <estim/libPF.h>
-#include <stat/libFN.h>
-
-#include "pmsm.h"
-
-using namespace bdm;
-
-//!Extended Kalman filter with unknown \c Q
-class EKF_unQ : public EKFCh , public BMcond {
-public:
-	//! Default constructor
-	void condition ( const vec &Q0 ) {
-		Q.setD ( Q0,0 );
-		//from EKF
-		preA.set_submatrix ( dimy+dimx,dimy,Q._Ch() );
-	}; 
-};
-
-int main() {
-	// Kalman filter
-	int Ndat = 10000;
-
-//	cout << KF;
-	// internal model
-	IMpmsm fxu;
-	//                  Rs    Ls        dt       Fmag(Ypm) kp   p    J     Bf(Mz)
-	fxu.set_parameters ( 0.28, 0.003465, 20*1e-6, 0.1989,   1.5 ,4.0, 0.04, 0.0 );
-	// observation model
-	OMpmsm hxu;
-
-	vec mu0= "100 100 100 1";
-	vec Qdiag ( "0.1 0.1 0.01 0.00001" );
-	vec Rdiag ( "0.02 0.02" );
-	vec vQ = "0.01:0.01:100";
-
-	chmat Q ( Qdiag );
-	chmat R ( Rdiag );
-
-	RV rQ ( "{Q}","2" );
-	EKF_unQ KFE ;
-	KFE.set_parameters ( &fxu,&hxu,Q,R );
-	KFE.set_est ( mu0, chmat ( 1000*ones ( 4 ) ) );
-
-	mgamma evolQ ;
-	//evolQ.set_parameters ( 10000.0 ); //sigma = 1/10 mu
-
-	MPF<EKF_unQ> M ( &evolQ,&evolQ,100,KFE );
-
-	const epdf& KFEep = KFE.posterior();
-	const epdf& Mep = M.posterior();
-	// initialize
-	evolQ.set_parameters ( 1.0, "0.5 0.5" ); //sigma = 1/10 mu
-	evolQ.condition ( "0.5 0.5" );
-	const epdf& pfinit=evolQ._epdf();
-	M.set_est ( pfinit );
-	evolQ.set_parameters ( 1000.0 , "0.5 0.5"); //sigma = 1/10 mu
-
-	//simulator values
-	vec dt ( 2 ); // output (isa isb)
-	vec wt ( 2 ); // noise on dt
-	vec ut ( 2 ); //
-	vec xt=mu0;   // initial state
-	vec et ( 4 ); // noise on xt
-
-	mat Xt=zeros ( 4,Ndat ); // True trajetory of xt
-	mat XtE=zeros ( 4,Ndat ); // Estimate of xt using EKF (known Q)
-	mat XtM=zeros ( 6,Ndat ); // Estimate of xt using EKF-MPF
-	Xt.set_col ( 0,mu0 );
-	XtM.set_col ( 0,Mep.mean() );
-
-	for ( int t=1;t<Ndat;t++ ) {
-		//simulator
-		// UniRNG.sample_vector ( 2,wt );
-
-		if ( rem ( t,500 ) <200 ) ut = rem ( t,500 ) *ones ( 2 );
-		else
-			ut=zeros ( 2 );
-
-		NorRNG.sample_vector ( 4,et );
-		NorRNG.sample_vector ( 2,wt );
-		xt = fxu.eval ( xt,ut ) + Q.sqrt_mult ( et );
-		dt = hxu.eval ( xt,ut ) + R.sqrt_mult ( wt );
-
-		//estimator
-		KFE.bayes ( concat ( dt,ut ) );
-		M.bayes ( concat ( dt,ut ) );
-
-		Xt.set_col ( t,xt );
-		XtE.set_col ( t,KFEep.mean() );
-		XtM.set_col ( t,Mep.mean() );
-	}
-
-	it_file fou ( "pmsm.it" );
-
-	fou << Name ( "xth" ) << Xt;
-	fou << Name ( "xthE" ) << XtE;
-	fou << Name ( "xthM" ) << XtM;
-	//Exit program:
-	return 0;
-
-}
Index: /plications/pmsm/old/sim_var.cpp
===================================================================
--- /applications/pmsm/old/sim_var.cpp (revision 279)
+++  (revision )
@@ -1,178 +1,0 @@
-/*!
-  \file
-  \brief Simulation of disturbances in PMSM model, EKF runs with simulated covariances
-  \author Vaclav Smidl.
-
-  \ingroup PMSM
-  -----------------------------------
-  BDM++ - C++ library for Bayesian Decision Making under Uncertainty
-
-  Using IT++ for numerical operations
-  -----------------------------------
-*/
-
-
-#include <stat/libFN.h>
-#include <estim/libKF.h>
-//#include <estim/libPF.h>
-#include <math/chmat.h>
-
-#include "pmsm.h"
-#include "simulator.h"
-#include "sim_profiles.h"
-
-#include <stat/loggers.h>
-
-using namespace bdm;
-
-int main() {
-	// Kalman filter
-	int Ndat = 90000;
-	double h = 1e-6;
-	int Nsimstep = 125;
-
-	dirfilelog L("exp/sim_var2",1000);
-	//memlog L(Ndat);
-	
-	
-	// SET SIMULATOR
-	pmsmsim_set_parameters ( 0.28,0.003465,0.1989,0.0,4,1.5,0.04, 200., 3e-6, h );
-	double Ww = 0.0;
-	vec dt ( 2 );
-	vec ut ( 2 );
-	vec utm ( 2 );
-	vec dut ( 2 );
-	vec dit (2);
-	vec x2o(2);
-	vec xtm=zeros ( 4 );
-	vec xte=zeros ( 4 );
-	vec xdif=zeros ( 4 );
-	vec xt ( 4 );
-	vec ddif=zeros(2);
-	IMpmsm2o fxu;
-	//                  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 );
-	OMpmsm hxu;
-	mat Qt=zeros ( 4,4 );
-	mat Rt=zeros ( 2,2 );
-
-	// ESTIMATORS
-	vec mu0= "0.0 0.0 0.0 0.0";
-	vec Qdiag ( "62 66 454 0.03" ); //zdenek: 0.01 0.01 0.0001 0.0001
-	vec Rdiag ( "100 100" ); //var(diff(xth)) = "0.034 0.034"
-	mat Q =diag( Qdiag );
-	mat R =diag ( Rdiag );
-	EKFfull Efix ;
-	Efix.set_est ( mu0, 1*eye ( 4 )  );
-	Efix.set_parameters ( &fxu,&hxu,Q,R);
-
-	EKFfull Eop ;
-	Eop.set_est ( mu0, 1*eye ( 4 ) );
-	Eop.set_parameters ( &fxu,&hxu,Q,R);
-
-	EKFfull Edi ;
-	Edi.set_est ( mu0, 1*eye ( 4 ) );
-	Edi.set_parameters ( &fxu,&hxu,Q,R);
-
-	const epdf& Efix_ep = Efix.posterior();
-	const epdf& Eop_ep = Eop.posterior();
-	const epdf& Edi_ep = Edi.posterior();
-	
-	//LOG
-	RV rQ( "{Q }", "16");
-	RV rR( "{R }", "4");
-	RV rUD( "{u_isa u_isb i_isa i_isb }", ones_i(4));
-	RV rDu("{dux duy }",ones_i(2));
-	RV rDi("{disa disb }",ones_i(2));
-	int X_log = L.add(rx,"X");
-	int X2o_log = L.add(rx,"X2o");
-	int Xdf_log = L.add(rx,"Xdf");
-	int Efix_log = L.add(rx,"XF");
-	int Eop_log = L.add(rx,"XO");
-	int Edi_log = L.add(rx,"XD");
-	int Q_log = L.add(rQ,"Q");
-	int R_log = L.add(rR,"R");
-	int D_log = L.add(rUD,"D");
-	int Du_log = L.add(rDu,"Du");
-	int Di_log = L.add(rDi,"Di");
-	L.init();
-
-	for ( int tK=1;tK<Ndat;tK++ ) {
-		//Number of steps of a simulator for one step of Kalman
-		for ( int ii=0; ii<Nsimstep;ii++ ) {
-			sim_profile_steps1 ( Ww , false);
-			pmsmsim_step ( Ww );
-		};
-		// simulation via deterministic model
-		ut ( 0 ) = KalmanObs[4];
-		ut ( 1 ) = KalmanObs[5];
-		
-		x2o = fxu.eval2o(utm-ut);
-		utm = ut;
-		
-		dt ( 0 ) = KalmanObs[2];
-		dt ( 1 ) = KalmanObs[3];
-		dut ( 0 ) = KalmanObs[4];
-		dut ( 1 ) = KalmanObs[5];
-		dit ( 0 ) = KalmanObs[8];
-		dit ( 1 ) = KalmanObs[9];
-
-		xte = fxu.eval ( xtm,ut );
-		//Results:
-		// in xt we have simulation according to the model
-		// in x we have "reality"
-		xt ( 0 ) =x[0];xt ( 1 ) =x[1];xt ( 2 ) =x[2];xt ( 3 ) =x[3];
-		xdif = xt-xte; //xtm is a copy of x[]
-		if (xdif(0)>3.0){
-			cout << "here" <<endl;
-			}
-		if ( xdif ( 3 ) >pi ) xdif ( 3 )-=2*pi;
-		if ( xdif ( 3 ) <-pi ) xdif ( 3 ) +=2*pi;
-		
-		ddif = hxu.eval(xt,ut) - dit;
-
-		//Rt = 0.9*Rt + xdif^2
-		Qt*=0.1;
-		Qt += 10*outer_product ( xdif,xdif ); //(x-xt)^2
-
-		if (Qt(0,0)>3.0){
-			cout << "here" <<endl;
-			}
-		// For future ref.
-		xtm = xt;
-
-		Rt*=0.1;
-//		Rt += 10*outer_product ( ddif,ddif ); //(x-xt)^2
-
-		//ESTIMATE
-		Efix.bayes(concat(dt,ut));
-		//
-		Eop.set_parameters ( &fxu,&hxu,(Qt+1e-8*eye(4)),(Rt+1e-6*eye(2)));
-		Eop.bayes(concat(dt,ut));
-		//
-		Edi.set_parameters ( &fxu,&hxu,(diag(diag(Qt))+1e-16*eye(4)), (diag(diag(Rt))+1e-3*eye(2)));
-		Edi.bayes(concat(dt,ut));
-		
-		//LOG
-		L.logit(X_log, 	vec(x,4)); //vec from C-array
-		L.logit(X2o_log, x2o); 
-		L.logit(Xdf_log, xdif); 
-		L.logit(Efix_log, Efix_ep.mean() ); 
-		L.logit(Eop_log, 	Eop_ep.mean() ); 
-		L.logit(Edi_log, 	Edi_ep.mean() ); 
-		L.logit(Q_log, 	vec(Qt._data(),16) ); 
-		L.logit(R_log,		vec(Rt._data(),4) ); 
-		L.logit(D_log,	vec(KalmanObs,4) ); 
-		L.logit(Du_log,	dut ); 
-		L.logit(Di_log,	dit ); 
-		
-		L.step();
-	}
-
-	L.finalize();
-	//L.itsave("sim_var.it");	
-	
-
-	return 0;
-}
-
Index: /plications/pmsm/old/mpf_u_delta_real.cpp
===================================================================
--- /applications/pmsm/old/mpf_u_delta_real.cpp (revision 279)
+++  (revision )
@@ -1,180 +1,0 @@
-/*!
-  \file
-  \brief TR 2525 file for testing Toy Problem of mpf for Covariance Estimation
-  \author Vaclav Smidl.
-
-  \ingroup PMSM
-
-  -----------------------------------
-  BDM++ - C++ library for Bayesian Decision Making under Uncertainty
-
-  Using IT++ for numerical operations
-  -----------------------------------
-*/
-
-
-
-#include <estim/libKF.h>
-#include <estim/libPF.h>
-#include <estim/ekf_templ.h>
-#include <stat/libFN.h>
-
-#include "pmsm.h"
-#include "simulator.h"
-#include "sim_profiles.h"
-
-using namespace bdm;
-
-class IMpmsm_delta :  public IMpmsm {
-protected:
-	vec ud;
-public:
-	IMpmsm_delta() :IMpmsm(),ud ( 2 ) {ud=zeros ( 2 );};
-	//! Set mechanical and electrical variables
-
-	void condition ( const vec &val ) {ud = val;}
-	vec eval ( const vec &x0, const vec &u0 ) {
-		// last state
-		double iam = x0 ( 0 );
-		double ibm = x0 ( 1 );
-		double omm = x0 ( 2 );
-		double thm = x0 ( 3 );
-		double uam = u0 ( 0 );
-		double ubm = u0 ( 1 );
-
-		vec xk=zeros ( 4 );
-		//ia
-		xk ( 0 ) = ( 1.0- Rs/Ls*dt ) * iam + Ypm/Ls*dt*omm * sin ( thm ) + ( uam+ud ( 0 ) ) *dt/Ls;
-		//ib
-		xk ( 1 ) = ( 1.0- Rs/Ls*dt ) * ibm - Ypm/Ls*dt*omm * cos ( thm ) + ( ubm+ud ( 1 ) ) *dt/Ls;
-		//om
-		xk ( 2 ) = omm + kp*p*p * Ypm/J*dt* ( ibm * cos ( thm )-iam * sin ( thm ) ) - p/J*dt*Mz;
-		//th
-		xk ( 3 ) = thm + omm*dt; // <0..2pi>
-		if ( xk ( 3 ) >pi ) xk ( 3 )-=2*pi;
-		if ( xk ( 3 ) <-pi ) xk ( 3 ) +=2*pi;
-		return xk;
-	}
-
-};
-
-
-int main() {
-	// Kalman filter
-	int Ndat = 8000; //1e6/125
-	double h = 1e-6;
-	int Nsimstep = 125;
-	int Npart = 20;
-
-	mat Rnoise = randn ( 2,Ndat );
-
-	// internal model
-	IMpmsm fxu0;
-	IMpmsm_delta fxu;
-	//                  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 );
-	fxu0.set_parameters ( 0.28, 0.003465, Nsimstep*h, 0.1989, 1.5 ,4.0, 0.04, 0.0 );
-	// observation model
-	OMpmsm hxu;
-
-	vec mu0= "0.0 0.0 0.0 0.0";
-	vec Qdiag ( "0.7 0.7 0.01 0.0001" ); //zdenek: 0.01 0.01 0.0001 0.0001
-	vec Rdiag ( "0.1 0.1" ); //var(diff(xth)) = "0.034 0.034"
-	chmat Q ( Qdiag );
-	chmat R ( Rdiag );
-	EKFCh KFE ;
-	KFE.set_parameters ( &fxu0,&hxu,Q,R );
-	KFE.set_est ( mu0, chmat ( ones ( 4 ) ) );
-
-	RV rUd ( "{ud }", "2" );
-	EKFCh_cond KFEp ;
-	KFEp.set_parameters ( &fxu,&hxu,Q,R );
-	KFEp.set_est ( mu0, chmat ( ones ( 4 ) ) );
-
-	mlnorm<ldmat> evolUd ;
-	MPF<EKFCh_cond> M ( &evolUd,&evolUd,Npart,KFEp );
-	// initialize
-	vec Ud0="0 0";
-	evolUd.set_parameters ( eye ( 2 ), vec_2 ( 0.0,0.0 ), ldmat ( 10.0*eye ( 2 ) ) );
-	evolUd.condition ( Ud0 );
-	epdf& pfinit=evolUd._epdf();
-	M.set_est ( pfinit );
-	evolUd.set_parameters ( eye ( 2 ), vec_2 ( 0.0,0.0 ), ldmat ( 0.005*eye ( 2 ) ) );
-
-	mat Xt=zeros ( Ndat ,4 ); //true state from simulator
-	mat Dt=zeros ( Ndat,2+2 ); //observation
-	mat XtE=zeros ( Ndat, 4 );
-	mat Qtr=zeros ( Ndat, 4 );
-	mat XtM=zeros ( Ndat,2+4 ); //W + x
-	mat XtMTh=zeros ( Ndat,1 );
-
-	// SET SIMULATOR
-	pmsmsim_set_parameters ( 0.28,0.003465,0.1989,0.0,4,1.5,0.04, 200., 3e-6, h );
-	vec dt ( 2 );
-	vec ut ( 2 );
-	vec xt ( 4 );
-	vec xtm=zeros ( 4 );
-	double Ww=0.0;
-	vec vecW="1 2 4 8 4 2 0 -4 -9 -16 -4 0 0 0";
-	vecW*=10.0;
-
-	it_file RD("tec0006ALL.it");
-	mat RIsx, RIsy, RUsx, RUsy;
-	RD >> Name("Isx") >> RIsx;
-	RD >> Name("Isy") >> RIsy;
-	RD >> Name("Usx") >> RUsx;
-	RD >> Name("Usy") >> RUsy;
-	
-	for ( int tK=1;tK<Ndat;tK++ ) {
-		//Number of steps of a simulator for one step of Kalman
-		for ( int ii=0; ii<Nsimstep;ii++ ) {
-			//simulator
-			pmsmsim_noreg_step ( RUsx(125*tK+ii) , RUsy(125*tK+ii));
-		};
-		ut ( 0 ) = RUsx(125*tK);
-		ut ( 1 ) = RUsy(125*tK);
-		dt ( 0 ) = RIsx(125*tK);
-		dt ( 1 ) = RIsy(125*tK);
-		xt = vec ( x,4 );
-
-		//estimator
-		KFE.bayes ( concat ( dt,ut ) );
-		M.bayes ( concat ( dt,ut ) );
-
-		Xt.set_row ( tK, xt ); //vec from C-array
-		Dt.set_row ( tK, concat ( dt,ut));
-		XtE.set_row ( tK,KFE._e()->mean() );
-		XtM.set_row ( tK,M._e()->mean() );
-		// correction for theta
-
-		{
-			double sumSin=0.0;
-			double sumCos=0.0;
-			vec mea ( 4 );
-			vec* _w;
-
-			for ( int p=0; p<Npart;p++ ) {
-				mea = M._BM ( p )->_e()->mean();
-				_w = M.__w();
-				sumSin += ( *_w ) ( p ) *sin ( mea ( 3 ) );
-				sumCos += ( *_w ) ( p ) *cos ( mea ( 3 ) );
-			}
-			double Th = atan2 ( sumSin, sumCos );
-
-			XtMTh.set_row ( tK,vec_1 ( Th ) );
-		}
-
-	}
-
-	it_file fou ( "mpf_u_delta_real.it" );
-
-	fou << Name ( "xth" ) << Xt;
-	fou << Name ( "Dt" ) << Dt;
-	fou << Name ( "xthE" ) << XtE;
-	fou << Name ( "xthM" ) << XtM;
-	fou << Name ( "xthMTh" ) << XtMTh;
-	//Exit program:
-
-	return 0;
-}
-
Index: /plications/pmsm/old/pmsm_sim.cpp
===================================================================
--- /applications/pmsm/old/pmsm_sim.cpp (revision 279)
+++  (revision )
@@ -1,124 +1,0 @@
-/*
-  \file
-  \brief Models for synchronous electric drive using IT++ and BDM
-  \author Vaclav Smidl.
-
-  -----------------------------------
-  BDM++ - C++ library for Bayesian Decision Making under Uncertainty
-
-  Using IT++ for numerical operations
-  -----------------------------------
-*/
-
-
-#include <estim/libKF.h>
-#include <estim/libPF.h>
-#include <stat/libFN.h>
-
-#include "pmsm.h"
-#include "simulator.h"
-#include "sim_profiles.h"
-
-using namespace bdm;
-//!Extended Kalman filter with unknown \c Q
-class EKF_unQ : public EKFCh , public BMcond {
-public:
-	//! Default constructor
-	void condition ( const vec &Q0 ) {
-		Q.setD ( Q0,0 );
-		//from EKF
-		preA.set_submatrix ( dimy+dimx,dimy,Q._Ch() );
-	};
-};
-
-
-int main() {
-	// Kalman filter
-	int Ndat = 9000;
-	double h = 1e-6;
-	int Nsimstep = 125;
-	int Npart = 200;
-
-	// internal model
-	IMpmsm fxu;
-	//                  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 );
-	// observation model
-	OMpmsm hxu;
-
-	vec mu0= "0.0 0.0 0.0 0.0";
-	vec Qdiag ( "0.001 0.001 1e-6 1e-10" ); //zdenek: 0.01 0.01 0.0001 0.0001
-	vec Rdiag ( "1e-10 1e-10" ); //var(diff(xth)) = "0.034 0.034"
-	chmat Q ( Qdiag );
-	chmat R ( Rdiag );
-	EKFCh KFE ;
-	KFE.set_parameters ( &fxu,&hxu,Q,R );
-	KFE.set_est ( mu0, chmat ( 1*ones ( 4 ) ) );
-
-	RV rQ ( "{Q }","2" );
-	EKF_unQ KFEp;
-	KFEp.set_parameters ( &fxu,&hxu,Q,R );
-	KFEp.set_est ( mu0, chmat ( zeros ( 4 ) ) );
-
-	mgamma evolQ ;
-	MPF<EKF_unQ> M (&evolQ,&evolQ,Npart,KFEp );
-	// initialize
-	evolQ.set_parameters ( 10.0, "0.01 0.01" ); //sigma = 1/10 mu
-	evolQ.condition ( "0.01 0.01" ); //Zdenek default
-	epdf& pfinit=evolQ._epdf();
-	M.set_est ( pfinit );
-	evolQ.set_parameters ( 10.0,  "0.01 0.01");
-
-	//
-
-	const epdf& KFEep = KFE.posterior();
-	const epdf& Mep = M.posterior();
-
-	mat Xt=zeros ( Ndat ,9 ); //true state from simulator
-	mat Dt=zeros ( Ndat,4+2 ); //observation
-	mat XtE=zeros ( Ndat, 4 );
-	mat XtM=zeros ( Ndat,2+4 ); //Q + x
-
-	// SET SIMULATOR
-	pmsmsim_set_parameters ( 0.28,0.003465,0.1989,0.0,4,1.5,0.04, 200., 3e-6, h );
-	double Ww=0.0;
-	static int k_rampa=1;
-	static long k_rampa_tmp=0;
-	vec dt ( 2 );
-	vec ut ( 2 );
-	vec vecW="0.1 0.2 0.4 0.9 0.4 0.2 0.0 -0.4 -0.9 -1.6 -0.4 0.0 0.0";
-
-	for ( int tK=1;tK<Ndat;tK++ ) {
-		//Number of steps of a simulator for one step of Kalman
-		for ( int ii=0; ii<Nsimstep;ii++ ) {
-			//simulator
-			sim_profile_vec01t(Ww,vecW);
-			pmsmsim_step ( Ww );
-		};
-		// collect data
-		ut ( 0 ) = 0.0;//KalmanObs[0];
-		ut ( 1 ) = 0.0;//KalmanObs[1];
-		dt ( 0 ) = KalmanObs[2];
-		dt ( 1 ) = KalmanObs[3];
-
-		//estimator
-		KFE.bayes ( concat ( dt,ut ) );
-		M.bayes ( concat ( dt,ut ) );
-
-		Xt.set_row ( tK,vec ( x,9 ) ); //vec from C-array
-		Dt.set_row ( tK, concat ( dt,ut,vec_1(sqrt(pow(ut(0),2)+pow(ut(1),2))), vec_1(sqrt(pow(dt(0),2)+pow(dt(1),2))) ) );
-		XtE.set_row ( tK,KFEep.mean() );
-		XtM.set_row ( tK,Mep.mean() );
-	}
-
-	it_file fou ( "pmsm_sim.it" );
-
-	fou << Name ( "xth" ) << Xt;
-	fou << Name ( "Dt" ) << Dt;
-	fou << Name ( "xthE" ) << XtE;
-	fou << Name ( "xthM" ) << XtM;
-	//Exit program:
-
-	return 0;
-}
-
Index: /plications/pmsm/old/pmsm_sim2.cpp
===================================================================
--- /applications/pmsm/old/pmsm_sim2.cpp (revision 279)
+++  (revision )
@@ -1,149 +1,0 @@
-/*
-  \file
-  \brief Models for synchronous electric drive using IT++ and BDM
-  \author Vaclav Smidl.
-
-  -----------------------------------
-  BDM++ - C++ library for Bayesian Decision Making under Uncertainty
-
-  Using IT++ for numerical operations
-  -----------------------------------
-*/
-
-
-#include <estim/libKF.h>
-#include <estim/libPF.h>
-#include <stat/libFN.h>
-
-#include <stat/loggers.h>
-
-#include "pmsm.h"
-#include "simulator.h"
-#include "sim_profiles.h"
-
-using namespace bdm;
-//!Extended Kalman filter with unknown \c Q
-class EKF_unQ : public EKFCh , public BMcond {
-public:
-	//! Default constructor
-	void condition ( const vec &Q0 ) {
-		Q.setD ( Q0,0 );
-		//from EKF
-		preA.set_submatrix ( dimy+dimx,dimy,Q._Ch() );
-	};
-	void bayes(const vec dt){
-	EKFCh::bayes(dt);
-		
-		vec xtrue(4);
-		//UGLY HACK!!! reliance on a predictor!!
-		xtrue(0)=x[0];
-		xtrue(1)=x[1];
-		xtrue(2)=x[2];
-		xtrue(3)=x[3];
-		
-		ll = -0.5* ( 4 * 1.83787706640935 +_P.logdet() +_P.invqform(xtrue));
-	}
-};
-class EKF_unQful : public EKFfull , public BMcond {
-public:
-	void condition ( const vec &Q0 ) {
-		Q=diag(Q0);
-	};
-	void bayes(const vec dt){
-	EKFfull::bayes(dt);
-		
-		vec xtrue(4);
-		//UGLY HACK!!! reliance on a predictor!!
-		xtrue(0)=x[0];
-		xtrue(1)=x[1];
-		xtrue(2)=x[2];
-		xtrue(3)=x[3];
-		
-		BM::ll = -0.5* ( 4 * 1.83787706640935 +log(det(P)) +xtrue* ( inv(P)*xtrue ) );
-	}
-};
-
-int main() {
-	// Kalman filter
-	int Ndat = 90000;
-	double h = 1e-6;
-	int Nsimstep = 125;
-	int Npart = 50;
-	
-	dirfilelog L("exp/pmsm_sim2",1000);
-	
-	// internal model
-	IMpmsm fxu;
-	//                  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 );
-	// observation model
-	OMpmsm hxu;
-
-	vec mu0= "0.0 0.0 0.0 0.0";
-//	vec Qdiag ( "0.01 0.01 0.01 0.0001" ); //zdenek: 0.01 0.01 0.0001 0.0001
-	vec Qdiag ( "10 10 10 0.001" ); //zdenek: 0.01 0.01 0.0001 0.0001
-	vec Rdiag ( "100 100" ); //var(diff(xth)) = "0.034 0.034"
-	chmat Q ( Qdiag );
-	chmat R ( Rdiag );
-	EKFCh KFE ;
-	KFE.set_est ( mu0, chmat( 1*eye ( 4 ) ) );
-	KFE.set_parameters ( &fxu,&hxu,Q,R);
-
-	RV rQ ( "{Q}","4" );
-	EKF_unQful KFEp ;
-	KFEp.set_est ( mu0,  1*ones ( 4 ) );
-	KFEp.set_parameters ( &fxu,&hxu,diag(Qdiag),diag(Rdiag) );
-
-	mgamma_fix evolQ ;
-	MPF<EKF_unQful> M ( &evolQ,&evolQ,Npart,KFEp );
-	// initialize
-	evolQ.set_parameters ( 1000.0 ,Qdiag, 0.5); //sigma = 1/10 mu
-	evolQ.condition ( Qdiag ); //Zdenek default
-	epdf& pfinit=evolQ._epdf();
-	M.set_est ( pfinit );
-	evolQ.set_parameters ( 100000.0, Qdiag, 0.9999 );
-	//
-	const epdf& KFEep = KFE.posterior();
-	const epdf& Mep = M.posterior();
-
-	int X_log = L.add(rx,"X");
-	int Efix_log = L.add(rx,"XF");
-	RV tmp=concat(rQ,rx);
-	int M_log = L.add(tmp,"M");
-	L.init();
-
-	// SET SIMULATOR
-	pmsmsim_set_parameters ( 0.28,0.003465,0.1989,0.0,4,1.5,0.04, 200., 3e-6, h );
-	double Ww=0.0;
-	vec dt ( 2 );
-	vec ut ( 2 );
-
-	for ( int tK=1;tK<Ndat;tK++ ) {
-		//Number of steps of a simulator for one step of Kalman
-		for ( int ii=0; ii<Nsimstep;ii++ ) {
-			//simulator
-			sim_profile_steps1(Ww);
-			pmsmsim_step ( Ww );
-		};
-		// collect data
-		ut ( 0 ) = KalmanObs[0];
-		ut ( 1 ) = KalmanObs[1];
-		dt ( 0 ) = KalmanObs[2];
-		dt ( 1 ) = KalmanObs[3];
-
-		//estimator
-		KFE.bayes ( concat ( dt,ut ) );
-		M.bayes ( concat ( dt,ut ) );
-		
-		L.logit(X_log, 	vec(x,4)); //vec from C-array
-		L.logit(Efix_log, KFEep.mean() ); 
-		L.logit(M_log, 	Mep.mean() ); 
-		
-		L.step();
-	}
-
-	L.finalize(); 
-	
-	return 0;
-}
-
Index: /plications/pmsm/old/pmsm_sim3.cpp
===================================================================
--- /applications/pmsm/old/pmsm_sim3.cpp (revision 279)
+++  (revision )
@@ -1,166 +1,0 @@
-/*
-  \file
-  \brief Models for synchronous electric drive using IT++ and BDM
-  \author Vaclav Smidl.
-
-  -----------------------------------
-  BDM++ - C++ library for Bayesian Decision Making under Uncertainty
-
-  Using IT++ for numerical operations
-  -----------------------------------
-*/
-
-#include <itpp/itbase.h>
-#include <estim/libKF.h>
-#include <estim/libPF.h>
-#include <stat/libFN.h>
-
-#include "pmsm.h"
-#include "simulator.h"
-
-#include "../simulator_zdenek/ekf_example/ekf_obj.h"
-#include "iopom.h"
-
-using namespace itpp;
-//!Extended Kalman filter with unknown \c Q
-
-void set_simulator_t(double &Ww) {
-
-        if (t>0.0002) x[8]=1.2;    // 1A //0.2ZP
-        if (t>0.4) x[8]=10.8;   // 9A
-        if (t>0.6) x[8]=25.2;  // 21A
-
-        if (t>0.7) Ww=2.*M_PI*10.;
-        if (t>1.0) x[8]=1.2;    // 1A
-        if (t>1.2) x[8]=10.8;   // 9A
-        if (t>1.4) x[8]=25.2;  // 21A
-
-        if (t>1.6) Ww=2.*M_PI*50.;
-        if (t>1.9) x[8]=1.2;    // 1A
-        if (t>2.1) x[8]=10.8;   // 9A
-        if (t>2.3) x[8]=25.2;  // 21A
-
-        if (t>2.5) Ww=2.*M_PI*100;
-        if (t>2.8) x[8]=1.2;    // 1A
-        if (t>3.0) x[8]=10.8;   // 9A
-        if (t>3.2) x[8]=25.2;  // 21A
-
-        if (t>3.4) Ww=2.*M_PI*150;
-        if (t>3.7) x[8]=1.2;    // 1A
-        if (t>3.9) x[8]=10.8;   // 9A
-        if (t>4.1) x[8]=25.2;  // 21A
-
-        if (t>4.3) Ww=2.*M_PI*0;
-        if (t>4.8) x[8]=-1.2;    // 1A
-        if (t>5.0) x[8]=-10.8;   // 9A
-        if (t>5.2) x[8]=-25.2;  // 21A
-
-        if (t>5.4) Ww=2.*M_PI*(-10.);
-        if (t>5.7) x[8]=-1.2;    // 1A
-        if (t>5.9) x[8]=-10.8;   // 9A
-        if (t>6.1) x[8]=-25.2;  // 21A
-
-        if (t>6.3) Ww=2.*M_PI*(-50.);
-        if (t>6.7) x[8]=-1.2;    // 1A
-        if (t>6.9) x[8]=-10.8;   // 9A
-        if (t>7.1) x[8]=-25.2;  // 21A
-
-        if (t>7.3) Ww=2.*M_PI*(-100.);
-        if (t>7.7) x[8]=-1.2;    // 1A
-        if (t>7.9) x[8]=-10.8;   // 9A
-        if (t>8.1) x[8]=-25.2;  // 21A
-        if (t>8.3) x[8]=10.8;   // 9A
-        if (t>8.5) x[8]=25.2;  // 21A
-        
-        x[8]=0.0;
-}
-
-int main() {
-	// Kalman filter
-	int Ndat = 90000;
-	double h = 1e-6;
-	int Nsimstep = 125;
-	int Npart = 100;
-	
-
-	vec mu0= "0.0 0.0 0.0 0.0";
-	vec Qdiag ( "0.05 0.05 0.002 0.001" ); //zdenek: 0.01 0.01 0.0001 0.0001
-	vec Rdiag ( "0.05 0.05" ); //var(diff(xth)) = "0.034 0.034"
-	chmat Q ( Qdiag );
-	chmat R ( Rdiag );
-	
-	RV rQ ( "100","{Q}","4","0" );
-	EKFfixed KFE ( rx, rQ);
-	KFE.init_ekf ( Nsimstep*h);
-
-
-///////////// Particles
-	mgamma_fix evolQ ( rQ,rQ );
-	MPF<EKFfixed> M ( rx,rQ,evolQ,evolQ,Npart,KFE );
-	// initialize
-	evolQ.set_parameters ( 10.0 ,Qdiag, 1.0); //sigma = 1/10 mu
-	evolQ.condition ( Qdiag ); //Zdenek default
-	epdf& pfinit=evolQ._epdf();
-	M.set_est ( pfinit );
-	evolQ.set_parameters ( 500000.0, Qdiag, 0.9999 );
-
-
-	epdf& KFEep = KFE._epdf();
-	epdf& Mep = M._epdf();
-
-
-	mat Xt=zeros ( Ndat ,9 ); //true state from simulator
-	mat Dt=zeros ( Ndat,4 ); //observation
-	mat XtE=zeros ( Ndat, 4 );
-	mat XtM=zeros ( Ndat,4+4 ); //Q + x
-
-	// SET SIMULATOR
-	pmsmsim_set_parameters ( 0.28,0.003465,0.1989,0.0,4,1.5,0.04, 200., 3e-6, h );
-	double Ww=0.0;
-	static int k_rampa=1;
-	static long k_rampa_tmp=0;
-
-	vec dt ( 2 );
-	vec ut ( 2 );
-
-	for ( int tK=1;tK<Ndat;tK++ ) {
-		//Number of steps of a simulator for one step of Kalman
-		for ( int ii=0; ii<Nsimstep;ii++ ) {
-			//simulator
-			Ww+=k_rampa*2.*M_PI*2e-4;    //1000Hz/s
-			if ( Ww>2.*M_PI*150. ) {
-				Ww=2.*M_PI*150.;
-				if ( k_rampa_tmp<500000 ) k_rampa_tmp++;
-				else {k_rampa=-1;k_rampa_tmp=0;}
-			};
-			if ( Ww<-2.*M_PI*150. ) Ww=-2.*M_PI*150.; /* */
-//			set_simulator_t(Ww);
-			pmsmsim_step ( Ww );
-		};
-		// collect data
-		ut ( 0 ) = KalmanObs[0];
-		ut ( 1 ) = KalmanObs[1];
-		dt ( 0 ) = KalmanObs[2];
-		dt ( 1 ) = KalmanObs[3];
-		//estimator
-		KFE.bayes ( concat ( dt,ut ) );
-		M.bayes ( concat ( dt,ut ) );
-		
-		Xt.set_row ( tK,vec ( x,9 ) ); //vec from C-array
-		Dt.set_row ( tK, concat ( dt,ut));
-		XtE.set_row ( tK,KFEep.mean() );
-		XtM.set_row ( tK,Mep.mean() );
-	}
-
-	char tmpstr[200];
-	sprintf(tmpstr,"%s/%s","herez/","format");
-	ofstream  form(tmpstr);
-	form << "# Experimetal header file"<< endl;
-	dirfile_write(form,"herez/",Xt,"X","{isa isb om th }" );
-	dirfile_write ( form,"herez",XtM,"XtM","{q1 q2 q3 q4 isa isb om th }" );
-	dirfile_write ( form,"herez",XtE,"XE","{isa isb om th }" );
-	dirfile_write ( form,"herez",Dt,"Dt","{isa isb ua ub }" );
-
-	return 0;
-}
-
Index: /plications/pmsm/old/sim.cpp
===================================================================
--- /applications/pmsm/old/sim.cpp (revision 279)
+++  (revision )
@@ -1,43 +1,0 @@
-/*!
-  \file
-  \brief Simulation of disturbances in PMSM model, PWM and integration disturbances are distinguished
-  \author Vaclav Smidl.
-
-  -----------------------------------
-  BDM++ - C++ library for Bayesian Decision Making under Uncertainty
-
-  Using IT++ for numerical operations
-  -----------------------------------
-*/
-
-#include "pmsm_ui.h"
-#include <stat/loggers_ui.h>
-
-using namespace bdm;
-int main() {
-	UIFile F("sim.txt");
-
-	logger* L; 
-	UIbuild(F.lookup("logger"),L);
-	pmsmDS * DS;
-	UIbuild(F.lookup("system"),DS);
-	int Ndat;
-	F.lookupValue("ndat",Ndat);
-	// SET SIMULATOR
-
-	DS->log_add(*L);
-	L->init();
-	
-	for ( int tK=1;tK<Ndat;tK++ ) {
-		DS->step();
-		DS->logit(*L);
-		L->step();
-	}
-	
-	L->finalize(); 
-	
-	delete L;
-	delete DS;
-	return 0;
-}
-
Index: /plications/pmsm/old/pmsm_mix.cpp
===================================================================
--- /applications/pmsm/old/pmsm_mix.cpp (revision 279)
+++  (revision )
@@ -1,131 +1,0 @@
-/*!
-  \file
-  \brief Models for synchronous electric drive using IT++ and BDM
-  \author Vaclav Smidl.
-
-  -----------------------------------
-  BDM++ - C++ library for Bayesian Decision Making under Uncertainty
-
-  Using IT++ for numerical operations
-  -----------------------------------
-*/
-
-
-#include <stat/libFN.h>
-#include <stat/emix.h>
-#include <estim/ekf_templ.h>
-#include <estim/libPF.h>
-
-#include "pmsm.h"
-#include "simulator.h"
-#include "sim_profiles.h"
-
-#include <stat/loggers.h>
-
-using namespace bdm;
-
-int main() {
-	// Kalman filter
-	int Ndat = 90000;
-	double h = 1e-6;
-	int Nsimstep = 125;
-	int Npar = 10;
-
-	dirfilelog L("exp/pmsm_mix",1000);
-	//memlog L(Ndat);
-	
-	// SET SIMULATOR
-	pmsmsim_set_parameters ( 0.28,0.003465,0.1989,0.0,4,1.5,0.04, 200., 3e-6, h );
-	double Ww = 0.0;
-	vec dt ( 2 );
-	vec ut ( 2 );
-	vec xtm=zeros ( 4 );
-	vec xdif=zeros ( 4 );
-	vec xt ( 4 );
-	vec ddif=zeros(2);
-	IMpmsm fxu;
-	//                  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 );
-	OMpmsm hxu;
-	mat Qt=zeros ( 4,4 );
-	mat Rt=zeros ( 2,2 );
-
-	// ESTIMATORS
-	vec mu0= "0.0 0.0 0.0 0.0";
-	vec Qdiag ( "62 66 454 0.03" ); //zdenek: 0.01 0.01 0.0001 0.0001
-	vec Rdiag ( "100 100" ); //var(diff(xth)) = "0.034 0.034"
-	mat Q =diag( Qdiag );
-	mat R =diag ( Rdiag );
-	EKFfull Efix ;
-	Efix.set_est ( mu0, 1*eye ( 4 )  );
-	Efix.set_parameters ( &fxu,&hxu,Q,R);
-
-	RV rQR( "{Q R }", "4 2 ");
-	EKFful_unQR EKU;
-	EKU.set_est ( mu0,  1*ones ( 4 ) );
-	EKU.set_parameters ( &fxu,&hxu,diag(Qdiag),diag(Rdiag) );
-
-	//QU model
-	egamma Gcom;Gcom.set_parameters(ones(6),vec("1 1 1e4 1e10 1 1"));
-/*	cout << Gcom.mean() <<endl;
-	cout << Gcom.sample() <<endl;*/
-	euni Ucom; Ucom.set_parameters(zeros(6),vec("60 60 453 0.03 100 100"));
-/*	cout << Ucom.mean() <<endl;
-	cout << Ucom.sample() <<endl;*/
-	Array<epdf*> Coms(2);
-	Coms(0) = &Gcom;
-	Coms(1) = &Ucom;
-	emix Eevol; 	Eevol.set_parameters("0.1 0.9", Coms);
-// 	cout << Eevol.sample() <<endl;
-
-	mepdf evolQR(&Eevol);
-	MPF<EKFful_unQR> M (  &evolQR, &evolQR, Npar, EKU );
-	M.set_est ( evolQR._epdf() );
-
-	const epdf& Efix_ep = Efix.posterior();
-	const epdf& M_ep = M.posterior();
-	
-	//LOG
-	RV rUD( "{u_isa u_isb i_isa i_isb }");
-	int X_log = L.add(rx,"X");
-	int Efix_log = L.add(rx,"XF");
-	RV tmp=concat(rQR,rx);
-	int M_log = L.add(tmp,"M");
-	L.init();
-
-vec dumvec = vec_1(1.0);
-vec z=  evolQR.samplecond(dumvec) ;
-cout << z << endl;
-
-	for ( int tK=1;tK<Ndat;tK++ ) {
-		//Number of steps of a simulator for one step of Kalman
-		for ( int ii=0; ii<Nsimstep;ii++ ) {
-			sim_profile_steps1 ( Ww, true );
-			pmsmsim_step ( Ww );
-		};
-		// simulation via deterministic model
-		ut ( 0 ) = KalmanObs[0];
-		ut ( 1 ) = KalmanObs[1];
-		dt ( 0 ) = KalmanObs[2];
-		dt ( 1 ) = KalmanObs[3];
-
-		//ESTIMATE
-		Efix.bayes(concat(dt,ut));
-		//
-		M.bayes(concat(dt,ut));
-		
-		//LOG
-		L.logit(X_log, 	vec(x,4)); //vec from C-array
-		L.logit(Efix_log, Efix_ep.mean() ); 
-		L.logit(M_log, 	M_ep.mean() ); 
-		
-		L.step();
-	}
-
-	L.finalize();
-	//L.itsave("sim_var.it");	
-	
-
-	return 0;
-}
-
Index: /plications/pmsm/old/pmsm_unkQ.cpp
===================================================================
--- /applications/pmsm/old/pmsm_unkQ.cpp (revision 279)
+++  (revision )
@@ -1,107 +1,0 @@
-/*
-  \file
-  \brief Models for synchronous electric drive using IT++ and BDM
-  \author Vaclav Smidl.
-
-  -----------------------------------
-  BDM++ - C++ library for Bayesian Decision Making under Uncertainty
-
-  Using IT++ for numerical operations
-  -----------------------------------
-*/
-
-
-#include <estim/libKF.h>
-#include <estim/libPF.h>
-#include <stat/libFN.h>
-
-#include "pmsm.h"
-
-using namespace bdm;
-/*
-// PMSM with Q on Ia and Ib given externally
-class EKF_unQ : public EKF<chmat> , public BMcond {
-public:
-	EKF_unQ( rx,ry,ru,rQ):EKF<chmat>(rx,ry,ru),BMcond(rQ){};
-	void condition(const vec &Q0){};
-};*/
-
-
-int main() {
-	// Kalman filter
-	int Ndat = 1000;
-
-//	cout << KF;
-	// internal model
-	IMpmsm fxu;
-	//                  Rs    Ls        dt       Fmag(Ypm) kp   p    J     Bf(Mz)
-	fxu.set_parameters ( 0.28, 0.003465, 20*1e-6, 0.1989,   1.5 ,4.0, 0.04, 0.0 );
-	// observation model
-	OMpmsm hxu;
-
-	vec mu0= "100 100 100 1";
-	vec Qdiag ( "0.1 0.1 0.01 0.01" );
-	vec Rdiag ( "0.02 0.02" );
-	vec vQ = "0.01:0.01:100";
-	chmat Q ( Qdiag );
-	chmat R ( Rdiag );
-	EKFCh KFE ;
-	KFE.set_est ( mu0, chmat ( 1000*ones ( 4 ) ) );
-	KFE.set_parameters ( &fxu,&hxu,Q,R );
-
-	mat ll(100,Ndat);
-
-	EKFCh* kfArray[100];
-
-	for ( int i=0;i<100;i++ ) {
-		vec Qid ( Qdiag );
-		Qid ( 0 ) = vQ ( i ); Qid ( 1 ) = vQ ( i );
-		kfArray[i]= new EKFCh;
-		kfArray[i]->set_est ( mu0, chmat ( 1000*ones ( 4 ) ) );
-		kfArray[i]->set_parameters ( &fxu,&hxu,chmat ( Qid ),R );
-	}
-
-	const epdf& KFEep = KFE.posterior();
-
-	//simulator values
-	vec dt ( 2 );
-	vec wt ( 2 );
-	vec ut ( 2 );
-	vec xt=mu0;
-	vec et ( 4 );
-
-	mat Xt=zeros ( 4,Ndat );
-	mat XtE=zeros ( 4,Ndat );
-	Xt.set_col ( 0,KFEep.mean() );
-
-	for ( int t=1;t<Ndat;t++ ) {
-		//simulator
-		UniRNG.sample_vector ( 2,wt );
-
-		if ( rem ( t,500 ) <200 ) ut = rem ( t,500 ) *ones ( 2 );
-		else
-			ut=zeros ( 2 );
-
-		NorRNG.sample_vector ( 4,et );
-		NorRNG.sample_vector ( 2,wt );
-		xt = fxu.eval ( xt,ut ) + Q.sqrt_mult ( et );
-		dt = hxu.eval ( xt,ut ) + R.sqrt_mult ( wt );
-
-		//estimator
-		KFE.bayes ( concat ( dt,ut ) );
-		for ( int i=0;i<100;i++ ) {kfArray[i]->bayes( concat ( dt,ut ) );ll(i,t)=ll(i,t-1) + kfArray[i]->_ll();
-		}
-		
-		Xt.set_col ( t,xt );
-		XtE.set_col ( t,KFEep.mean() );
-	}
-
-	it_file fou ( "pmsm.it" );
-
-	fou << Name ( "xth" ) << Xt;
-	fou << Name ( "xthE" ) << XtE;
-	fou << Name ( "ll" ) << ll;
-	//Exit program:
-	return 0;
-
-}
Index: /plications/pmsm/old/mpf_u_weight.cpp
===================================================================
--- /applications/pmsm/old/mpf_u_weight.cpp (revision 279)
+++  (revision )
@@ -1,189 +1,0 @@
-/*!
-  \file
-  \brief Voltage U is multiplied by an unknown weight w which is estimated by MPF
-  \author Vaclav Smidl.
-
-  \ingroup PMSM
-
-  -----------------------------------
-  BDM++ - C++ library for Bayesian Decision Making under Uncertainty
-
-  Using IT++ for numerical operations
-  -----------------------------------
-*/
-
-
-
-#include <estim/libKF.h>
-#include <estim/libPF.h>
-#include <stat/libFN.h>
-
-#include "pmsm.h"
-#include "simulator.h"
-#include "sim_profiles.h"
-
-using namespace bdm;
-
-//!Extended Kalman filter with unknown \c Q
-class EKFCh_cond : public EKFCh , public BMcond {
-public:
-	//! condition on value of pfxu
-	void condition ( const vec &val ) {
-		pfxu->condition ( val );
-	};
-};
-
-class IMpmsm_w :  public IMpmsm {
-protected:
-	double w;
-public:
-	IMpmsm_w() :IMpmsm(),w ( 1.0 ) {};
-	//! Set mechanical and electrical variables
-
-	void condition ( const vec &val ) {w = val ( 0 );}
-	vec eval ( const vec &x0, const vec &u0 ) {
-		// last state
-		double iam = x0 ( 0 );
-		double ibm = x0 ( 1 );
-		double omm = x0 ( 2 );
-		double thm = x0 ( 3 );
-		double uam = u0 ( 0 );
-		double ubm = u0 ( 1 );
-
-		vec xk=zeros ( 4 );
-		//ia
-		xk ( 0 ) = ( 1.0- Rs/Ls*dt ) * iam + Ypm/Ls*dt*omm * sin ( thm ) + w* uam*dt/Ls;
-		//ib
-		xk ( 1 ) = ( 1.0- Rs/Ls*dt ) * ibm - Ypm/Ls*dt*omm * cos ( thm ) + w* ubm*dt/Ls;
-		//om
-		xk ( 2 ) = omm + kp*p*p * Ypm/J*dt* ( ibm * cos ( thm )-iam * sin ( thm ) ) - p/J*dt*Mz;
-		//th
-		xk ( 3 ) = thm + omm*dt; // <0..2pi>
-		if ( xk ( 3 ) >pi ) xk ( 3 )-=2*pi;
-		if ( xk ( 3 ) <-pi ) xk ( 3 ) +=2*pi;
-		return xk;
-	}
-
-};
-
-
-int main() {
-	// Kalman filter
-	int Ndat = 9000;
-	double h = 1e-6;
-	int Nsimstep = 125;
-	int Npart = 200;
-
-	mat Rnoise = randn ( 2,Ndat );
-
-	// internal model
-	IMpmsm fxu0;
-	IMpmsm_w fxu;
-	//                  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 );
-	fxu0.set_parameters ( 0.28, 0.003465, Nsimstep*h, 0.1989, 1.5 ,4.0, 0.04, 0.0 );
-	// observation model
-	OMpmsm hxu;
-
-	vec mu0= "0.0 0.0 0.0 0.0";
-	vec Qdiag ( "0.1 0.1 0.001 0.000001" ); //zdenek: 0.01 0.01 0.0001 0.0001
-	vec Rdiag ( "0.1 0.1" ); //var(diff(xth)) = "0.034 0.034"
-	chmat Q ( Qdiag );
-	chmat R ( Rdiag );
-	EKFCh KFE;
-	KFE.set_parameters ( &fxu0,&hxu,Q,R );
-	KFE.set_est ( mu0, chmat ( ones ( 4 ) ) );
-
-	RV rW ( "{w }" );
-	EKFCh_cond KFEp;
-	KFEp.set_parameters ( &fxu,&hxu,Q,R );
-	KFEp.set_est ( mu0, chmat ( ones ( 4 ) ) );
-
-	mgamma_fix evolW ;
-	MPF<EKFCh_cond> M (&evolW,&evolW,Npart,KFEp );
-	// initialize
-	vec W0="0.5";
-	evolW.set_parameters ( 10.0, W0, 1.0 ); //sigma = 1/10 mu
-	evolW.condition ( W0 );
-	epdf& pfinit=evolW._epdf();
-	M.set_est ( pfinit );
-	evolW.set_parameters ( 100.0, W0, 0.99 ); //sigma = 1/10 mu
-
-	mat Xt=zeros ( Ndat ,4 ); //true state from simulator
-	mat Dt=zeros ( Ndat,2+2 ); //observation
-	mat XtE=zeros ( Ndat, 4 );
-	mat Qtr=zeros ( Ndat, 4 );
-	mat XtM=zeros ( Ndat,1+4 ); //W + x
-	mat XtMTh=zeros ( Ndat,1 ); //W + x
-
-	// SET SIMULATOR
-	pmsmsim_set_parameters ( 0.28,0.003465,0.1989,0.0,4,1.5,0.04, 200., 3e-6, h );
-	vec dt ( 2 );
-	vec ut ( 2 );
-	vec xt ( 4 );
-	vec xtm=zeros ( 4 );
-	double Ww=0.0;
-	vec vecW="1 2 4 8 4 2 0 -4 -9 -16 -4 0 0 0";
-	vecW*=10.0;
-
-	for ( int tK=1;tK<Ndat;tK++ ) {
-		//Number of steps of a simulator for one step of Kalman
-		for ( int ii=0; ii<Nsimstep;ii++ ) {
-			//simulator
-			sim_profile_vec01t ( Ww,vecW );
-			pmsmsim_step ( Ww );
-		};
-		ut ( 0 ) = KalmanObs[0];
-		ut ( 1 ) = KalmanObs[1];
-		dt ( 0 ) = KalmanObs[2]+0.3*Rnoise ( 0,t );
-		dt ( 1 ) = KalmanObs[3]+0.3*Rnoise ( 1,t );
-		xt = vec ( x,4 );
-
-		//estimator
-		KFE.bayes ( concat ( dt,ut ) );
-		M.bayes ( concat ( dt,ut ) );
-
-		Xt.set_row ( tK, xt ); //vec from C-array
-		Dt.set_row ( tK, concat ( dt,ut ) );
-		Qtr.set_row ( tK, Qdiag );
-		XtE.set_row ( tK,KFE._e()->mean() );
-		XtM.set_row ( tK,M._e()->mean() );
-		{
-			double sumSin=0.0;
-			double sumCos=0.0;
-			vec mea ( 4 );
-			vec* _w;
-
-			for ( int p=0; p<Npart;p++ ) {
-				mea = M._BM ( p )->_e()->mean();
-				_w = M.__w();
-				sumSin += ( *_w ) ( p ) *sin ( mea ( 3 ) );
-				sumCos += ( *_w ) ( p ) *cos ( mea ( 3 ) );
-			}
-			double Th = asin ( sumSin );
-			if ( sumCos<0 ) {
-				if ( sumSin>0 ) {
-					Th = M_PI-Th;
-				}
-				else {
-					Th = -M_PI-Th;
-				}
-			}
-
-			XtMTh.set_row ( tK,vec_1 ( Th ) );
-		}
-	}
-
-	it_file fou ( "mpf_u_weight.it" );
-
-	fou << Name ( "xth" ) << Xt;
-	fou << Name ( "Dt" ) << Dt;
-	fou << Name ( "Qtr" ) << Qtr;
-	fou << Name ( "xthE" ) << XtE;
-	fou << Name ( "xthM" ) << XtM;
-	fou << Name ( "xthMTh" ) << XtMTh;
-	//Exit program:
-
-	return 0;
-}
-
