diff options
| -rw-r--r-- | math/Makefile | 1 | ||||
| -rw-r--r-- | math/libocas/Makefile | 64 | ||||
| -rw-r--r-- | math/libocas/distinfo | 2 | ||||
| -rw-r--r-- | math/libocas/files/patch-linclass.c | 142 | ||||
| -rw-r--r-- | math/libocas/files/patch-msvmocas.c | 20 | ||||
| -rw-r--r-- | math/libocas/pkg-descr | 10 | 
6 files changed, 239 insertions, 0 deletions
diff --git a/math/Makefile b/math/Makefile index b8e1f6745eff..d7394b59f71a 100644 --- a/math/Makefile +++ b/math/Makefile @@ -179,6 +179,7 @@      SUBDIR += liblbfgs      SUBDIR += libmath++      SUBDIR += libneural +    SUBDIR += libocas      SUBDIR += liborigin      SUBDIR += libqalculate      SUBDIR += libranlip diff --git a/math/libocas/Makefile b/math/libocas/Makefile new file mode 100644 index 000000000000..4727206be59e --- /dev/null +++ b/math/libocas/Makefile @@ -0,0 +1,64 @@ +# New ports collection makefile for:	libocas +# Date created: 	5 Oct 2011 +# Whom: 	b.f. <bf@FreeBSD.org> +# +# $FreeBSD$ +# + +PORTNAME=	libocas +PORTVERSION=	0.93 +CATEGORIES=	math +MASTER_SITES=	http://cmp.felk.cvut.cz/~xfrancv/ocas/ LOCAL/bf +DISTNAME=	${PORTNAME}_v${PORTVERSION:S/.//} + +MAINTAINER=	bf@FreeBSD.org +COMMENT=	Efficient training of SVM classifiers + +LICENSE=	GPLv3 + +USE_GMAKE=	yes +USE_LDCONFIG=	yes +USE_ZIP=	yes + +ALL_TARGET=	all linclass +LIBS=		-lm ${PTHREAD_LIBS} +MAKE_ENV=	MEXDETECTED=no + +PLIST_FILES=	bin/linclass bin/msvmocas bin/svmocas lib/libocas.so \ +		lib/libocas.so.1 + +.include <bsd.port.pre.mk> + +.if ${ARCH} == sparc64 +PICFLAG=	-fPIC +.else +PICFLAG=	-fpic +.endif + +CFLAGS+=	${PICFLAG} ${PTHREAD_CFLAGS} + +post-patch: +	@${REINPLACE_CMD} \ +		-e '\|:=|d' \ +		-e 's|libocas\.so|&.1|' \ +		-e '\|$$(CC) $$(CFLAGS) -o|{s|$$(CFLAGS)|& ${LDFLAGS}|;s|$$| ${LIBS}|;}' \ +		${WRKSRC}/Makefile + +do-install: +.for p in linclass msvmocas svmocas +	@${INSTALL_PROGRAM} ${WRKSRC}/${p} ${PREFIX}/bin +.endfor +	@${INSTALL_LIB} ${WRKSRC}/libocas.so.1 ${PREFIX}/lib +	@${LN} -sf libocas.so.1 ${PREFIX}/lib/libocas.so + +check regression-test test: build +	${WRKSRC}/msvmocas -c 10 -v 1 ${WRKSRC}/data/example4_train.light \ +		${WRKSRC}/data/msvmocas.model +	${WRKSRC}/linclass -e -v 1 -o ${WRKSRC}/data/exaple4_test.pred \ +		${WRKSRC}/data/example4_test.light ${WRKSRC}/data/msvmocas.model +	${WRKSRC}/svmocas -c 10 -b 1 -v 1 ${WRKSRC}/data/riply_trn.light \ +		${WRKSRC}/data/svmocas.model +	${WRKSRC}/linclass -e -v 1 -o ${WRKSRC}/data/riply_tst.pred \ +		${WRKSRC}/data/riply_tst.light ${WRKSRC}/data/svmocas.model + +.include <bsd.port.post.mk> diff --git a/math/libocas/distinfo b/math/libocas/distinfo new file mode 100644 index 000000000000..d1725afce641 --- /dev/null +++ b/math/libocas/distinfo @@ -0,0 +1,2 @@ +SHA256 (libocas_v093.zip) = 341b4b1ab5594a6d2a92fdff1654aa320b6845412c97f5493c92d48cf6618aae +SIZE (libocas_v093.zip) = 3328943 diff --git a/math/libocas/files/patch-linclass.c b/math/libocas/files/patch-linclass.c new file mode 100644 index 000000000000..52399b846073 --- /dev/null +++ b/math/libocas/files/patch-linclass.c @@ -0,0 +1,142 @@ +--- linclass.c.orig	2010-05-05 08:55:55.000000000 -0400 ++++ linclass.c	2011-10-06 05:11:23.000000000 -0400 +@@ -62,7 +62,7 @@ +   uint32_t i, j; +   int len; +   int recognized; +-  int exitflag = 0; ++  int exitflag = 1; +   int verb; +   int binary_problem; +   int output_type; +@@ -101,6 +101,8 @@ +   feat_idx = NULL; +   W = NULL; +   W0 = 0; ++  input_fname = NULL; ++  model_fname = NULL; +   output_fname = NULL; +   nClassErrors = NULL; +   nClass = NULL; +@@ -275,6 +277,7 @@ +   if(fgets(line,LIBSLF_MAXLINELEN, fid) == NULL )  +   { +     fprintf(stderr,"Empty example file.\n"); ++    fclose(fid); +     goto clean_up; +   } +   else +@@ -312,6 +315,7 @@ +     if( tmp_nCols != nCols) +     { +       fprintf(stderr,"Error: Model file contains lines with different number of colums.\n"); ++      fclose(fid); +       goto clean_up; +     } +  +@@ -340,6 +344,7 @@ +     if(W == NULL) +     { +       fprintf(stderr,"Not enough memory for vector W.\n"); ++      fclose(fid); +       goto clean_up; +     } +  +@@ -355,6 +360,7 @@ +       if(fgets(line,LIBSLF_MAXLINELEN, fid) == NULL )  +       { +         fprintf(stderr,"Model file corrupted.\n"); ++	fclose(fid); +         goto clean_up; +       } +  +@@ -364,6 +370,7 @@ +       if(val == 0 && begptr == endptr) +       { +         fprintf(stderr,"Model file corrupted.\n"); ++	fclose(fid); +         goto clean_up; +       } +  +@@ -388,6 +395,7 @@ +     if(W == NULL) +     { +       fprintf(stderr,"Not enough memory for matrix W.\n"); ++      fclose(fid); +       goto clean_up; +     } +  +@@ -403,6 +411,7 @@ +       if(fgets(line,LIBSLF_MAXLINELEN, fid) == NULL )  +       { +         fprintf(stderr,"Model file corrupted.\n"); ++	fclose(fid); +         goto clean_up; +       } +  +@@ -414,6 +423,7 @@ +         if(val == 0 && begptr == endptr) +         { +           fprintf(stderr,"Model file corrupted.\n"); ++	  fclose(fid); +           goto clean_up; +         } +         begptr = endptr; +@@ -458,7 +468,7 @@ +   else +   { +     fout = fopen(output_fname, "w+"); +-    if(fid == NULL) { ++    if(fout == NULL) { +       fprintf(stderr,"Cannot open output file.\n"); +       perror("fopen error "); +       fclose(fid); +@@ -478,6 +488,9 @@ +   if(nClassErrors == NULL) +   { +     fprintf(stderr,"Not enough memory for vector nClassError.\n"); ++    fclose(fid); ++    if(output_fname != NULL) ++      fclose(fout); +     goto clean_up; +   } +  +@@ -485,6 +498,9 @@ +   if(nClass == NULL) +   { +     fprintf(stderr,"Not enough memory for vector nClass.\n"); ++    fclose(fid); ++    if(output_fname != NULL) ++      fclose(fout); +     goto clean_up; +   } +    +@@ -505,6 +521,9 @@ +       { +          fprintf(stderr,"Parsing error on line %ld .\n", line_cnt); +          fprintf(stderr,"Probably defective input file.\n"); ++	 fclose(fid); ++	 if(output_fname != NULL) ++	   fclose(fout); +          goto clean_up; +       } +  +@@ -612,12 +631,16 @@ +  +  +   fclose(fid); +-  fclose(fout); ++  if(output_fname != NULL) ++    fclose(fout); +  +-  exitflag = 1; ++  exitflag = 0; +    + clean_up: +  ++  free(input_fname); ++  free(model_fname); ++  free(output_fname); +   free(W); +   free(line); +   free(feat_val); diff --git a/math/libocas/files/patch-msvmocas.c b/math/libocas/files/patch-msvmocas.c new file mode 100644 index 000000000000..0cb51a0aa100 --- /dev/null +++ b/math/libocas/files/patch-msvmocas.c @@ -0,0 +1,20 @@ +--- msvmocas.c.orig	2010-05-05 08:55:55.000000000 -0400 ++++ msvmocas.c	2011-10-06 05:20:07.000000000 -0400 +@@ -91,6 +91,8 @@ +   total_time = get_time(); +  +   /* init */ ++  input_fname = NULL; ++  model_fname= NULL; +   data_X = NULL; +   data_y = NULL; +   W = NULL; +@@ -508,6 +510,8 @@ +  + clean_up: +  ++  free(input_fname); ++  free(model_fname); +   mxDestroyArray(data_X); +   mxFree(data_y); +   mxFree(W); diff --git a/math/libocas/pkg-descr b/math/libocas/pkg-descr new file mode 100644 index 000000000000..c531270ca67c --- /dev/null +++ b/math/libocas/pkg-descr @@ -0,0 +1,10 @@ +libocas implements an Optimized Cutting Plane Algorithm (OCAS) for training +linear SVM classifiers from large-scale data. The computational effort of +OCAS scales with O(m log m) where m is the sample size. In an extensive +empirical evaluation, OCAS significantly outperforms current state-of-the-art +SVM solvers. + +libocas also implements the COFFIN framework for efficient training of +translation invariant image classifiers from virtual examples. + +WWW:	http://cmp.felk.cvut.cz/~xfrancv/ocas/html/index.html  | 
