root/library/bdm/stat/exp_family.h @ 629

Revision 629, 36.5 kB (checked in by smidl, 15 years ago)

egiw.variance works for multidimensional + cleanup in tests

  • Property svn:eol-style set to native
Line 
1/*!
2  \file
3  \brief Probability distributions for Exponential Family models.
4  \author Vaclav Smidl.
5
6  -----------------------------------
7  BDM++ - C++ library for Bayesian Decision Making under Uncertainty
8
9  Using IT++ for numerical operations
10  -----------------------------------
11*/
12
13#ifndef EF_H
14#define EF_H
15
16
17#include "../shared_ptr.h"
18#include "../base/bdmbase.h"
19#include "../math/chmat.h"
20
21namespace bdm
22{
23
24
25//! Global Uniform_RNG
26extern Uniform_RNG UniRNG;
27//! Global Normal_RNG
28extern Normal_RNG NorRNG;
29//! Global Gamma_RNG
30extern Gamma_RNG GamRNG;
31
32/*!
33* \brief General conjugate exponential family posterior density.
34
35* More?...
36*/
37
38class eEF : public epdf
39{
40        public:
41//      eEF() :epdf() {};
42                //! default constructor
43                eEF () : epdf () {};
44                //! logarithm of the normalizing constant, \f$\mathcal{I}\f$
45                virtual double lognc() const = 0;
46
47                //!Evaluate normalized log-probability
48                virtual double evallog_nn (const vec &val) const {
49                        bdm_error ("Not implemented");
50                        return 0.0;
51                }
52
53                //!Evaluate normalized log-probability
54                virtual double evallog (const vec &val) const {
55                        double tmp;
56                        tmp = evallog_nn (val) - lognc();
57                        return tmp;
58                }
59                //!Evaluate normalized log-probability for many samples
60                virtual vec evallog_m (const mat &Val) const {
61                        vec x (Val.cols());
62                        for (int i = 0;i < Val.cols();i++) {x (i) = evallog_nn (Val.get_col (i)) ;}
63                        return x -lognc();
64                }
65                //!Evaluate normalized log-probability for many samples
66                virtual vec evallog_m (const Array<vec> &Val) const {
67                        vec x (Val.length());
68                        for (int i = 0;i < Val.length();i++) {x (i) = evallog_nn (Val (i)) ;}
69                        return x -lognc();
70                }
71
72                //!Power of the density, used e.g. to flatten the density
73                virtual void pow (double p) {
74                        bdm_error ("Not implemented");
75                }
76};
77
78
79//! Estimator for Exponential family
80class BMEF : public BM
81{
82        protected:
83                //! forgetting factor
84                double frg;
85                //! cached value of lognc() in the previous step (used in evaluation of \c ll )
86                double last_lognc;
87        public:
88                //! Default constructor (=empty constructor)
89                BMEF (double frg0 = 1.0) : BM (), frg (frg0) {}
90                //! Copy constructor
91                BMEF (const BMEF &B) : BM (B), frg (B.frg), last_lognc (B.last_lognc) {}
92                //!get statistics from another model
93                virtual void set_statistics (const BMEF* BM0) {
94                        bdm_error ("Not implemented");
95                }
96
97                //! Weighted update of sufficient statistics (Bayes rule)
98                virtual void bayes (const vec &data, const double w) {};
99                //original Bayes
100                void bayes (const vec &dt);
101
102                //!Flatten the posterior according to the given BMEF (of the same type!)
103                virtual void flatten (const BMEF * B) {
104                        bdm_error ("Not implemented");
105                }
106
107                BMEF* _copy_ () const {
108                        bdm_error ("function _copy_ not implemented for this BM");
109                        return NULL;
110                }
111};
112
113template<class sq_T, template <typename> class TEpdf>
114class mlnorm;
115
116/*!
117* \brief Gaussian density with positive definite (decomposed) covariance matrix.
118
119* More?...
120*/
121template<class sq_T>
122class enorm : public eEF
123{
124        protected:
125                //! mean value
126                vec mu;
127                //! Covariance matrix in decomposed form
128                sq_T R;
129        public:
130                //!\name Constructors
131                //!@{
132
133                enorm () : eEF (), mu (), R () {};
134                enorm (const vec &mu, const sq_T &R) {set_parameters (mu, R);}
135                void set_parameters (const vec &mu, const sq_T &R);
136                /*! Create Normal density
137                \f[ f(rv) = N(\mu, R) \f]
138                from structure
139                \code
140                class = 'enorm<ldmat>', (OR) 'enorm<chmat>', (OR) 'enorm<fsqmat>';
141                mu    = [];                  // mean value
142                R     = [];                  // variance, square matrix of appropriate dimension
143                \endcode
144                */
145                void from_setting (const Setting &root);
146                void validate() {
147                        bdm_assert (mu.length() == R.rows(), "mu and R parameters do not match");
148                        dim = mu.length();
149                }
150                //!@}
151
152                //! \name Mathematical operations
153                //!@{
154
155                //! dupdate in exponential form (not really handy)
156                void dupdate (mat &v, double nu = 1.0);
157
158                vec sample() const;
159
160                double evallog_nn (const vec &val) const;
161                double lognc () const;
162                vec mean() const {return mu;}
163                vec variance() const {return diag (R.to_mat());}
164//      mlnorm<sq_T>* condition ( const RV &rvn ) const ; <=========== fails to cmpile. Why?
165                shared_ptr<mpdf> condition ( const RV &rvn ) const;
166
167                // target not typed to mlnorm<sq_T, enorm<sq_T> > &
168                // because that doesn't compile (perhaps because we
169                // haven't finished defining enorm yet), but the type
170                // is required
171                void condition ( const RV &rvn, mpdf &target ) const;
172
173                shared_ptr<epdf> marginal (const RV &rvn ) const;
174                void marginal ( const RV &rvn, enorm<sq_T> &target ) const;
175                //!@}
176
177                //! \name Access to attributes
178                //!@{
179
180                vec& _mu() {return mu;}
181                const vec& _mu() const {return mu;}
182                void set_mu (const vec mu0) { mu = mu0;}
183                sq_T& _R() {return R;}
184                const sq_T& _R() const {return R;}
185                //!@}
186
187};
188UIREGISTER2 (enorm, chmat);
189SHAREDPTR2 ( enorm, chmat );
190UIREGISTER2 (enorm, ldmat);
191SHAREDPTR2 ( enorm, ldmat );
192UIREGISTER2 (enorm, fsqmat);
193SHAREDPTR2 ( enorm, fsqmat );
194
195
196/*!
197* \brief Gauss-inverse-Wishart density stored in LD form
198
199* For \f$p\f$-variate densities, given rv.count() should be \f$p\times\f$ V.rows().
200*
201*/
202class egiw : public eEF
203{
204        protected:
205                //! Extended information matrix of sufficient statistics
206                ldmat V;
207                //! Number of data records (degrees of freedom) of sufficient statistics
208                double nu;
209                //! Dimension of the output
210                int dimx;
211                //! Dimension of the regressor
212                int nPsi;
213        public:
214                //!\name Constructors
215                //!@{
216                egiw() : eEF() {};
217                egiw (int dimx0, ldmat V0, double nu0 = -1.0) : eEF() {set_parameters (dimx0, V0, nu0);};
218
219                void set_parameters (int dimx0, ldmat V0, double nu0 = -1.0);
220                //!@}
221
222                vec sample() const;
223                vec mean() const;
224                vec variance() const;
225
226                //! LS estimate of \f$\theta\f$
227                vec est_theta() const;
228
229                //! Covariance of the LS estimate
230                ldmat est_theta_cov() const;
231
232                //! expected values of the linear coefficient and the covariance matrix are written to \c M and \c R , respectively
233                void mean_mat (mat &M, mat&R) const;
234                //! In this instance, val= [theta, r]. For multivariate instances, it is stored columnwise val = [theta_1 theta_2 ... r_1 r_2 ]
235                double evallog_nn (const vec &val) const;
236                double lognc () const;
237                void pow (double p) {V *= p;nu *= p;};
238
239                //! \name Access attributes
240                //!@{
241
242                ldmat& _V() {return V;}
243                const ldmat& _V() const {return V;}
244                double& _nu()  {return nu;}
245                const double& _nu() const {return nu;}
246                /*! Create Gauss-inverse-Wishart density
247                \f[ f(rv) = GiW(V,\nu) \f]
248                from structure
249                \code
250                class = 'egiw';
251                V     = [];               // square matrix
252                nu    = [];               // scalar \nu ((almost) degrees of freedom)
253                                                                  // when missing, it will be computed to obtain proper pdf
254                dimx  = [];               // dimension of the wishart part
255                rv = RV({'name'})         // description of RV
256                rvc = RV({'name'})        // description of RV in condition
257                \endcode
258                */
259               
260                void from_setting (const Setting &set) {
261                        epdf::from_setting(set);
262                        if (!UI::get (nu, set, "nu", UI::compulsory)) {nu=-1;}
263                        UI::get (dimx, set, "dimx", UI::compulsory);
264                        mat V;
265                        UI::get (V, set, "V", UI::compulsory);
266                        set_parameters (dimx, V, nu);
267                }
268                //!@}
269};
270UIREGISTER ( egiw );
271SHAREDPTR ( egiw );
272
273/*! \brief Dirichlet posterior density
274
275Continuous Dirichlet density of \f$n\f$-dimensional variable \f$x\f$
276\f[
277f(x|\beta) = \frac{\Gamma[\gamma]}{\prod_{i=1}^{n}\Gamma(\beta_i)} \prod_{i=1}^{n}x_i^{\beta_i-1}
278\f]
279where \f$\gamma=\sum_i \beta_i\f$.
280*/
281class eDirich: public eEF
282{
283        protected:
284                //!sufficient statistics
285                vec beta;
286        public:
287                //!\name Constructors
288                //!@{
289
290                eDirich () : eEF () {};
291                eDirich (const eDirich &D0) : eEF () {set_parameters (D0.beta);};
292                eDirich (const vec &beta0) {set_parameters (beta0);};
293                void set_parameters (const vec &beta0) {
294                        beta = beta0;
295                        dim = beta.length();
296                }
297                //!@}
298
299                vec sample() const {
300                        bdm_error ("Not implemented");
301                        return vec();
302                }
303
304                vec mean() const {return beta / sum (beta);};
305                vec variance() const {double gamma = sum (beta); return elem_mult (beta, (beta + 1)) / (gamma* (gamma + 1));}
306                //! In this instance, val is ...
307                double evallog_nn (const vec &val) const {
308                        double tmp; tmp = (beta - 1) * log (val);
309                        return tmp;
310                }
311
312                double lognc () const {
313                        double tmp;
314                        double gam = sum (beta);
315                        double lgb = 0.0;
316                        for (int i = 0;i < beta.length();i++) {lgb += lgamma (beta (i));}
317                        tmp = lgb - lgamma (gam);
318                        return tmp;
319                }
320
321                //!access function
322                vec& _beta()  {return beta;}
323                //!Set internal parameters
324};
325
326//! \brief Estimator for Multinomial density
327class multiBM : public BMEF
328{
329        protected:
330                //! Conjugate prior and posterior
331                eDirich est;
332                //! Pointer inside est to sufficient statistics
333                vec &beta;
334        public:
335                //!Default constructor
336                multiBM () : BMEF (), est (), beta (est._beta()) {
337                        if (beta.length() > 0) {last_lognc = est.lognc();}
338                        else{last_lognc = 0.0;}
339                }
340                //!Copy constructor
341                multiBM (const multiBM &B) : BMEF (B), est (B.est), beta (est._beta()) {}
342                //! Sets sufficient statistics to match that of givefrom mB0
343                void set_statistics (const BM* mB0) {const multiBM* mB = dynamic_cast<const multiBM*> (mB0); beta = mB->beta;}
344                void bayes (const vec &dt) {
345                        if (frg < 1.0) {beta *= frg;last_lognc = est.lognc();}
346                        beta += dt;
347                        if (evalll) {ll = est.lognc() - last_lognc;}
348                }
349                double logpred (const vec &dt) const {
350                        eDirich pred (est);
351                        vec &beta = pred._beta();
352
353                        double lll;
354                        if (frg < 1.0)
355                                {beta *= frg;lll = pred.lognc();}
356                        else
357                                if (evalll) {lll = last_lognc;}
358                                else{lll = pred.lognc();}
359
360                        beta += dt;
361                        return pred.lognc() - lll;
362                }
363                void flatten (const BMEF* B) {
364                        const multiBM* E = dynamic_cast<const multiBM*> (B);
365                        // sum(beta) should be equal to sum(B.beta)
366                        const vec &Eb = E->beta;//const_cast<multiBM*> ( E )->_beta();
367                        beta *= (sum (Eb) / sum (beta));
368                        if (evalll) {last_lognc = est.lognc();}
369                }
370                //! reimplemnetation of BM::posterior()
371                const eDirich& posterior() const {return est;};
372                //! constructor function               
373                void set_parameters (const vec &beta0) {
374                        est.set_parameters (beta0);
375                        if (evalll) {last_lognc = est.lognc();}
376                }
377};
378
379/*!
380 \brief Gamma posterior density
381
382 Multivariate Gamma density as product of independent univariate densities.
383 \f[
384 f(x|\alpha,\beta) = \prod f(x_i|\alpha_i,\beta_i)
385 \f]
386*/
387
388class egamma : public eEF
389{
390        protected:
391                //! Vector \f$\alpha\f$
392                vec alpha;
393                //! Vector \f$\beta\f$
394                vec beta;
395        public :
396                //! \name Constructors
397                //!@{
398                egamma () : eEF (), alpha (0), beta (0) {};
399                egamma (const vec &a, const vec &b) {set_parameters (a, b);};
400                void set_parameters (const vec &a, const vec &b) {alpha = a, beta = b;dim = alpha.length();};
401                //!@}
402
403                vec sample() const;
404                double evallog (const vec &val) const;
405                double lognc () const;
406                //! Returns pointer to internal alpha. Potentially dengerous: use with care!
407                vec& _alpha() {return alpha;}
408                //! Returns pointer to internal beta. Potentially dengerous: use with care!
409                vec& _beta() {return beta;}
410                vec mean() const {return elem_div (alpha, beta);}
411                vec variance() const {return elem_div (alpha, elem_mult (beta, beta)); }
412
413                /*! Create Gamma density
414                \f[ f(rv|rvc) = \Gamma(\alpha, \beta) \f]
415                from structure
416                \code
417                class = 'egamma';
418                alpha = [...];         // vector of alpha
419                beta = [...];          // vector of beta
420                rv = RV({'name'})      // description of RV
421                \endcode
422                */
423                void from_setting (const Setting &set) {
424                        epdf::from_setting (set); // reads rv
425                        UI::get (alpha, set, "alpha", UI::compulsory);
426                        UI::get (beta, set, "beta", UI::compulsory);
427                        validate();
428                }
429                void validate() {
430                        bdm_assert (alpha.length() == beta.length(), "parameters do not match");
431                        dim = alpha.length();
432                }
433};
434UIREGISTER (egamma);
435SHAREDPTR ( egamma );
436
437/*!
438 \brief Inverse-Gamma posterior density
439
440 Multivariate inverse-Gamma density as product of independent univariate densities.
441 \f[
442 f(x|\alpha,\beta) = \prod f(x_i|\alpha_i,\beta_i)
443 \f]
444
445Vector \f$\beta\f$ has different meaning (in fact it is 1/beta as used in definition of iG)
446
447 Inverse Gamma can be converted to Gamma using \f[
448 x\sim iG(a,b) => 1/x\sim G(a,1/b)
449\f]
450This relation is used in sampling.
451 */
452
453class eigamma : public egamma
454{
455        protected:
456        public :
457                //! \name Constructors
458                //! All constructors are inherited
459                //!@{
460                //!@}
461
462                vec sample() const {return 1.0 / egamma::sample();};
463                //! Returns poiter to alpha and beta. Potentially dangerous: use with care!
464                vec mean() const {return elem_div (beta, alpha - 1);}
465                vec variance() const {vec mea = mean(); return elem_div (elem_mult (mea, mea), alpha - 2);}
466};
467/*
468//! Weighted mixture of epdfs with external owned components.
469class emix : public epdf {
470protected:
471        int n;
472        vec &w;
473        Array<epdf*> Coms;
474public:
475//! Default constructor
476        emix ( const RV &rv, vec &w0): epdf(rv), n(w0.length()), w(w0), Coms(n) {};
477        void set_parameters( int &i, double wi, epdf* ep){w(i)=wi;Coms(i)=ep;}
478        vec mean(){vec pom; for(int i=0;i<n;i++){pom+=Coms(i)->mean()*w(i);} return pom;};
479};
480*/
481
482//!  Uniform distributed density on a rectangular support
483
484class euni: public epdf
485{
486        protected:
487//! lower bound on support
488                vec low;
489//! upper bound on support
490                vec high;
491//! internal
492                vec distance;
493//! normalizing coefficients
494                double nk;
495//! cache of log( \c nk )
496                double lnk;
497        public:
498                //! \name Constructors
499                //!@{
500                euni () : epdf () {}
501                euni (const vec &low0, const vec &high0) {set_parameters (low0, high0);}
502                void set_parameters (const vec &low0, const vec &high0) {
503                        distance = high0 - low0;
504                        low = low0;
505                        high = high0;
506                        nk = prod (1.0 / distance);
507                        lnk = log (nk);
508                        dim = low.length();
509                }
510                //!@}
511
512                double evallog (const vec &val) const  {
513                        if (any (val < low) && any (val > high)) {return inf;}
514                        else return lnk;
515                }
516                vec sample() const {
517                        vec smp (dim);
518#pragma omp critical
519                        UniRNG.sample_vector (dim , smp);
520                        return low + elem_mult (distance, smp);
521                }
522                //! set values of \c low and \c high
523                vec mean() const {return (high -low) / 2.0;}
524                vec variance() const {return (pow (high, 2) + pow (low, 2) + elem_mult (high, low)) / 3.0;}
525                /*! Create Uniform density
526                \f[ f(rv) = U(low,high) \f]
527                from structure
528                 \code
529                 class = 'euni'
530                 high = [...];          // vector of upper bounds
531                 low = [...];           // vector of lower bounds
532                 rv = RV({'name'});     // description of RV
533                 \endcode
534                 */
535                void from_setting (const Setting &set) {
536                        epdf::from_setting (set); // reads rv and rvc
537
538                        UI::get (high, set, "high", UI::compulsory);
539                        UI::get (low, set, "low", UI::compulsory);
540                        set_parameters(low,high);
541                        validate();
542                }
543                void validate() {
544                        bdm_assert(high.length()==low.length(), "Incompatible high and low vectors");
545                        dim = high.length();
546                        bdm_assert (min (distance) > 0.0, "bad support");
547                }
548};
549UIREGISTER(euni);
550
551/*!
552 \brief Normal distributed linear function with linear function of mean value;
553
554 Mean value \f$ \mu=A*\mbox{rvc}+\mu_0 \f$.
555*/
556template < class sq_T, template <typename> class TEpdf = enorm >
557class mlnorm : public mpdf_internal< TEpdf<sq_T> >
558{
559        protected:
560                //! Internal epdf that arise by conditioning on \c rvc
561                mat A;
562                //! Constant additive term
563                vec mu_const;
564//                      vec& _mu; //cached epdf.mu; !!!!!! WHY NOT?
565        public:
566                //! \name Constructors
567                //!@{
568                mlnorm() : mpdf_internal< TEpdf<sq_T> >() {};
569                mlnorm (const mat &A, const vec &mu0, const sq_T &R) : mpdf_internal< TEpdf<sq_T> >() {
570                        set_parameters (A, mu0, R);
571                }
572
573                //! Set \c A and \c R
574                void set_parameters (const  mat &A0, const vec &mu0, const sq_T &R0) { 
575                        this->iepdf.set_parameters (zeros (A0.rows()), R0);
576                        A = A0;
577                        mu_const = mu0;
578                        this->dimc = A0.cols();
579                }
580                //!@}
581                //! Set value of \c rvc . Result of this operation is stored in \c epdf use function \c _ep to access it.
582                void condition (const vec &cond) {
583                        this->iepdf._mu() = A * cond + mu_const;
584//R is already assigned;
585                }
586
587                //!access function
588                const vec& _mu_const() const {return mu_const;}
589                //!access function
590                const mat& _A() const {return A;}
591                //!access function
592                mat _R() const { return this->iepdf._R().to_mat(); }
593
594                //! Debug stream
595                template<typename sq_M>
596                friend std::ostream &operator<< (std::ostream &os,  mlnorm<sq_M, enorm> &ml);
597
598                /*! Create Normal density with linear function of mean value
599                 \f[ f(rv|rvc) = N(A*rvc+const, R) \f]
600                from structure
601                \code
602                class = 'mlnorm<ldmat>', (OR) 'mlnorm<chmat>', (OR) 'mlnorm<fsqmat>';
603                A     = [];                  // matrix or vector of appropriate dimension
604                const = [];                  // vector of constant term
605                R     = [];                  // square matrix of appropriate dimension
606                \endcode
607                */
608                void from_setting (const Setting &set) {
609                        mpdf::from_setting (set);
610
611                        UI::get (A, set, "A", UI::compulsory);
612                        UI::get (mu_const, set, "const", UI::compulsory);
613                        mat R0;
614                        UI::get (R0, set, "R", UI::compulsory);
615                        set_parameters (A, mu_const, R0);
616                        validate();
617                };
618                void validate() {
619                        bdm_assert (A.rows() == mu_const.length(), "mlnorm: A vs. mu mismatch");
620                        bdm_assert (A.rows() == _R().rows(), "mlnorm: A vs. R mismatch");
621                       
622                }
623};
624UIREGISTER2 (mlnorm,ldmat);
625SHAREDPTR2 ( mlnorm, ldmat );
626UIREGISTER2 (mlnorm,fsqmat);
627SHAREDPTR2 ( mlnorm, fsqmat );
628UIREGISTER2 (mlnorm, chmat);
629SHAREDPTR2 ( mlnorm, chmat );
630
631//! Mpdf with general function for mean value
632template<class sq_T>
633class mgnorm : public mpdf_internal< enorm< sq_T > >
634{
635        private:
636//                      vec &mu; WHY NOT?
637                shared_ptr<fnc> g;
638
639        public:
640                //!default constructor
641                mgnorm() : mpdf_internal<enorm<sq_T> >() { }
642                //!set mean function
643                inline void set_parameters (const shared_ptr<fnc> &g0, const sq_T &R0);
644                inline void condition (const vec &cond);
645
646
647                /*! Create Normal density with given function of mean value
648                \f[ f(rv|rvc) = N( g(rvc), R) \f]
649                from structure
650                \code
651                class = 'mgnorm';
652                g.class =  'fnc';      // function for mean value evolution
653                g._fields_of_fnc = ...;
654
655                R = [1, 0;             // covariance matrix
656                        0, 1];
657                        --OR --
658                dR = [1, 1];           // diagonal of cavariance matrix
659
660                rv = RV({'name'})      // description of RV
661                rvc = RV({'name'})     // description of RV in condition
662                \endcode
663                */
664
665                void from_setting (const Setting &set) {
666                        mpdf::from_setting(set);
667                        shared_ptr<fnc> g = UI::build<fnc> (set, "g", UI::compulsory);
668
669                        mat R;
670                        vec dR;
671                        if (UI::get (dR, set, "dR"))
672                                R = diag (dR);
673                        else
674                                UI::get (R, set, "R", UI::compulsory);
675
676                        set_parameters (g, R);
677                        validate();
678                }
679                void validate() {
680                        bdm_assert(g->dimension()==this->dimension(),"incompatible function");
681                }
682};
683
684UIREGISTER2 (mgnorm, chmat);
685SHAREDPTR2 ( mgnorm, chmat );
686
687
688/*! (Approximate) Student t density with linear function of mean value
689
690The internal epdf of this class is of the type of a Gaussian (enorm).
691However, each conditioning is trying to assure the best possible approximation by taking into account the zeta function. See [] for reference.
692
693Perhaps a moment-matching technique?
694*/
695class mlstudent : public mlnorm<ldmat, enorm>
696{
697        protected:
698                //! Variable \f$ \Lambda \f$ from theory
699                ldmat Lambda;
700                //! Reference to variable \f$ R \f$
701                ldmat &_R;
702                //! Variable \f$ R_e \f$
703                ldmat Re;
704        public:
705                mlstudent () : mlnorm<ldmat, enorm> (),
706                                Lambda (),      _R (iepdf._R()) {}
707                //! constructor function
708                void set_parameters (const mat &A0, const vec &mu0, const ldmat &R0, const ldmat& Lambda0) {
709                        iepdf.set_parameters (mu0, R0);// was Lambda, why?
710                        A = A0;
711                        mu_const = mu0;
712                        Re = R0;
713                        Lambda = Lambda0;
714                }
715                void condition (const vec &cond) {
716                        iepdf._mu() = A * cond + mu_const;
717                        double zeta;
718                        //ugly hack!
719                        if ( (cond.length() + 1) == Lambda.rows()) {
720                                zeta = Lambda.invqform (concat (cond, vec_1 (1.0)));
721                        } else {
722                                zeta = Lambda.invqform (cond);
723                        }
724                        _R = Re;
725                        _R *= (1 + zeta);// / ( nu ); << nu is in Re!!!!!!
726                };
727
728                void validate() {
729                        bdm_assert (A.rows() == mu_const.length(), "mlstudent: A vs. mu mismatch");
730                        bdm_assert (_R.rows() == A.rows(), "mlstudent: A vs. R mismatch");
731                       
732                }
733};
734/*!
735\brief  Gamma random walk
736
737Mean value, \f$\mu\f$, of this density is given by \c rvc .
738Standard deviation of the random walk is proportional to one \f$k\f$-th the mean.
739This is achieved by setting \f$\alpha=k\f$ and \f$\beta=k/\mu\f$.
740
741The standard deviation of the walk is then: \f$\mu/\sqrt(k)\f$.
742*/
743class mgamma : public mpdf_internal<egamma>
744{
745        protected:
746
747                //! Constant \f$k\f$
748                double k;
749
750                //! cache of iepdf.beta
751                vec &_beta;
752
753        public:
754                //! Constructor
755                mgamma() : mpdf_internal<egamma>(), k (0),
756                                _beta (iepdf._beta()) {
757                }
758
759                //! Set value of \c k
760                void set_parameters (double k, const vec &beta0);
761
762                void condition (const vec &val) {_beta = k / val;};
763                /*! Create Gamma density with conditional mean value
764                \f[ f(rv|rvc) = \Gamma(k, k/rvc) \f]
765                from structure
766                \code
767                  class = 'mgamma';
768                  beta = [...];          // vector of initial alpha
769                  k = 1.1;               // multiplicative constant k
770                  rv = RV({'name'})      // description of RV
771                  rvc = RV({'name'})     // description of RV in condition
772                 \endcode
773                */
774                void from_setting (const Setting &set) {
775                        mpdf::from_setting (set); // reads rv and rvc
776                        vec betatmp; // ugly but necessary
777                        UI::get (betatmp, set, "beta", UI::compulsory);
778                        UI::get (k, set, "k", UI::compulsory);
779                        set_parameters (k, betatmp);
780                }
781};
782UIREGISTER (mgamma);
783SHAREDPTR (mgamma);
784
785/*!
786\brief  Inverse-Gamma random walk
787
788Mean value, \f$ \mu \f$, of this density is given by \c rvc .
789Standard deviation of the random walk is proportional to one \f$ k \f$-th the mean.
790This is achieved by setting \f$ \alpha=\mu/k^2+2 \f$ and \f$ \beta=\mu(\alpha-1)\f$.
791
792The standard deviation of the walk is then: \f$ \mu/\sqrt(k)\f$.
793 */
794class migamma : public mpdf_internal<eigamma>
795{
796        protected:
797                //! Constant \f$k\f$
798                double k;
799
800                //! cache of iepdf.alpha
801                vec &_alpha;
802
803                //! cache of iepdf.beta
804                vec &_beta;
805
806        public:
807                //! \name Constructors
808                //!@{
809                migamma() : mpdf_internal<eigamma>(),
810                                k (0),
811                                _alpha (iepdf._alpha()),
812                                _beta (iepdf._beta()) {
813                }
814
815                migamma (const migamma &m) : mpdf_internal<eigamma>(),
816                                k (0),
817                                _alpha (iepdf._alpha()),
818                                _beta (iepdf._beta()) {
819                }
820                //!@}
821
822                //! Set value of \c k
823                void set_parameters (int len, double k0) {
824                        k = k0;
825                        iepdf.set_parameters ( (1.0 / (k*k) + 2.0) *ones (len) /*alpha*/, ones (len) /*beta*/);
826                        dimc = dimension();
827                };
828                void condition (const vec &val) {
829                        _beta = elem_mult (val, (_alpha - 1.0));
830                };
831};
832
833
834/*!
835\brief  Gamma random walk around a fixed point
836
837Mean value, \f$\mu\f$, of this density is given by a geometric combination of \c rvc and given fixed point, \f$p\f$. \f$l\f$ is the coefficient of the geometric combimation
838\f[ \mu = \mu_{t-1} ^{l} p^{1-l}\f]
839
840Standard deviation of the random walk is proportional to one \f$k\f$-th the mean.
841This is achieved by setting \f$\alpha=k\f$ and \f$\beta=k/\mu\f$.
842
843The standard deviation of the walk is then: \f$\mu/\sqrt(k)\f$.
844*/
845class mgamma_fix : public mgamma
846{
847        protected:
848                //! parameter l
849                double l;
850                //! reference vector
851                vec refl;
852        public:
853                //! Constructor
854                mgamma_fix () : mgamma (), refl () {};
855                //! Set value of \c k
856                void set_parameters (double k0 , vec ref0, double l0) {
857                        mgamma::set_parameters (k0, ref0);
858                        refl = pow (ref0, 1.0 - l0);l = l0;
859                        dimc = dimension();
860                };
861
862                void condition (const vec &val) {vec mean = elem_mult (refl, pow (val, l)); _beta = k / mean;};
863};
864
865
866/*!
867\brief  Inverse-Gamma random walk around a fixed point
868
869Mean value, \f$\mu\f$, of this density is given by a geometric combination of \c rvc and given fixed point, \f$p\f$. \f$l\f$ is the coefficient of the geometric combimation
870\f[ \mu = \mu_{t-1} ^{l} p^{1-l}\f]
871
872==== Check == vv =
873Standard deviation of the random walk is proportional to one \f$k\f$-th the mean.
874This is achieved by setting \f$\alpha=k\f$ and \f$\beta=k/\mu\f$.
875
876The standard deviation of the walk is then: \f$\mu/\sqrt(k)\f$.
877 */
878class migamma_ref : public migamma
879{
880        protected:
881                //! parameter l
882                double l;
883                //! reference vector
884                vec refl;
885        public:
886                //! Constructor
887                migamma_ref () : migamma (), refl () {};
888                //! Set value of \c k
889                void set_parameters (double k0 , vec ref0, double l0) {
890                        migamma::set_parameters (ref0.length(), k0);
891                        refl = pow (ref0, 1.0 - l0);
892                        l = l0;
893                        dimc = dimension();
894                };
895
896                void condition (const vec &val) {
897                        vec mean = elem_mult (refl, pow (val, l));
898                        migamma::condition (mean);
899                };
900
901
902                /*! Create inverse-Gamma density with conditional mean value
903                \f[ f(rv|rvc) = i\Gamma(k, k/(rvc^l \circ ref^{(1-l)}) \f]
904                from structure
905                \code
906                class = 'migamma_ref';
907                ref = [1e-5; 1e-5; 1e-2 1e-3];            // reference vector
908                l = 0.999;                                // constant l
909                k = 0.1;                                  // constant k
910                rv = RV({'name'})                         // description of RV
911                rvc = RV({'name'})                        // description of RV in condition
912                \endcode
913                 */
914                void from_setting (const Setting &set);
915
916                // TODO dodelat void to_setting( Setting &set ) const;
917};
918
919
920UIREGISTER (migamma_ref);
921SHAREDPTR (migamma_ref);
922
923/*! Log-Normal probability density
924 only allow diagonal covariances!
925
926Density of the form \f$ \log(x)\sim \mathcal{N}(\mu,\sigma^2) \f$ , i.e.
927\f[
928x \sim \frac{1}{x\sigma\sqrt{2\pi}}\exp{-\frac{1}{2\sigma^2}(\log(x)-\mu)}
929\f]
930
931Function from_setting loads mu and R in the same way as it does for enorm<>!
932*/
933class elognorm: public enorm<ldmat>
934{
935        public:
936                vec sample() const {return exp (enorm<ldmat>::sample());};
937                vec mean() const {vec var = enorm<ldmat>::variance();return exp (mu - 0.5*var);};
938
939};
940
941/*!
942\brief  Log-Normal random walk
943
944Mean value, \f$\mu\f$, is...
945
946 */
947class mlognorm : public mpdf_internal<elognorm>
948{
949        protected:
950                //! parameter 1/2*sigma^2
951                double sig2;
952
953                //! access
954                vec &mu;
955        public:
956                //! Constructor
957                mlognorm() : mpdf_internal<elognorm>(),
958                                sig2 (0),
959                                mu (iepdf._mu()) {
960                }
961
962                //! Set value of \c k
963                void set_parameters (int size, double k) {
964                        sig2 = 0.5 * log (k * k + 1);
965                        iepdf.set_parameters (zeros (size), 2*sig2*eye (size));
966
967                        dimc = size;
968                };
969
970                void condition (const vec &val) {
971                        mu = log (val) - sig2;//elem_mult ( refl,pow ( val,l ) );
972                };
973
974                /*! Create logNormal random Walk
975                \f[ f(rv|rvc) = log\mathcal{N}( \log(rvc)-0.5\log(k^2+1), k I) \f]
976                from structure
977                \code
978                class = 'mlognorm';
979                k   = 0.1;               // "variance" k
980                mu0 = 0.1;               // Initial value of mean
981                rv  = RV({'name'})       // description of RV
982                rvc = RV({'name'})       // description of RV in condition
983                \endcode
984                */
985                void from_setting (const Setting &set);
986
987                // TODO dodelat void to_setting( Setting &set ) const;
988
989};
990
991UIREGISTER (mlognorm);
992SHAREDPTR (mlognorm);
993
994/*! inverse Wishart density defined on Choleski decomposition
995
996*/
997class eWishartCh : public epdf
998{
999        protected:
1000                //! Upper-Triagle of Choleski decomposition of \f$ \Psi \f$
1001                chmat Y;
1002                //! dimension of matrix  \f$ \Psi \f$
1003                int p;
1004                //! degrees of freedom  \f$ \nu \f$
1005                double delta;
1006        public:
1007                //! Set internal structures
1008                void set_parameters (const mat &Y0, const double delta0) {Y = chmat (Y0);delta = delta0; p = Y.rows(); dim = p * p; }
1009                //! Sample matrix argument
1010                mat sample_mat() const {
1011                        mat X = zeros (p, p);
1012
1013                        //sample diagonal
1014                        for (int i = 0;i < p;i++) {
1015                                GamRNG.setup (0.5* (delta - i) , 0.5);   // no +1 !! index if from 0
1016#pragma omp critical
1017                                X (i, i) = sqrt (GamRNG());
1018                        }
1019                        //do the rest
1020                        for (int i = 0;i < p;i++) {
1021                                for (int j = i + 1;j < p;j++) {
1022#pragma omp critical
1023                                        X (i, j) = NorRNG.sample();
1024                                }
1025                        }
1026                        return X*Y._Ch();// return upper triangular part of the decomposition
1027                }
1028                vec sample () const {
1029                        return vec (sample_mat()._data(), p*p);
1030                }
1031                //! fast access function y0 will be copied into Y.Ch.
1032                void setY (const mat &Ch0) {copy_vector (dim, Ch0._data(), Y._Ch()._data());}
1033                //! fast access function y0 will be copied into Y.Ch.
1034                void _setY (const vec &ch0) {copy_vector (dim, ch0._data(), Y._Ch()._data()); }
1035                //! access function
1036                const chmat& getY() const {return Y;}
1037};
1038
1039//! Inverse Wishart on Choleski decomposition
1040/*! Being computed by conversion from `standard' Wishart
1041*/
1042class eiWishartCh: public epdf
1043{
1044        protected:
1045                //! Internal instance of Wishart density
1046                eWishartCh W;
1047                //! size of Ch
1048                int p;
1049                //! parameter delta
1050                double delta;
1051        public:
1052                //! constructor function
1053                void set_parameters (const mat &Y0, const double delta0) {
1054                        delta = delta0;
1055                        W.set_parameters (inv (Y0), delta0);
1056                        dim = W.dimension(); p = Y0.rows();
1057                }
1058                vec sample() const {mat iCh; iCh = inv (W.sample_mat()); return vec (iCh._data(), dim);}
1059                //! access function
1060                void _setY (const vec &y0) {
1061                        mat Ch (p, p);
1062                        mat iCh (p, p);
1063                        copy_vector (dim, y0._data(), Ch._data());
1064
1065                        iCh = inv (Ch);
1066                        W.setY (iCh);
1067                }
1068                virtual double evallog (const vec &val) const {
1069                        chmat X (p);
1070                        const chmat& Y = W.getY();
1071
1072                        copy_vector (p*p, val._data(), X._Ch()._data());
1073                        chmat iX (p);X.inv (iX);
1074                        // compute
1075//                              \frac{ |\Psi|^{m/2}|X|^{-(m+p+1)/2}e^{-tr(\Psi X^{-1})/2} }{ 2^{mp/2}\Gamma_p(m/2)},
1076                        mat M = Y.to_mat() * iX.to_mat();
1077
1078                        double log1 = 0.5 * p * (2 * Y.logdet()) - 0.5 * (delta + p + 1) * (2 * X.logdet()) - 0.5 * trace (M);
1079                        //Fixme! Multivariate gamma omitted!! it is ok for sampling, but not otherwise!!
1080
1081                        /*                              if (0) {
1082                                                                mat XX=X.to_mat();
1083                                                                mat YY=Y.to_mat();
1084
1085                                                                double log2 = 0.5*p*log(det(YY))-0.5*(delta+p+1)*log(det(XX))-0.5*trace(YY*inv(XX));
1086                                                                cout << log1 << "," << log2 << endl;
1087                                                        }*/
1088                        return log1;
1089                };
1090
1091};
1092
1093//! Random Walk on inverse Wishart
1094class rwiWishartCh : public mpdf_internal<eiWishartCh>
1095{
1096        protected:
1097                //!square root of \f$ \nu-p-1 \f$ - needed for computation of \f$ \Psi \f$ from conditions
1098                double sqd;
1099                //!reference point for diagonal
1100                vec refl;
1101                //! power of the reference
1102                double l;
1103                //! dimension
1104                int p;
1105
1106        public:
1107                rwiWishartCh() : sqd (0), l (0), p (0) {}
1108                //! constructor function
1109                void set_parameters (int p0, double k, vec ref0, double l0) {
1110                        p = p0;
1111                        double delta = 2 / (k * k) + p + 3;
1112                        sqd = sqrt (delta - p - 1);
1113                        l = l0;
1114                        refl = pow (ref0, 1 - l);
1115
1116                        iepdf.set_parameters (eye (p), delta);
1117                        dimc = iepdf.dimension();
1118                }
1119                void condition (const vec &c) {
1120                        vec z = c;
1121                        int ri = 0;
1122                        for (int i = 0;i < p*p;i += (p + 1)) {//trace diagonal element
1123                                z (i) = pow (z (i), l) * refl (ri);
1124                                ri++;
1125                        }
1126
1127                        iepdf._setY (sqd*z);
1128                }
1129};
1130
1131//! Switch between various resampling methods.
1132enum RESAMPLING_METHOD { MULTINOMIAL = 0, STRATIFIED = 1, SYSTEMATIC = 3 };
1133/*!
1134\brief Weighted empirical density
1135
1136Used e.g. in particle filters.
1137*/
1138class eEmp: public epdf
1139{
1140        protected :
1141                //! Number of particles
1142                int n;
1143                //! Sample weights \f$w\f$
1144                vec w;
1145                //! Samples \f$x^{(i)}, i=1..n\f$
1146                Array<vec> samples;
1147        public:
1148                //! \name Constructors
1149                //!@{
1150                eEmp () : epdf (), w (), samples () {};
1151                //! copy constructor
1152                eEmp (const eEmp &e) : epdf (e), w (e.w), samples (e.samples) {};
1153                //!@}
1154
1155                //! Set samples and weights
1156                void set_statistics (const vec &w0, const epdf &pdf0);
1157                //! Set samples and weights
1158                void set_statistics (const epdf &pdf0 , int n) {set_statistics (ones (n) / n, pdf0);};
1159                //! Set sample
1160                void set_samples (const epdf* pdf0);
1161                //! Set sample
1162                void set_parameters (int n0, bool copy = true) {n = n0; w.set_size (n0, copy);samples.set_size (n0, copy);};
1163                //! Set samples
1164                void set_parameters (const Array<vec> &Av) {
1165                        bdm_assert(Av.size()>0,"Empty samples"); 
1166                        n = Av.size(); 
1167                        epdf::set_parameters(Av(0).length());
1168                        w=1/n*ones(n);
1169                        samples=Av;
1170                };
1171                //! Potentially dangerous, use with care.
1172                vec& _w()  {return w;};
1173                //! Potentially dangerous, use with care.
1174                const vec& _w() const {return w;};
1175                //! access function
1176                Array<vec>& _samples() {return samples;};
1177                //! access function
1178                const Array<vec>& _samples() const {return samples;};
1179                //! Function performs resampling, i.e. removal of low-weight samples and duplication of high-weight samples such that the new samples represent the same density.
1180                ivec resample (RESAMPLING_METHOD method = SYSTEMATIC);
1181
1182                //! inherited operation : NOT implemented
1183                vec sample() const {
1184                        bdm_error ("Not implemented");
1185                        return vec();
1186                }
1187
1188                //! inherited operation : NOT implemented
1189                double evallog (const vec &val) const {
1190                        bdm_error ("Not implemented");
1191                        return 0.0;
1192                }
1193
1194                vec mean() const {
1195                        vec pom = zeros (dim);
1196                        for (int i = 0;i < n;i++) {pom += samples (i) * w (i);}
1197                        return pom;
1198                }
1199                vec variance() const {
1200                        vec pom = zeros (dim);
1201                        for (int i = 0;i < n;i++) {pom += pow (samples (i), 2) * w (i);}
1202                        return pom -pow (mean(), 2);
1203                }
1204                //! For this class, qbounds are minimum and maximum value of the population!
1205                void qbounds (vec &lb, vec &ub, double perc = 0.95) const {
1206                        // lb in inf so than it will be pushed below;
1207                        lb.set_size (dim);
1208                        ub.set_size (dim);
1209                        lb = std::numeric_limits<double>::infinity();
1210                        ub = -std::numeric_limits<double>::infinity();
1211                        int j;
1212                        for (int i = 0;i < n;i++) {
1213                                for (j = 0;j < dim; j++) {
1214                                        if (samples (i) (j) < lb (j)) {lb (j) = samples (i) (j);}
1215                                        if (samples (i) (j) > ub (j)) {ub (j) = samples (i) (j);}
1216                                }
1217                        }
1218                }
1219};
1220
1221
1222////////////////////////
1223
1224template<class sq_T>
1225void enorm<sq_T>::set_parameters (const vec &mu0, const sq_T &R0)
1226{
1227//Fixme test dimensions of mu0 and R0;
1228        mu = mu0;
1229        R = R0;
1230        validate();
1231};
1232
1233template<class sq_T>
1234void enorm<sq_T>::from_setting (const Setting &set)
1235{
1236        epdf::from_setting (set); //reads rv
1237
1238        UI::get (mu, set, "mu", UI::compulsory);
1239        mat Rtmp;// necessary for conversion
1240        UI::get (Rtmp, set, "R", UI::compulsory);
1241        R = Rtmp; // conversion
1242        validate();
1243}
1244
1245template<class sq_T>
1246void enorm<sq_T>::dupdate (mat &v, double nu)
1247{
1248        //
1249};
1250
1251// template<class sq_T>
1252// void enorm<sq_T>::tupdate ( double phi, mat &vbar, double nubar ) {
1253//      //
1254// };
1255
1256template<class sq_T>
1257vec enorm<sq_T>::sample() const
1258{
1259        vec x (dim);
1260#pragma omp critical
1261        NorRNG.sample_vector (dim, x);
1262        vec smp = R.sqrt_mult (x);
1263
1264        smp += mu;
1265        return smp;
1266};
1267
1268// template<class sq_T>
1269// double enorm<sq_T>::eval ( const vec &val ) const {
1270//      double pdfl,e;
1271//      pdfl = evallog ( val );
1272//      e = exp ( pdfl );
1273//      return e;
1274// };
1275
1276template<class sq_T>
1277double enorm<sq_T>::evallog_nn (const vec &val) const
1278{
1279        // 1.83787706640935 = log(2pi)
1280        double tmp = -0.5 * (R.invqform (mu - val));// - lognc();
1281        return  tmp;
1282};
1283
1284template<class sq_T>
1285inline double enorm<sq_T>::lognc () const
1286{
1287        // 1.83787706640935 = log(2pi)
1288        double tmp = 0.5 * (R.cols() * 1.83787706640935 + R.logdet());
1289        return tmp;
1290};
1291
1292
1293// template<class sq_T>
1294// vec mlnorm<sq_T>::samplecond (const  vec &cond, double &lik ) {
1295//      this->condition ( cond );
1296//      vec smp = epdf.sample();
1297//      lik = epdf.eval ( smp );
1298//      return smp;
1299// }
1300
1301// template<class sq_T>
1302// mat mlnorm<sq_T>::samplecond (const vec &cond, vec &lik, int n ) {
1303//      int i;
1304//      int dim = rv.count();
1305//      mat Smp ( dim,n );
1306//      vec smp ( dim );
1307//      this->condition ( cond );
1308//
1309//      for ( i=0; i<n; i++ ) {
1310//              smp = epdf.sample();
1311//              lik ( i ) = epdf.eval ( smp );
1312//              Smp.set_col ( i ,smp );
1313//      }
1314//
1315//      return Smp;
1316// }
1317
1318
1319template<class sq_T>
1320shared_ptr<epdf> enorm<sq_T>::marginal ( const RV &rvn ) const
1321{
1322        enorm<sq_T> *tmp = new enorm<sq_T> ();
1323        shared_ptr<epdf> narrow(tmp);
1324        marginal ( rvn, *tmp );
1325        return narrow;
1326}
1327
1328template<class sq_T>
1329void enorm<sq_T>::marginal ( const RV &rvn, enorm<sq_T> &target ) const
1330{
1331        bdm_assert (isnamed(), "rv description is not assigned");
1332        ivec irvn = rvn.dataind (rv);
1333
1334        sq_T Rn (R, irvn);  // select rows and columns of R
1335
1336        target.set_rv ( rvn );
1337        target.set_parameters (mu (irvn), Rn);
1338}
1339
1340template<class sq_T>
1341shared_ptr<mpdf> enorm<sq_T>::condition ( const RV &rvn ) const
1342{
1343        mlnorm<sq_T> *tmp = new mlnorm<sq_T> ();
1344        shared_ptr<mpdf> narrow(tmp);
1345        condition ( rvn, *tmp );
1346        return narrow;
1347}
1348
1349template<class sq_T>
1350void enorm<sq_T>::condition ( const RV &rvn, mpdf &target ) const
1351{
1352        typedef mlnorm<sq_T> TMlnorm;
1353
1354        bdm_assert (isnamed(), "rvs are not assigned");
1355        TMlnorm &uptarget = dynamic_cast<TMlnorm &>(target);
1356
1357        RV rvc = rv.subt (rvn);
1358        bdm_assert ( (rvc._dsize() + rvn._dsize() == rv._dsize()), "wrong rvn");
1359        //Permutation vector of the new R
1360        ivec irvn = rvn.dataind (rv);
1361        ivec irvc = rvc.dataind (rv);
1362        ivec perm = concat (irvn , irvc);
1363        sq_T Rn (R, perm);
1364
1365        //fixme - could this be done in general for all sq_T?
1366        mat S = Rn.to_mat();
1367        //fixme
1368        int n = rvn._dsize() - 1;
1369        int end = R.rows() - 1;
1370        mat S11 = S.get (0, n, 0, n);
1371        mat S12 = S.get (0, n , rvn._dsize(), end);
1372        mat S22 = S.get (rvn._dsize(), end, rvn._dsize(), end);
1373
1374        vec mu1 = mu (irvn);
1375        vec mu2 = mu (irvc);
1376        mat A = S12 * inv (S22);
1377        sq_T R_n (S11 - A *S12.T());
1378
1379        uptarget.set_rv (rvn);
1380        uptarget.set_rvc (rvc);
1381        uptarget.set_parameters (A, mu1 - A*mu2, R_n);
1382}
1383
1384////
1385///////
1386template<class sq_T>
1387void mgnorm<sq_T >::set_parameters (const shared_ptr<fnc> &g0, const sq_T &R0) {
1388        g = g0;
1389        this->iepdf.set_parameters (zeros (g->dimension()), R0);
1390}
1391
1392template<class sq_T>
1393void mgnorm<sq_T >::condition (const vec &cond) {this->iepdf._mu() = g->eval (cond);};
1394
1395//! \todo unify this stuff with to_string()
1396template<class sq_T>
1397std::ostream &operator<< (std::ostream &os,  mlnorm<sq_T> &ml)
1398{
1399        os << "A:" << ml.A << endl;
1400        os << "mu:" << ml.mu_const << endl;
1401        os << "R:" << ml._R() << endl;
1402        return os;
1403};
1404
1405}
1406#endif //EF_H
Note: See TracBrowser for help on using the browser.