Index: science/Makefile =================================================================== --- science/Makefile +++ science/Makefile @@ -53,6 +53,7 @@ SUBDIR += fastcap SUBDIR += fasthenry SUBDIR += fisicalab + SUBDIR += fsom SUBDIR += fvcom SUBDIR += fvcom-mpi SUBDIR += fvm Index: science/fsom/Makefile =================================================================== --- /dev/null +++ science/fsom/Makefile @@ -0,0 +1,26 @@ +# $FreeBSD$ + +PORTNAME= fsom +DISTVERSION= g20151117 +CATEGORIES= science + +MAINTAINER= jwb@FreeBSD.org +COMMENT= Tiny C library for managing SOM (Self-Organizing Maps) neural networks + +LICENSE= GPLv3 + +USE_GITHUB= yes +GH_ACCOUNT= ekg +GH_TAGNAME= 56695e1611d824cda97f08e932d25d08419170cd + +INSTALL_TARGET= install-strip + +PLIST_FILES= bin/fsom \ + include/fsom/convert.h \ + include/fsom/fsom.h \ + include/fsom/split.h \ + lib/libfsom.a + +MAKEFILE= ${FILESDIR}/Makefile + +.include Index: science/fsom/distinfo =================================================================== --- /dev/null +++ science/fsom/distinfo @@ -0,0 +1,3 @@ +TIMESTAMP = 1523601004 +SHA256 (ekg-fsom-g20151117-56695e1611d824cda97f08e932d25d08419170cd_GH0.tar.gz) = 1ba3360985be781bb9f79d974705c86e7bb0719cb83638955e113b5dd83ec8dd +SIZE (ekg-fsom-g20151117-56695e1611d824cda97f08e932d25d08419170cd_GH0.tar.gz) = 9771 Index: science/fsom/files/Makefile =================================================================== --- /dev/null +++ science/fsom/files/Makefile @@ -0,0 +1,52 @@ + +# Use ?= to allow overriding from the env or command-line, e.g. +# +# make CXXFLAGS="-O3 -fPIC" install +# +# Package managers will override many of these variables automatically, so +# this is aimed at making it easy to create packages (Debian packages, +# FreeBSD ports, MacPorts, pkgsrc, etc.) + +CXX ?= g++ +CXXFLAGS ?= -w -O3 -pipe -fomit-frame-pointer -ffast-math +AR ?= ar +MKDIR ?= mkdir +STRIP ?= strip +DESTDIR ?= stage +PREFIX ?= /usr/local + +BIN = fsom +LIB = libfsom.a +OBJS = fsom.o split.o +MAIN = main.o + +all: ${BIN} ${LIB} + +${BIN}: ${OBJS} ${MAIN} + ${CXX} -o fsom ${OBJS} ${MAIN} -lm + +${LIB}: ${OBJS} + ${AR} -rs ${LIB} ${OBJS} + +fsom.o: fsom.c + ${CXX} ${CXXFLAGS} -c fsom.c + +split.o: split.cpp + ${CXX} ${CXXFLAGS} -c split.cpp + +main.o: main.cpp + ${CXX} ${CXXFLAGS} -c main.cpp + +install: all + ${MKDIR} -p ${DESTDIR}${PREFIX}/bin + ${MKDIR} -p ${DESTDIR}${PREFIX}/include/fsom + ${MKDIR} -p ${DESTDIR}${PREFIX}/lib + ${INSTALL} ${BIN} ${DESTDIR}${PREFIX}/bin + ${INSTALL} *.h ${DESTDIR}${PREFIX}/include/fsom + ${INSTALL} ${LIB} ${DESTDIR}${PREFIX}/lib + +install-strip: install + ${STRIP} ${DESTDIR}${PREFIX}/bin/${BIN} + +clean: + rm -rf *.o ${BIN} ${LIB} ${DESTDIR} Index: science/fsom/files/patch-fsom.c =================================================================== --- /dev/null +++ science/fsom/files/patch-fsom.c @@ -0,0 +1,26 @@ +--- fsom.c.orig 2015-11-21 16:35:06 UTC ++++ fsom.c +@@ -31,6 +31,10 @@ + #define M_E 2.7182818284590452354 + #endif + ++#ifndef ABS ++#define ABS(x) ((x) < 0 ? -(x) : (x)) ++#endif ++ + /** + * \brief Create a new synapsis between two neurons + * \param input_neuron Input neuron for the synapsis +@@ -591,10 +595,10 @@ som_train_iteration ( som_network_t *net + som_neuron_t *neuron; + for ( i=0; i < net->output_layer->neurons_rows; ++i ) + { +- dist_i = abs( x - i ); ++ dist_i = ABS( x - i ); + for ( j=0; j < net->output_layer->neurons_cols; ++j ) + { +- dist = pow( dist_i + abs ( y - j ), 4 ); ++ dist = pow( dist_i + ABS ( y - j ), 4 ); + inv_dist = (1.0 / ((double) dist + 1)) * l_rate; + neuron = net->output_layer->neurons[i][j]; + for ( k=0; k < net->input_layer->neurons_count; ++k ) Index: science/fsom/pkg-descr =================================================================== --- /dev/null +++ science/fsom/pkg-descr @@ -0,0 +1,6 @@ +FSOM is a tiny C library for managing SOM (Self-Organizing Maps) neural +networks, a type of artificial neural network (ANN) that is trained using +unsupervised learning to produce a low-dimensional (typically two-dimensional), +discretized representation of the input space of the training samples. + +WWW: https://github.com/ekg/fsom