From bb8c6e3d454cbb46c0aa1689c5770c8176dd7432 Mon Sep 17 00:00:00 2001 From: Kevin Date: Mon, 13 Mar 2017 15:22:41 +0800 Subject: [PATCH] remove trailing spaces and tabs --- Makefile.win | 2 +- blas/Makefile | 8 ++++---- blas/blasp.h | 16 ++++++++-------- blas/daxpy.c | 6 +++--- blas/ddot.c | 6 +++--- blas/dnrm2.c | 14 +++++++------- blas/dscal.c | 8 ++++---- linear.cpp | 4 ++-- linear.h | 2 +- matlab/Makefile | 2 +- matlab/libsvmread.c | 6 +++--- matlab/libsvmwrite.c | 16 ++++++++-------- matlab/train.c | 36 ++++++++++++++++++------------------ python/README | 16 ++++++++-------- python/liblinear.py | 40 ++++++++++++++++++++-------------------- python/liblinearutil.py | 4 ++-- 16 files changed, 93 insertions(+), 93 deletions(-) diff --git a/Makefile.win b/Makefile.win index 9b3b8c6..f5d91a6 100644 --- a/Makefile.win +++ b/Makefile.win @@ -17,7 +17,7 @@ tron.obj: tron.cpp tron.h $(CXX) $(CFLAGS) -c tron.cpp lib: linear.cpp linear.h linear.def tron.obj - $(CXX) $(CFLAGS) -LD linear.cpp tron.obj blas\*.c -Fe$(TARGET)\liblinear -link -DEF:linear.def + $(CXX) $(CFLAGS) -LD linear.cpp tron.obj blas\*.c -Fe$(TARGET)\liblinear -link -DEF:linear.def clean: -erase /Q *.obj $(TARGET)\*.exe $(TARGET)\*.dll $(TARGET)\*.exp $(TARGET)\*.lib diff --git a/blas/Makefile b/blas/Makefile index 895fd24..ff42789 100644 --- a/blas/Makefile +++ b/blas/Makefile @@ -1,14 +1,14 @@ AR = ar rcv -RANLIB = ranlib +RANLIB = ranlib HEADERS = blas.h blasp.h -FILES = dnrm2.o daxpy.o ddot.o dscal.o +FILES = dnrm2.o daxpy.o ddot.o dscal.o -CFLAGS = $(OPTFLAGS) +CFLAGS = $(OPTFLAGS) FFLAGS = $(OPTFLAGS) blas: $(FILES) $(HEADERS) - $(AR) blas.a $(FILES) + $(AR) blas.a $(FILES) $(RANLIB) blas.a clean: diff --git a/blas/blasp.h b/blas/blasp.h index fbf6e7f..d0fe8ec 100644 --- a/blas/blasp.h +++ b/blas/blasp.h @@ -170,7 +170,7 @@ int dgemm_(char *transa, char *transb, int *m, int *n, int *k, double *beta, double *c, int *ldc); int dgemv_(char *trans, int *m, int *n, double *alpha, double *a, - int *lda, double *x, int *incx, double *beta, double *y, + int *lda, double *x, int *incx, double *beta, double *y, int *incy); int dger_(int *m, int *n, double *alpha, double *x, int *incx, @@ -182,7 +182,7 @@ int drot_(int *n, double *sx, int *incx, double *sy, int *incy, int drotg_(double *sa, double *sb, double *c, double *s); int dsbmv_(char *uplo, int *n, int *k, double *alpha, double *a, - int *lda, double *x, int *incx, double *beta, double *y, + int *lda, double *x, int *incx, double *beta, double *y, int *incy); int dscal_(int *n, double *sa, double *sx, int *incx); @@ -231,14 +231,14 @@ int dtpsv_(char *uplo, char *trans, char *diag, int *n, double *ap, double *x, int *incx); int dtrmm_(char *side, char *uplo, char *transa, char *diag, int *m, - int *n, double *alpha, double *a, int *lda, double *b, + int *n, double *alpha, double *a, int *lda, double *b, int *ldb); int dtrmv_(char *uplo, char *trans, char *diag, int *n, double *a, int *lda, double *x, int *incx); int dtrsm_(char *side, char *uplo, char *transa, char *diag, int *m, - int *n, double *alpha, double *a, int *lda, double *b, + int *n, double *alpha, double *a, int *lda, double *b, int *ldb); int dtrsv_(char *uplo, char *trans, char *diag, int *n, double *a, @@ -258,7 +258,7 @@ int sgemm_(char *transa, char *transb, int *m, int *n, int *k, float *beta, float *c, int *ldc); int sgemv_(char *trans, int *m, int *n, float *alpha, float *a, - int *lda, float *x, int *incx, float *beta, float *y, + int *lda, float *x, int *incx, float *beta, float *y, int *incy); int sger_(int *m, int *n, float *alpha, float *x, int *incx, @@ -270,7 +270,7 @@ int srot_(int *n, float *sx, int *incx, float *sy, int *incy, int srotg_(float *sa, float *sb, float *c, float *s); int ssbmv_(char *uplo, int *n, int *k, float *alpha, float *a, - int *lda, float *x, int *incx, float *beta, float *y, + int *lda, float *x, int *incx, float *beta, float *y, int *incy); int sscal_(int *n, float *sa, float *sx, int *incx); @@ -319,14 +319,14 @@ int stpsv_(char *uplo, char *trans, char *diag, int *n, float *ap, float *x, int *incx); int strmm_(char *side, char *uplo, char *transa, char *diag, int *m, - int *n, float *alpha, float *a, int *lda, float *b, + int *n, float *alpha, float *a, int *lda, float *b, int *ldb); int strmv_(char *uplo, char *trans, char *diag, int *n, float *a, int *lda, float *x, int *incx); int strsm_(char *side, char *uplo, char *transa, char *diag, int *m, - int *n, float *alpha, float *a, int *lda, float *b, + int *n, float *alpha, float *a, int *lda, float *b, int *ldb); int strsv_(char *uplo, char *trans, char *diag, int *n, float *a, diff --git a/blas/daxpy.c b/blas/daxpy.c index f762bd5..0a3c594 100644 --- a/blas/daxpy.c +++ b/blas/daxpy.c @@ -10,9 +10,9 @@ int daxpy_(int *n, double *sa, double *sx, int *incx, double *sy, long int i, m, ix, iy, nn, iincx, iincy; register double ssa; - /* constant times a vector plus a vector. - uses unrolled loop for increments equal to one. - jack dongarra, linpack, 3/11/78. + /* constant times a vector plus a vector. + uses unrolled loop for increments equal to one. + jack dongarra, linpack, 3/11/78. modified 12/3/93, array(1) declarations changed to array(*) */ /* Dereference inputs */ diff --git a/blas/ddot.c b/blas/ddot.c index adc0965..294f4ed 100644 --- a/blas/ddot.c +++ b/blas/ddot.c @@ -10,9 +10,9 @@ double ddot_(int *n, double *sx, int *incx, double *sy, int *incy) double stemp; long int ix, iy; - /* forms the dot product of two vectors. - uses unrolled loops for increments equal to one. - jack dongarra, linpack, 3/11/78. + /* forms the dot product of two vectors. + uses unrolled loops for increments equal to one. + jack dongarra, linpack, 3/11/78. modified 12/3/93, array(1) declarations changed to array(*) */ /* Dereference inputs */ diff --git a/blas/dnrm2.c b/blas/dnrm2.c index 7898783..d80b1a5 100644 --- a/blas/dnrm2.c +++ b/blas/dnrm2.c @@ -10,13 +10,13 @@ double dnrm2_(int *n, double *x, int *incx) long int ix, nn, iincx; double norm, scale, absxi, ssq, temp; -/* DNRM2 returns the euclidean norm of a vector via the function - name, so that +/* DNRM2 returns the euclidean norm of a vector via the function + name, so that - DNRM2 := sqrt( x'*x ) + DNRM2 := sqrt( x'*x ) - -- This version written on 25-October-1982. - Modified on 14-October-1993 to inline the call to SLASSQ. + -- This version written on 25-October-1982. + Modified on 14-October-1993 to inline the call to SLASSQ. Sven Hammarling, Nag Ltd. */ /* Dereference inputs */ @@ -28,13 +28,13 @@ double dnrm2_(int *n, double *x, int *incx) if (nn == 1) { norm = fabs(x[0]); - } + } else { scale = 0.0; ssq = 1.0; - /* The following loop is equivalent to this call to the LAPACK + /* The following loop is equivalent to this call to the LAPACK auxiliary routine: CALL SLASSQ( N, X, INCX, SCALE, SSQ ) */ for (ix=(nn-1)*iincx; ix>=0; ix-=iincx) diff --git a/blas/dscal.c b/blas/dscal.c index 2bbdebc..5edbe8b 100644 --- a/blas/dscal.c +++ b/blas/dscal.c @@ -9,10 +9,10 @@ int dscal_(int *n, double *sa, double *sx, int *incx) long int i, m, nincx, nn, iincx; double ssa; - /* scales a vector by a constant. - uses unrolled loops for increment equal to 1. - jack dongarra, linpack, 3/11/78. - modified 3/93 to return if incx .le. 0. + /* scales a vector by a constant. + uses unrolled loops for increment equal to 1. + jack dongarra, linpack, 3/11/78. + modified 3/93 to return if incx .le. 0. modified 12/3/93, array(1) declarations changed to array(*) */ /* Dereference inputs */ diff --git a/linear.cpp b/linear.cpp index e1d12e3..5136261 100644 --- a/linear.cpp +++ b/linear.cpp @@ -1187,7 +1187,7 @@ void solve_l2r_lr_dual(const problem *prob, double *w, double eps, double Cp, do int i, s, iter = 0; double *xTx = new double[l]; int max_iter = 1000; - int *index = new int[l]; + int *index = new int[l]; double *alpha = new double[2*l]; // store alpha and C - alpha schar *y = new schar[l]; int max_inner_iter = 100; // for inner Newton @@ -1206,7 +1206,7 @@ void solve_l2r_lr_dual(const problem *prob, double *w, double eps, double Cp, do y[i] = -1; } } - + // Initial alpha can be set here. Note that // 0 < alpha[i] < upper_bound[GETI(i)] // alpha[2*i] + alpha[2*i+1] = upper_bound[GETI(i)] diff --git a/linear.h b/linear.h index bc6aaf8..b6086da 100644 --- a/linear.h +++ b/linear.h @@ -16,7 +16,7 @@ struct problem int l, n; double *y; struct feature_node **x; - double bias; /* < 0 if no bias term */ + double bias; /* < 0 if no bias term */ }; enum { L2R_LR, L2R_L2LOSS_SVC_DUAL, L2R_L2LOSS_SVC, L2R_L1LOSS_SVC_DUAL, MCSVM_CS, L1R_L2LOSS_SVC, L1R_LR, L2R_LR_DUAL, L2R_L2LOSS_SVR = 11, L2R_L2LOSS_SVR_DUAL, L2R_L1LOSS_SVR_DUAL }; /* solver_type */ diff --git a/matlab/Makefile b/matlab/Makefile index a2c0284..8826a40 100644 --- a/matlab/Makefile +++ b/matlab/Makefile @@ -38,7 +38,7 @@ linear_model_matlab.o: linear_model_matlab.c ../linear.h ../linear.o: ../linear.cpp ../linear.h make -C .. linear.o -../tron.o: ../tron.cpp ../tron.h +../tron.o: ../tron.cpp ../tron.h make -C .. tron.o ../blas/blas.a: ../blas/*.c ../blas/*.h diff --git a/matlab/libsvmread.c b/matlab/libsvmread.c index d2fe0f5..21291df 100644 --- a/matlab/libsvmread.c +++ b/matlab/libsvmread.c @@ -9,8 +9,8 @@ #ifdef MX_API_VER #if MX_API_VER < 0x07030000 typedef int mwIndex; -#endif -#endif +#endif +#endif #ifndef max #define max(x,y) (((x)>(y))?(x):(y)) #endif @@ -38,7 +38,7 @@ static int max_line_len; static char* readline(FILE *input) { int len; - + if(fgets(line,max_line_len,input) == NULL) return NULL; diff --git a/matlab/libsvmwrite.c b/matlab/libsvmwrite.c index 9c93fd3..3c59178 100644 --- a/matlab/libsvmwrite.c +++ b/matlab/libsvmwrite.c @@ -33,7 +33,7 @@ void libsvmwrite(const char *filename, const mxArray *label_vec, const mxArray * if(fp ==NULL) { - mexPrintf("can't open output file %s\n",filename); + mexPrintf("can't open output file %s\n",filename); return; } @@ -72,7 +72,7 @@ void libsvmwrite(const char *filename, const mxArray *label_vec, const mxArray * low = jc[i], high = jc[i+1]; for(k=low;k>> print(node) + >>> print(node) - Function: gen_feature_nodearray(xi [,feature_max=None [,issparse=True]]) @@ -149,7 +149,7 @@ LIBLINEAR shared library: x: a Python list/tuple of l data instances. Each element of x must be an instance of list/tuple/dictionary type. - bias: if bias >= 0, instance x becomes [x; bias]; if < 0, no bias term + bias: if bias >= 0, instance x becomes [x; bias]; if < 0, no bias term added (default -1) You can also modify the bias value by @@ -277,9 +277,9 @@ The above command loads structure. If '-v' is specified, cross validation is conducted and the returned model is just a scalar: cross-validation accuracy for classification and mean-squared error for regression. - If the '-C' option is specified, the best parameter C is found - by cross validation. The returned model is a tuple of the best C - and the corresponding cross-validation accuracy. The parameter + If the '-C' option is specified, the best parameter C is found + by cross validation. The returned model is a tuple of the best C + and the corresponding cross-validation accuracy. The parameter selection utility is supported by only -s 0 and -s 2. @@ -322,11 +322,11 @@ The above command loads squared error, and squared correlation coefficient (for regression). - p_vals: a list of decision values or probability estimates (if '-b 1' + p_vals: a list of decision values or probability estimates (if '-b 1' is specified). If k is the number of classes, for decision values, each element includes results of predicting k binary-class - SVMs. If k = 2 and solver is not MCSVM_CS, only one decision value - is returned. For probabilities, each element contains k values + SVMs. If k = 2 and solver is not MCSVM_CS, only one decision value + is returned. For probabilities, each element contains k values indicating the probability that the testing instance is in each class. Note that the order of classes here is the same as 'model.label' field in the model structure. diff --git a/python/liblinear.py b/python/liblinear.py index d650062..e5dbf44 100644 --- a/python/liblinear.py +++ b/python/liblinear.py @@ -7,8 +7,8 @@ import sys __all__ = ['liblinear', 'feature_node', 'gen_feature_nodearray', 'problem', 'parameter', 'model', 'toPyModel', 'L2R_LR', 'L2R_L2LOSS_SVC_DUAL', - 'L2R_L2LOSS_SVC', 'L2R_L1LOSS_SVC_DUAL', 'MCSVM_CS', - 'L1R_L2LOSS_SVC', 'L1R_LR', 'L2R_LR_DUAL', 'L2R_L2LOSS_SVR', + 'L2R_L2LOSS_SVC', 'L2R_L1LOSS_SVC_DUAL', 'MCSVM_CS', + 'L1R_L2LOSS_SVC', 'L1R_LR', 'L2R_LR_DUAL', 'L2R_L2LOSS_SVR', 'L2R_L2LOSS_SVR_DUAL', 'L2R_L1LOSS_SVR_DUAL', 'print_null'] try: @@ -27,25 +27,25 @@ except: raise Exception('LIBLINEAR library not found.') L2R_LR = 0 -L2R_L2LOSS_SVC_DUAL = 1 -L2R_L2LOSS_SVC = 2 +L2R_L2LOSS_SVC_DUAL = 1 +L2R_L2LOSS_SVC = 2 L2R_L1LOSS_SVC_DUAL = 3 -MCSVM_CS = 4 -L1R_L2LOSS_SVC = 5 -L1R_LR = 6 -L2R_LR_DUAL = 7 +MCSVM_CS = 4 +L1R_L2LOSS_SVC = 5 +L1R_LR = 6 +L2R_LR_DUAL = 7 L2R_L2LOSS_SVR = 11 L2R_L2LOSS_SVR_DUAL = 12 L2R_L1LOSS_SVR_DUAL = 13 PRINT_STRING_FUN = CFUNCTYPE(None, c_char_p) -def print_null(s): - return +def print_null(s): + return -def genFields(names, types): +def genFields(names, types): return list(zip(names, types)) -def fillprototype(f, restype, argtypes): +def fillprototype(f, restype, argtypes): f.restype = restype f.argtypes = argtypes @@ -69,7 +69,7 @@ def gen_feature_nodearray(xi, feature_max=None, issparse=True): if feature_max: assert(isinstance(feature_max, int)) index_range = filter(lambda j: j <= feature_max, index_range) - if issparse: + if issparse: index_range = filter(lambda j:xi[j] != 0, index_range) index_range = sorted(index_range) @@ -80,7 +80,7 @@ def gen_feature_nodearray(xi, feature_max=None, issparse=True): ret[idx].index = j ret[idx].value = xi[j] max_idx = 0 - if index_range : + if index_range : max_idx = index_range[-1] return ret, max_idx @@ -106,18 +106,18 @@ class problem(Structure): self.y = (c_double * l)() for i, yi in enumerate(y): self.y[i] = y[i] - self.x = (POINTER(feature_node) * l)() + self.x = (POINTER(feature_node) * l)() for i, xi in enumerate(self.x_space): self.x[i] = xi self.set_bias(bias) def set_bias(self, bias): if self.bias == bias: - return - if bias >= 0 and self.bias < 0: + return + if bias >= 0 and self.bias < 0: self.n += 1 node = feature_node(self.n, bias) - if bias < 0 and self.bias >= 0: + if bias < 0 and self.bias >= 0: self.n -= 1 node = feature_node(-1, bias) @@ -139,7 +139,7 @@ class parameter(Structure): def __str__(self): s = '' attrs = parameter._names + list(self.__dict__.keys()) - values = map(lambda attr: getattr(self, attr), attrs) + values = map(lambda attr: getattr(self, attr), attrs) for attr, val in zip(attrs, values): s += (' %s: %s\n' % (attr, val)) s = s.strip() @@ -217,7 +217,7 @@ class parameter(Structure): liblinear.set_print_string_function(self.print_func) self.weight_label = (c_int*self.nr_weight)() self.weight = (c_double*self.nr_weight)() - for i in range(self.nr_weight): + for i in range(self.nr_weight): self.weight[i] = weight[i] self.weight_label[i] = weight_label[i] diff --git a/python/liblinearutil.py b/python/liblinearutil.py index cb5e60b..0ca44c2 100644 --- a/python/liblinearutil.py +++ b/python/liblinearutil.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import os, sys -sys.path = [os.path.dirname(os.path.abspath(__file__))] + sys.path +sys.path = [os.path.dirname(os.path.abspath(__file__))] + sys.path from liblinear import * from liblinear import __all__ as liblinear_all from ctypes import c_double @@ -153,7 +153,7 @@ def train(arg1, arg2=None, arg3=None): if param.flag_find_C: nr_fold = param.nr_fold best_C = c_double() - best_rate = c_double() + best_rate = c_double() max_C = 1024 if param.flag_C_specified: start_C = param.C -- 2.50.1