about summary refs log tree commit diff
path: root/sourcecodes/bnt-master/KPMtools/max_mult.c
diff options
context:
space:
mode:
authorziejd22017-09-28 15:04:40 -0500
committerziejd22017-09-28 15:04:40 -0500
commit8070dc963753142bb86c4ed698d91fd623ed28e7 (patch)
treed0f6dd8fc46a49b819aa55c1a90faa14d8448883 /sourcecodes/bnt-master/KPMtools/max_mult.c
parent7cc31810d53176e805532b2789955f4eedbce6bb (diff)
downloadBNW-8070dc963753142bb86c4ed698d91fd623ed28e7.tar.gz
BNW using Octave instead of Matlab.
This version of BNW should perform the same as the original version. The only difference is that it uses Octave instead of Matlab when running BayesNet Toolbox during parameter learning.

I am calling this BNW_1.02. It can be accessed at:
compbio.uthsc.edu/BNW_1.02
Diffstat (limited to 'sourcecodes/bnt-master/KPMtools/max_mult.c')
-rw-r--r--sourcecodes/bnt-master/KPMtools/max_mult.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/sourcecodes/bnt-master/KPMtools/max_mult.c b/sourcecodes/bnt-master/KPMtools/max_mult.c
new file mode 100644
index 00000000..204fd956
--- /dev/null
+++ b/sourcecodes/bnt-master/KPMtools/max_mult.c
@@ -0,0 +1,46 @@
+/* C mex version of max_mult.m in BPMRF2 directory  */
+/* gcc -Wall -I/mit/matlab_v6.5/distrib/bin/glnx86 -c max_mult.c */
+
+#include <math.h>
+#include "mex.h"
+
+void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
+{
+  int rows,cols,common,m,n,p;
+  double y1, y2;
+  double *arr1, *arr2, *arr3;
+
+
+  if (nrhs!=2 || nlhs>1)
+    mexErrMsgTxt("max_mult requires two inputs and one output");
+  if (mxIsChar(prhs[0]) || mxIsClass(prhs[0], "sparse") || mxIsComplex(prhs[0])
+      || mxIsChar(prhs[1]) || mxIsClass(prhs[1], "sparse") || mxIsComplex(prhs[1]))
+    mexErrMsgTxt("Inputs must be real, full, and nonstring");
+  if (mxGetN(prhs[0])!=mxGetM(prhs[1]))
+    mexErrMsgTxt("The number of columns of A must be the same as the number of rows of x");
+  
+
+  arr1=mxGetPr(prhs[0]);
+  arr2=mxGetPr(prhs[1]);
+  p=mxGetN(prhs[0]);
+  m=mxGetM(prhs[0]);
+  n=mxGetN(prhs[1]);
+  plhs[0]=mxCreateDoubleMatrix(m, n, mxREAL);
+  arr3=mxMalloc(m*n*sizeof(double));
+
+  for (rows=0; rows<m ; rows++)
+    for (cols=0; cols<n ; cols++)
+    {
+      y1=arr1[rows]*arr2[cols*p];  
+      for (common=1; common<p; common++)
+      {
+	y2=arr1[rows+common*m]*arr2[common+cols*p];
+        if (y2>y1)
+          y1=y2;
+      }
+      arr3[rows+cols*m]=y1;
+    }
+
+  mxSetPr(plhs[0], arr3);
+	 
+}