Skip to content

Commit

Permalink
standardizing c/cpp comments and removing tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
pdollar committed Oct 27, 2014
1 parent 39c63c2 commit c5ee373
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 116 deletions.
4 changes: 2 additions & 2 deletions classify/private/fernsInds1.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**************************************************************************
/*******************************************************************************
* Piotr's Computer Vision Matlab Toolbox Version 2.50
* Copyright 2014 Piotr Dollar. [pdollar-at-gmail.com]
* Licensed under the Simplified BSD License [see external/bsd.txt]
**************************************************************************/
*******************************************************************************/
#include "mex.h"
#include <math.h>
typedef unsigned int uint;
Expand Down
66 changes: 33 additions & 33 deletions classify/private/meanShift1.c
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/**************************************************************************
/*******************************************************************************
* Piotr's Computer Vision Matlab Toolbox Version 2.50
* Copyright 2014 Piotr Dollar. [pdollar-at-gmail.com]
* Licensed under the Simplified BSD License [see external/bsd.txt]
**************************************************************************/
*******************************************************************************/
#include <math.h>
#include <string.h>
#include "mex.h"

/**************************************************************************
* Calculates mean of all the points in data that lie on a sphere of
* radius^2==radius2 centered on [1xp] vector x. data is [nxp]. mean
* contains [1xp] result and return is number of points used for calc.
*************************************************************************/
int meanVec( double *x, double *data, int p, int n, double radius2,
/*******************************************************************************
* Calculates mean of all the points in data that lie on a sphere of
* radius^2==radius2 centered on [1xp] vector x. data is [nxp]. mean
* contains [1xp] result and return is number of points used for calc.
*******************************************************************************/
int meanVec( double *x, double *data, int p, int n, double radius2,
double *mean ) {
int i, j; double dist; int cnt=0, m=0;
for( j=0; j<p; j++ ) mean[j]=0;
Expand All @@ -31,36 +31,36 @@ int meanVec( double *x, double *data, int p, int n, double radius2,
}

/* Squared euclidean distance between two vectors. */
double dist( double *A, double *B, int n ) {
double dist( double *A, double *B, int n ) {
double d=0.0; int i;
for(i=0; i<n; i++) d+=(A[i]-B[i]) * (A[i]-B[i]);
return d;
}

/**************************************************************************
* data - p x n column matrix of data points
* p - dimension of data points
* n - number of data points
* radius - radius of search windo
* rate - gradient descent proportionality factor
* maxIter - max allowed number of iterations
* blur - specifies algorithm mode
* labels - labels for each cluster
* means - output (final clusters)
*************************************************************************/
void meanShift( double data[], int p, int n, double radius, double rate,
/*******************************************************************************
* data - p x n column matrix of data points
* p - dimension of data points
* n - number of data points
* radius - radius of search windo
* rate - gradient descent proportionality factor
* maxIter - max allowed number of iterations
* blur - specifies algorithm mode
* labels - labels for each cluster
* means - output (final clusters)
*******************************************************************************/
void meanShift( double data[], int p, int n, double radius, double rate,
int maxIter, bool blur, double labels[], double *means ) {
double radius2; /* radius^2 */
int iter; /* number of iterations */
double *mean; /* mean vector */
int i, j, o, m; /* looping and temporary variables */
int delta = 1; /* indicator if change occurred between iterations */
int *deltas; /* indicator if change occurred between iterations per point */
double *meansCur; /* calculated means for current iter */
double *meansNxt; /* calculated means for next iter */
double *data1; /* If blur data1 points to meansCur else it points to data */
int *consolidated; /* Needed in the assignment of cluster labels */
int nLabels = 1; /* Needed in the assignment of cluster labels */
double radius2; /* radius^2 */
int iter; /* number of iterations */
double *mean; /* mean vector */
int i, j, o, m; /* looping and temporary variables */
int delta = 1; /* indicator if change occurred between iterations */
int *deltas; /* indicator if change occurred between iterations per point */
double *meansCur; /* calculated means for current iter */
double *meansNxt; /* calculated means for next iter */
double *data1; /* If blur data1 points to meansCur else it points to data */
int *consolidated; /* Needed in the assignment of cluster labels */
int nLabels = 1; /* Needed in the assignment of cluster labels */

/* initialization */
meansCur = (double*) malloc( sizeof(double)*p*n );
Expand Down Expand Up @@ -111,7 +111,7 @@ void meanShift( double data[], int p, int n, double radius, double rate,
}

/* see meanShift.m for usage info */
void mexFunction( int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[] ) {
void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) {
double radius, rate, *data, *labels, *means; int p, n, maxIter; bool blur;

/* Check inputs */
Expand Down
22 changes: 11 additions & 11 deletions images/private/assignToBins1.c
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/**************************************************************************
/*******************************************************************************
* Piotr's Computer Vision Matlab Toolbox Version 2.2
* Copyright 2014 Piotr Dollar. [pdollar-at-gmail.com]
* Licensed under the Simplified BSD License [see external/bsd.txt]
*************************************************************************/
*******************************************************************************/
#include "mex.h"

/**************************************************************************
* Return index of bin for x. The edges are determined by the (nBins+1)
* element vector edges. Returns an integer value k in [0,nBins-1]
* representing the bin x falls into, or k==nBins if x does not fall
* into any bin. if edges[k] <= x < edges[k+1], then x falls
* into bin k (k<nBins). Additionally, if x==edges[nBins], then x falls
* into bin k=nBins-1. Eventually, all values where k==nBins should be ingored.
* Adapted from \MATLAB6p5\toolbox\matlab\datafun\histc.c
*************************************************************************/
/*******************************************************************************
* Return index of bin for x. The edges are determined by the (nBins+1)
* element vector edges. Returns an integer value k in [0,nBins-1]
* representing the bin x falls into, or k==nBins if x does not fall
* into any bin. if edges[k] <= x < edges[k+1], then x falls
* into bin k (k<nBins). Additionally, if x==edges[nBins], then x falls
* into bin k=nBins-1. Eventually, all values where k==nBins should be ingored.
* Adapted from \MATLAB6p5\toolbox\matlab\datafun\histc.c
*******************************************************************************/
int findBin( double x, double *edges, int nBins ) {
int k = nBins; /* NOBIN */
int k0 = 0; int k1 = nBins;
Expand Down
38 changes: 19 additions & 19 deletions images/private/histc2c.c
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/**************************************************************************
/*******************************************************************************
* Piotr's Computer Vision Matlab Toolbox Version 2.2
* Copyright 2014 Piotr Dollar. [pdollar-at-gmail.com]
* Licensed under the Simplified BSD License [see external/bsd.txt]
**************************************************************************/
*******************************************************************************/
#include "mex.h"

/**************************************************************************
* Return index of bin for x. The edges are determined by the (nBins+1)
* element vector edges. Returns an integer value k in [0,nBins-1]
* representing the bin x falls into, or k==nBins if x does not fall
* into any bin. if edges[k] <= x < edges[k+1], then x falls
* into bin k (k<nBins). Additionally, if x==edges[nBins], then x falls
* into bin k=nBins-1. Eventually, all values where k==nBins should be ingored.
* Adapted from \MATLAB6p5\toolbox\matlab\datafun\histc.c
*************************************************************************/
/*******************************************************************************
* Return index of bin for x. The edges are determined by the (nBins+1)
* element vector edges. Returns an integer value k in [0,nBins-1]
* representing the bin x falls into, or k==nBins if x does not fall
* into any bin. if edges[k] <= x < edges[k+1], then x falls
* into bin k (k<nBins). Additionally, if x==edges[nBins], then x falls
* into bin k=nBins-1. Eventually, all values where k==nBins should be ingored.
* Adapted from \MATLAB6p5\toolbox\matlab\datafun\histc.c
*******************************************************************************/
int findBin( double x, double *edges, int nBins ) {
int k = nBins; /* NOBIN */
int k0 = 0; int k1 = nBins;
Expand All @@ -31,14 +31,14 @@ int findBin( double x, double *edges, int nBins ) {
return k;
}

/**************************************************************************
* Fast indexing into multidimensional arrays.
* Call sub2ind_init once and store the result (siz contains the nd sizes):
* subMul = sub2ind_init( siz, nd );
* Then, to index into an array A of size siz, given a subscript sub
* (where sub is an nd int array of subscripts), you can get the index using:
* sub2ind(ind,sub,subMul,nd)
*************************************************************************/
/*******************************************************************************
* Fast indexing into multidimensional arrays.
* Call sub2ind_init once and store the result (siz contains the nd sizes):
* subMul = sub2ind_init( siz, nd );
* Then, to index into an array A of size siz, given a subscript sub
* (where sub is an nd int array of subscripts), you can get the index using:
* sub2ind(ind,sub,subMul,nd)
*******************************************************************************/
#define sub2ind(ind, sub, subMul, nd) ind=sub[0]; for(k=1;k<nd;k++) ind+=sub[k]*subMul[k];
int *sub2ind_init( const int*siz, const int nd ) {
int i, *subMul;
Expand Down
22 changes: 11 additions & 11 deletions images/private/nlfiltersep_max.c
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/**************************************************************************
/*******************************************************************************
* Piotr's Computer Vision Matlab Toolbox Version 2.2
* Copyright 2014 Piotr Dollar. [pdollar-at-gmail.com]
* Licensed under the Simplified BSD License [see external/bsd.txt]
**************************************************************************/
*******************************************************************************/
#include "mex.h"

#define arraymax(A, m, s, e, i) m=A[s]; for(i=s+1; i<=e; i++) { m=((A[i])>(m)?(A[i]):(m)); };
int maxi( int x, int y ) { return (x > y) ? x : y; };
int mini( int x, int y ) { return (x < y) ? x : y; };
int maxi( int x, int y ) { return (x > y) ? x : y; };
int mini( int x, int y ) { return (x < y) ? x : y; };

/**************************************************************************
* Row non-linear seperable filter - max (see nlfiltersep.m)
* x = nlfiltersep_max( [ 1 9; 5 9; 0 0; 4 8; 7 3; 2 6], 1, 1 )
* y = [5 9; 5 9; 5 9; 7 8; 7 8; 7 6]; x-y
* B(i,j) is the max of A(i-r1:i+r2,j). It has the same dims as A.
* Border calculations are done separately for efficiency.
*************************************************************************/
/*******************************************************************************
* Row non-linear seperable filter - max (see nlfiltersep.m)
* x = nlfiltersep_max( [ 1 9; 5 9; 0 0; 4 8; 7 3; 2 6], 1, 1 )
* y = [5 9; 5 9; 5 9; 7 8; 7 8; 7 6]; x-y
* B(i,j) is the max of A(i-r1:i+r2,j). It has the same dims as A.
* Border calculations are done separately for efficiency.
*******************************************************************************/
void nlfiltersep_max( const double *A, double *B, int r1, int r2, int mRows, int nCols ) {
int i, row0, e, s, r, c; double m;
for( c=0; c<nCols; c++ ) {
Expand Down
26 changes: 13 additions & 13 deletions images/private/nlfiltersep_sum.c
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
/**************************************************************************
/*******************************************************************************
* Piotr's Computer Vision Matlab Toolbox Version 2.2
* Copyright 2014 Piotr Dollar. [pdollar-at-gmail.com]
* Licensed under the Simplified BSD License [see external/bsd.txt]
**************************************************************************/
*******************************************************************************/
#include "mex.h"

#define arraysum(A, m, s, e, i) m=0; for(i=s; i<=e; i++) { m+=A[i]; };
int maxi( int x, int y ) { return (x > y) ? x : y; };
int mini( int x, int y ) { return (x < y) ? x : y; };
int maxi( int x, int y ) { return (x > y) ? x : y; };
int mini( int x, int y ) { return (x < y) ? x : y; };

/**************************************************************************
* Row non-linear seperable filter - sum (see nlfiltersep.m)
* x = nlfiltersep_sum( [ 1 9; 5 9; 0 0; 4 8; 7 3; 2 6], 1, 1 )
* y = [6 18; 6 18; 9 17; 11 11; 13 17; 9 9]; x-y
* B(i,j) is the sum of A(i-r1:i+r2,j). It has the same dims as A.
* This can be implemented effiicently because:
* B[i] = B[i-1] + A[i+r2] - A[i-r1-1];
* Does not work for initial (r1+1) and final r2 values in each row.
*************************************************************************/
/*******************************************************************************
* Row non-linear seperable filter - sum (see nlfiltersep.m)
* x = nlfiltersep_sum( [ 1 9; 5 9; 0 0; 4 8; 7 3; 2 6], 1, 1 )
* y = [6 18; 6 18; 9 17; 11 11; 13 17; 9 9]; x-y
* B(i,j) is the sum of A(i-r1:i+r2,j). It has the same dims as A.
* This can be implemented effiicently because:
* B[i] = B[i-1] + A[i+r2] - A[i-r1-1];
* Does not work for initial (r1+1) and final r2 values in each row.
*******************************************************************************/
void nlfiltersep_sum( const double *A, double *B, int r1, int r2, int mRows, int nCols ) {
int i, row0, e, s, r, c; double m;
for( c=0; c<nCols; c++ ) {
Expand Down
28 changes: 14 additions & 14 deletions matlab/private/dijkstra1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
* Licensed under the Simplified BSD License [see external/bsd.txt]
*******************************************************************************/

/**************************************************************************
* Based on ISOMAP code which can be found at http:*isomap.stanford.edu/.
* See accompanying m file (dijkstra.m) for usage.
*************************************************************************/
/*******************************************************************************
* Based on ISOMAP code which can be found at http:*isomap.stanford.edu/.
* See accompanying m file (dijkstra.m) for usage.
*******************************************************************************/

/**************************************************************************
* Bug fix for certain versions of VC++ compiler when used in Matlab.
* http://www.mathworks.com/matlabcentral/newsreader/view_thread/281754
*************************************************************************/
/*******************************************************************************
* Bug fix for certain versions of VC++ compiler when used in Matlab.
* http://www.mathworks.com/matlabcentral/newsreader/view_thread/281754
*******************************************************************************/
#if (_MSC_VER >= 1600)
#define __STDC_UTF_16__
typedef unsigned short char16_t;
Expand All @@ -22,9 +22,9 @@ typedef unsigned short char16_t;
#include "fibheap.h"
#define DIJKSTRA_CPP

/**************************************************************************
* class HeapNode
*************************************************************************/
/*******************************************************************************
* class HeapNode
*******************************************************************************/
class HeapNode : public FibHeapNode {
double N;
long int IndexV;
Expand Down Expand Up @@ -70,9 +70,9 @@ int HeapNode::operator <(FibHeapNode& RHS) {
return N < ((HeapNode&) RHS).N ? 1 : 0;
};

/*************************************************************************
* main
*************************************************************************/
/*******************************************************************************
* main
*******************************************************************************/
void dijkstra1( long int n, long int s, double *D1, double *P1, double *Gpr, mwIndex *Gir, mwIndex *Gjc) {
int finished;
long int i, startInd, endInd, whichNeigh, nDone, closest;
Expand Down
26 changes: 13 additions & 13 deletions videos/private/ktHistcRgb_c.c
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
/**************************************************************************
/*******************************************************************************
* Piotr's Computer Vision Matlab Toolbox Version 2.2
* Copyright 2014 Piotr Dollar. [pdollar-at-gmail.com]
* Licensed under the Simplified BSD License [see external/bsd.txt]
**************************************************************************/
*******************************************************************************/
#include "mex.h"
typedef unsigned char uchar;

/**************************************************************************
* Construct 3-D RGB histogram of colors in B [n x 3].
* Efficient implementation possible for the following reasons:
* 1) We know that histogram is 3 dimensional.
* 2) All values in B are between [0,2^nBits)
* 3) Bins are restricted to powers of 2 (nBins=2^nBits)
* Finding the bin index is simply a matter of dividing/multiplying by
* powers of 2, which can be done efficiently with the left and right shift
* operators. See also histc2c.c in toolbox for more general histogramming
* implementation. This is about 5x faster. Note: nBins = 2^nBits = 1<<nBits
*************************************************************************/
/*******************************************************************************
* Construct 3-D RGB histogram of colors in B [n x 3].
* Efficient implementation possible for the following reasons:
* 1) We know that histogram is 3 dimensional.
* 2) All values in B are between [0,2^nBits)
* 3) Bins are restricted to powers of 2 (nBins=2^nBits)
* Finding the bin index is simply a matter of dividing/multiplying by
* powers of 2, which can be done efficiently with the left and right shift
* operators. See also histc2c.c in toolbox for more general histogramming
* implementation. This is about 5x faster. Note: nBins = 2^nBits = 1<<nBits
*******************************************************************************/
void ktHistcRgb( double* h, uchar* B, double* wtMask, int n, int nBits ) {
int i, indFlat, nBits2=nBits+nBits;
for( i=0; i<n; i++ ) {
Expand Down

0 comments on commit c5ee373

Please sign in to comment.