[mlpack-svn] r13947 - mlpack/trunk/src/mlpack/bindings/matlab/kernel_pca

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Wed Nov 28 18:09:33 EST 2012


Author: rcurtin
Date: 2012-11-28 18:09:33 -0500 (Wed, 28 Nov 2012)
New Revision: 13947

Modified:
   mlpack/trunk/src/mlpack/bindings/matlab/kernel_pca/kernel_pca.cpp
Log:
Tabs to spaces and correct includes.


Modified: mlpack/trunk/src/mlpack/bindings/matlab/kernel_pca/kernel_pca.cpp
===================================================================
--- mlpack/trunk/src/mlpack/bindings/matlab/kernel_pca/kernel_pca.cpp	2012-11-28 23:05:14 UTC (rev 13946)
+++ mlpack/trunk/src/mlpack/bindings/matlab/kernel_pca/kernel_pca.cpp	2012-11-28 23:09:33 UTC (rev 13947)
@@ -8,7 +8,7 @@
 #include <mlpack/core/kernels/polynomial_kernel.hpp>
 #include <mlpack/core/kernels/cosine_distance.hpp>
 
-#include "kernel_pca.hpp"
+#include <mlpack/methods/kernel_pca/kernel_pca.hpp>
 
 using namespace mlpack;
 using namespace mlpack::kpca;
@@ -20,56 +20,56 @@
                  int nrhs, const mxArray *prhs[])
 {
   // argument checks
-  if (nrhs != 8) 
+  if (nrhs != 8)
   {
     mexErrMsgTxt("Expecting eight arguments.");
   }
 
-  if (nlhs != 1) 
+  if (nlhs != 1)
   {
     mexErrMsgTxt("Output required.");
   }
 
   // Load input dataset.
-	if (mxDOUBLE_CLASS != mxGetClassID(prhs[0]))
-		mexErrMsgTxt("Input dataset must have type mxDOUBLE_CLASS.");
+  if (mxDOUBLE_CLASS != mxGetClassID(prhs[0]))
+    mexErrMsgTxt("Input dataset must have type mxDOUBLE_CLASS.");
 
   mat dataset(mxGetM(prhs[0]), mxGetN(prhs[0]));
-	double * values = mxGetPr(prhs[0]);
-	for (int i=0, num=mxGetNumberOfElements(prhs[0]); i<num; ++i)
-		dataset(i) = values[i];
-	
+  double * values = mxGetPr(prhs[0]);
+  for (int i=0, num=mxGetNumberOfElements(prhs[0]); i<num; ++i)
+    dataset(i) = values[i];
+
   // Get the new dimensionality, if it is necessary.
   size_t newDim = dataset.n_rows;
-	const int argNewDim = (int) mxGetScalar(prhs[2]);
+  const int argNewDim = (int) mxGetScalar(prhs[2]);
   if (argNewDim != 0)
   {
     newDim = argNewDim;
 
     if (newDim > dataset.n_rows)
     {
-			stringstream ss;
+      stringstream ss;
       ss << "New dimensionality (" << newDim
           << ") cannot be greater than existing dimensionality ("
           << dataset.n_rows << ")!";
-			mexErrMsgTxt(ss.str().c_str());
+      mexErrMsgTxt(ss.str().c_str());
     }
   }
 
   // Get the kernel type and make sure it is valid.
-	if (mxCHAR_CLASS != mxGetClassID(prhs[1]))
-	{
-		mexErrMsgTxt("Kernel input must have type mxCHAR_CLASS.");
-	}
-	int bufLength = mxGetNumberOfElements(prhs[1]) + 1;
-	char * buf;
-	buf = (char *) mxCalloc(bufLength, sizeof(char));
+  if (mxCHAR_CLASS != mxGetClassID(prhs[1]))
+  {
+    mexErrMsgTxt("Kernel input must have type mxCHAR_CLASS.");
+  }
+  int bufLength = mxGetNumberOfElements(prhs[1]) + 1;
+  char * buf;
+  buf = (char *) mxCalloc(bufLength, sizeof(char));
   mxGetString(prhs[1], buf, bufLength);
-	string kernelType(buf);
-	mxFree(buf);
+  string kernelType(buf);
+  mxFree(buf);
 
-	// scale parameter
-	const bool scaleData = (mxGetScalar(prhs[3]) == 1.0);
+  // scale parameter
+  const bool scaleData = (mxGetScalar(prhs[3]) == 1.0);
 
   if (kernelType == "linear")
   {
@@ -78,7 +78,7 @@
   }
   else if (kernelType == "gaussian")
   {
-		const double bandwidth = mxGetScalar(prhs[3]);
+    const double bandwidth = mxGetScalar(prhs[3]);
 
     GaussianKernel kernel(bandwidth);
     KernelPCA<GaussianKernel> kpca(kernel, scaleData);
@@ -86,8 +86,8 @@
   }
   else if (kernelType == "polynomial")
   {
-		const double degree = mxGetScalar(prhs[4]);
-		const double offset = mxGetScalar(prhs[5]);
+    const double degree = mxGetScalar(prhs[4]);
+    const double offset = mxGetScalar(prhs[5]);
 
     PolynomialKernel kernel(offset, degree);
     KernelPCA<PolynomialKernel> kpca(kernel, scaleData);
@@ -95,8 +95,8 @@
   }
   else if (kernelType == "hyptan")
   {
-	  const double scale = mxGetScalar(prhs[6]);
-		const double offset = mxGetScalar(prhs[5]);
+    const double scale = mxGetScalar(prhs[6]);
+    const double offset = mxGetScalar(prhs[5]);
 
     HyperbolicTangentKernel kernel(scale, offset);
     KernelPCA<HyperbolicTangentKernel> kpca(kernel, scaleData);
@@ -104,7 +104,7 @@
   }
   else if (kernelType == "laplacian")
   {
-		const double bandwidth = mxGetScalar(prhs[7]);
+    const double bandwidth = mxGetScalar(prhs[7]);
 
     LaplacianKernel kernel(bandwidth);
     KernelPCA<LaplacianKernel> kpca(kernel, scaleData);
@@ -118,19 +118,19 @@
   else
   {
     // Invalid kernel type.
-		stringstream ss;
+    stringstream ss;
     ss << "Invalid kernel type ('" << kernelType << "'); valid choices "
         << "are 'linear', 'gaussian', 'polynomial', 'hyptan', 'laplacian', and "
         << "'cosine'.";
-		mexErrMsgTxt(ss.str().c_str());
+    mexErrMsgTxt(ss.str().c_str());
   }
 
   // Now returning results to matlab
-	plhs[0] = mxCreateDoubleMatrix(dataset.n_rows, dataset.n_cols, mxREAL);
-	values = mxGetPr(plhs[0]);
-	for (int i = 0; i < dataset.n_rows * dataset.n_cols; ++i)
-	{
-		values[i] = dataset(i);
-	}
+  plhs[0] = mxCreateDoubleMatrix(dataset.n_rows, dataset.n_cols, mxREAL);
+  values = mxGetPr(plhs[0]);
+  for (int i = 0; i < dataset.n_rows * dataset.n_cols; ++i)
+  {
+    values[i] = dataset(i);
+  }
 
 }




More information about the mlpack-svn mailing list