[mlpack-svn] r13950 - mlpack/trunk/src/mlpack/bindings/matlab/nmf
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Wed Nov 28 18:11:24 EST 2012
Author: rcurtin
Date: 2012-11-28 18:11:24 -0500 (Wed, 28 Nov 2012)
New Revision: 13950
Removed:
mlpack/trunk/src/mlpack/bindings/matlab/nmf/Makefile
Modified:
mlpack/trunk/src/mlpack/bindings/matlab/nmf/nmf.cpp
Log:
Tabs to spaces, fix includes, remove unnecessary Makefile.
Deleted: mlpack/trunk/src/mlpack/bindings/matlab/nmf/Makefile
===================================================================
--- mlpack/trunk/src/mlpack/bindings/matlab/nmf/Makefile 2012-11-28 23:10:05 UTC (rev 13949)
+++ mlpack/trunk/src/mlpack/bindings/matlab/nmf/Makefile 2012-11-28 23:11:24 UTC (rev 13950)
@@ -1,22 +0,0 @@
-nmf: nmf.o
- g++ -O -pthread -shared \
--Wl,--version-script,/opt/matlab/2010b/extern/lib/glnxa64/mexFunction.map \
--Wl,--no-undefined -o 'mex_nmf.mexa64' nmf.o \
--L../../build/lib -lmlpack \
--Wl,-rpath-link,/opt/matlab/2010b/bin/glnxa64 \
--L/opt/matlab/2010b/bin/glnxa64 -lmx -lmex -lmat -lm -lmwlapack \
--Wl,-rpath=/net/hu19/pmason8/mlpack/trunk/build/lib \
--L/usr/lib64 -larmadillo \
-
-nmf.o:
- g++ -c \
--I../../build/include \
--I../../build/include/mlpack/methods/nmf \
--I/usr/include/libxml2 \
--I/opt/matlab/2010b/extern/include \
--DMATLAB_MEX_FILE \
--ansi -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread \
--DMX_COMPAT_32 -O -DNDEBUG 'nmf.cpp'
-
-clean:
- rm -f *.o *.mexa64
Modified: mlpack/trunk/src/mlpack/bindings/matlab/nmf/nmf.cpp
===================================================================
--- mlpack/trunk/src/mlpack/bindings/matlab/nmf/nmf.cpp 2012-11-28 23:10:05 UTC (rev 13949)
+++ mlpack/trunk/src/mlpack/bindings/matlab/nmf/nmf.cpp 2012-11-28 23:11:24 UTC (rev 13950)
@@ -2,12 +2,12 @@
#include <mlpack/core.hpp>
-#include "nmf.hpp"
+#include <mlpack/methods/nmf/nmf.hpp>
-#include "random_init.hpp"
-#include "mult_dist_update_rules.hpp"
-#include "mult_div_update_rules.hpp"
-#include "als_update_rules.hpp"
+#include <mlpack/methods/nmf/random_init.hpp>
+#include <mlpack/methods/nmf/mult_dist_update_rules.hpp>
+#include <mlpack/methods/nmf/mult_div_update_rules.hpp>
+#include <mlpack/methods/nmf/als_update_rules.hpp>
using namespace mlpack;
using namespace mlpack::nmf;
@@ -17,17 +17,17 @@
int nrhs, const mxArray *prhs[])
{
// argument checks
- if (nrhs != 6)
+ if (nrhs != 6)
{
mexErrMsgTxt("Expecting six inputs.");
}
- if (nlhs != 2)
+ if (nlhs != 2)
{
mexErrMsgTxt("Two outputs required.");
}
- const size_t seed = (size_t) mxGetScalar(prhs[5]);
+ const size_t seed = (size_t) mxGetScalar(prhs[5]);
// Initialize random seed.
if (seed != 0)
@@ -36,16 +36,16 @@
math::RandomSeed((size_t) std::time(NULL));
// Gather parameters.
- const size_t r = (size_t) mxGetScalar(prhs[1]);
- const size_t maxIterations = (size_t) mxGetScalar(prhs[2]);
- const double minResidue = mxGetScalar(prhs[3]);
+ const size_t r = (size_t) mxGetScalar(prhs[1]);
+ const size_t maxIterations = (size_t) mxGetScalar(prhs[2]);
+ const double minResidue = mxGetScalar(prhs[3]);
- // update rule
- int bufLength = mxGetNumberOfElements(prhs[4]) + 1;
- char * buf = (char *) mxCalloc(bufLength, sizeof(char));
+ // update rule
+ int bufLength = mxGetNumberOfElements(prhs[4]) + 1;
+ char * buf = (char *) mxCalloc(bufLength, sizeof(char));
mxGetString(prhs[4], buf, bufLength);
- string updateRules(buf);
- mxFree(buf);
+ string updateRules(buf);
+ mxFree(buf);
// Validate rank.
if (r < 1)
@@ -57,17 +57,17 @@
(updateRules != "multdiv") &&
(updateRules != "als"))
{
- stringstream ss;
- ss << "Invalid update rules ('" << updateRules << "'); must be '"
+ stringstream ss;
+ ss << "Invalid update rules ('" << updateRules << "'); must be '"
<< "multdist', 'multdiv', or 'als'.";
- mexErrMsgTxt(ss.str().c_str());
+ mexErrMsgTxt(ss.str().c_str());
}
// Load input dataset.
arma::mat V(mxGetM(prhs[0]), mxGetN(prhs[0]));
- double * values = mxGetPr(prhs[0]);
- for (int i=0, num=mxGetNumberOfElements(prhs[0]); i<num; ++i)
- V(i) = values[i];
+ double * values = mxGetPr(prhs[0]);
+ for (int i=0, num=mxGetNumberOfElements(prhs[0]); i<num; ++i)
+ V(i) = values[i];
arma::mat W;
arma::mat H;
@@ -93,14 +93,14 @@
nmf.Apply(V, r, W, H);
}
- // return to matlab
- plhs[0] = mxCreateDoubleMatrix(W.n_rows, W.n_cols, mxREAL);
- values = mxGetPr(plhs[0]);
- for (int i = 0; i < W.n_elem; ++i)
- values[i] = W(i);
+ // return to matlab
+ plhs[0] = mxCreateDoubleMatrix(W.n_rows, W.n_cols, mxREAL);
+ values = mxGetPr(plhs[0]);
+ for (int i = 0; i < W.n_elem; ++i)
+ values[i] = W(i);
- plhs[1] = mxCreateDoubleMatrix(H.n_rows, H.n_cols, mxREAL);
- values = mxGetPr(plhs[0]);
- for (int i = 0; i < H.n_elem; ++i)
- values[i] = H(i);
+ plhs[1] = mxCreateDoubleMatrix(H.n_rows, H.n_cols, mxREAL);
+ values = mxGetPr(plhs[0]);
+ for (int i = 0; i < H.n_elem; ++i)
+ values[i] = H(i);
}
More information about the mlpack-svn
mailing list