Index: /library/bdm/base/itpp/itmex.h
===================================================================
--- /library/bdm/base/itpp/itmex.h (revision 813)
+++ /library/bdm/base/itpp/itmex.h (revision 937)
@@ -336,8 +336,7 @@
   int i, size;
   double* temp = (double*) mxGetPr(in);
-  if (temp == 0) mexErrMsgTxt("mxArray2ivec: Pointer to data is NULL");
 
   size = mxGetNumberOfElements(in);
-  if (size == 0) mexErrMsgTxt("mxArray2ivec: Size of data is zero");
+  if ((size > 0) && (temp == 0)) mexErrMsgTxt("mxArray2ivec: Size of data is zero");
 
   out.set_size(size, false);
@@ -356,9 +355,8 @@
   int i, size;
   double* temp = (double*) mxGetPr(in);
-  if (temp == 0) mexErrMsgTxt("mxArray2vec: Pointer to data is NULL");
 
   size = mxGetNumberOfElements(in);
-  if (size == 0) mexErrMsgTxt("mxArray2vec: Size of data is zero");
-
+  if ((size >0) && (temp == 0)) mexErrMsgTxt("mxArray2vec: Pointer to data is NULL");
+  
   out.set_size(size, false);
 
@@ -577,6 +575,5 @@
 {
   double* temp = (double *) mxGetPr(out);
-  if (temp == 0) mexErrMsgTxt("vec2mxArray: Pointer to data is NULL");
-  if (in.size() == 0) mexErrMsgTxt("vec2mxArray: Size of data is zero");
+  if ((in.size() > 0) && (temp == 0)) mexErrMsgTxt("vec2mxArray: Pointer to data is NULL");
 
   for (int i = 0; i < in.size(); i++) {
Index: /applications/bdmtoolbox/mex/RV.m
===================================================================
--- /applications/bdmtoolbox/mex/RV.m (revision 706)
+++ /applications/bdmtoolbox/mex/RV.m (revision 937)
@@ -2,4 +2,7 @@
 % create RV from cell of names, vector of sizes and vector of time delayes
 
+if nargin<1
+    names='';
+end
 r.class='RV';
 if isstr(names)
Index: /applications/bdmtoolbox/mex/epdf_sample_mat.cpp
===================================================================
--- /applications/bdmtoolbox/mex/epdf_sample_mat.cpp (revision 801)
+++ /applications/bdmtoolbox/mex/epdf_sample_mat.cpp (revision 937)
@@ -12,4 +12,5 @@
 #ifdef MEX
 #include <mex/mex_parser.h>
+#include "mexPdf.h"
 
 void mexFunction ( int n_output, mxArray *output[], int n_input, const mxArray *input[] ) {
Index: /applications/bdmtoolbox/mex/mex_classes/mexBM.m
===================================================================
--- /applications/bdmtoolbox/mex/mex_classes/mexBM.m (revision 937)
+++ /applications/bdmtoolbox/mex/mex_classes/mexBM.m (revision 937)
@@ -0,0 +1,25 @@
+classdef mexBM
+    properties
+      % from wikipedia
+      rv
+      rvc
+      rvy
+    end
+    methods
+        function validate(p)
+            if size(p.mu)<1 & (size(p.b)<1)
+                error('incompatible mu and b');
+            end
+        end
+        function dims=dimensions(p)
+            %please fill
+            [size_of_posterior size_of_data size_of_condition]
+        end
+        function obj=bayes(obj,dt,cond)
+            % transform old estimate into new estimate
+        end
+        function p=posterior(obj)
+            % return posterior density
+        end
+    end
+end
Index: /applications/bdmtoolbox/mex/mex_classes/mexEpdf.m
===================================================================
--- /applications/bdmtoolbox/mex/mex_classes/mexEpdf.m (revision 937)
+++ /applications/bdmtoolbox/mex/mex_classes/mexEpdf.m (revision 937)
@@ -0,0 +1,28 @@
+classdef mexEpdf
+    properties
+	    rv = RV; %empty description add some valid RV when needed
+    end
+    methods
+        function m=mean(p)
+            error('define how to compute mean')
+        end
+        function validate(p)
+            error('check if the density is consistent')
+        end
+        function dim=dimension(p)
+            error('return dimension of the density')
+        end
+        function v=variance(p)
+            error('define how to compute mean')
+        end
+        function l=evallog(p,x)
+            error('define how to evaluate log of this density at point x')
+        end
+        function l=evallog_nn(p,x)
+            % define how to evaluate non-normalized log of this density at point x
+            % makes sense if faster than normalized
+            evallog(p,x);
+        end
+
+    end
+end
Index: /applications/bdmtoolbox/mex/mex_classes/mexLaplace.m
===================================================================
--- /applications/bdmtoolbox/mex/mex_classes/mexLaplace.m (revision 937)
+++ /applications/bdmtoolbox/mex/mex_classes/mexLaplace.m (revision 937)
@@ -0,0 +1,31 @@
+classdef mexLaplace < mexEpdf
+    properties
+      % from wikipedia
+    	mu
+    	b
+    end
+    methods
+        function m=mean(p)
+            m = p.mu;
+        end
+        function validate(p)
+            if size(p.mu)<1 & (size(p.b)<1)
+                error('incompatible mu and b');
+            end
+        end
+        function dim=dimension(p)
+            dim = size(p.mu,1);
+        end
+        function v=variance(p)
+            v=2*p.b^2;
+        end
+        function l=evallog(p,x)
+            l=-log(2*p.b)-abs(x-p.mu)/p.b;
+        end
+        function s=sample(p);
+            v=-log(rand);%sample_exponential(0,1);
+            z = randn;
+            s = p.mu+p.b*sqrt(2*v)*z;
+        end
+    end
+end
Index: /applications/bdmtoolbox/mex/mexPdf.h
===================================================================
--- /applications/bdmtoolbox/mex/mexPdf.h (revision 936)
+++ /applications/bdmtoolbox/mex/mexPdf.h (revision 937)
@@ -9,6 +9,8 @@
 		} 
 		void validate() {
-			mexCallMATLAB(1, &data, 0, 0, "validate");
-			dim = mexCallMATLAB(1, &data, 0, 0, "dimension");
+			mexCallMATLAB(0, 0, 1, &data,  "validate");
+			mxArray *tmp;
+			mexCallMATLAB(1, &tmp, 1, &data, "dimension");
+			dim = mxArray2double(tmp);
 		}
 		vec mean() const {
@@ -24,5 +26,9 @@
 		double evallog(const vec &dt) const {
 			mxArray *tmp;
-			mexCallMATLAB(1, &tmp, 1, (mxArray **) &data, "evallog");
+			mxArray *in[2];
+			in[0]=data;
+			in[1]=mxCreateDoubleMatrix(dimension(),1,mxREAL);
+			vec2mxArray(dt,in[1]);
+			mexCallMATLAB(1, &tmp, 2, in, "evallog");
 			return mxArray2double(tmp);
 		}
@@ -34,2 +40,3 @@
 };
 UIREGISTER(mexEpdf);
+
Index: /applications/bdmtoolbox/mex/epdf_marginal.cpp
===================================================================
--- /applications/bdmtoolbox/mex/epdf_marginal.cpp (revision 803)
+++ /applications/bdmtoolbox/mex/epdf_marginal.cpp (revision 937)
@@ -12,4 +12,5 @@
 #ifdef MEX
 #include <mex/mex_parser.h>
+#include "mexPdf.h"
 
 void mexFunction ( int n_output, mxArray *output[], int n_input, const mxArray *input[] ) {
Index: /applications/bdmtoolbox/mex/epdf_evallog_mat.cpp
===================================================================
--- /applications/bdmtoolbox/mex/epdf_evallog_mat.cpp (revision 803)
+++ /applications/bdmtoolbox/mex/epdf_evallog_mat.cpp (revision 937)
@@ -12,4 +12,5 @@
 #ifdef MEX
 #include <mex/mex_parser.h>
+#include "mexPdf.h"
 
 void mexFunction ( int n_output, mxArray *output[], int n_input, const mxArray *input[] ) {
Index: /applications/bdmtoolbox/mex/epdf_covariance.cpp
===================================================================
--- /applications/bdmtoolbox/mex/epdf_covariance.cpp (revision 803)
+++ /applications/bdmtoolbox/mex/epdf_covariance.cpp (revision 937)
@@ -12,4 +12,5 @@
 #ifdef MEX
 #include <mex/mex_parser.h>
+#include "mexPdf.h"
 
 void mexFunction ( int n_output, mxArray *output[], int n_input, const mxArray *input[] ) {
Index: /applications/bdmtoolbox/mex/epdf_variance.cpp
===================================================================
--- /applications/bdmtoolbox/mex/epdf_variance.cpp (revision 801)
+++ /applications/bdmtoolbox/mex/epdf_variance.cpp (revision 937)
@@ -12,4 +12,5 @@
 #ifdef MEX
 #include <mex/mex_parser.h>
+#include "mexPdf.h"
 
 void mexFunction ( int n_output, mxArray *output[], int n_input, const mxArray *input[] ) {
