diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..43c681a --- /dev/null +++ b/Makefile @@ -0,0 +1,36 @@ +SRCDIR=src +INCLUDEDIR=include +PREFIX=/usr +LIB=neural++ +CC=g++ +CFLAGS=-Wall -pedantic -pedantic-errors + +all: + ${CC} -I${INCLUDEDIR} ${CFLAGS} -fPIC -g -c ${SRCDIR}/neuralnet.cpp + ${CC} -I${INCLUDEDIR} ${CFLAGS} -fPIC -g -c ${SRCDIR}/layer.cpp + ${CC} -I${INCLUDEDIR} ${CFLAGS} -fPIC -g -c ${SRCDIR}/neuron.cpp + ${CC} -I${INCLUDEDIR} ${CFLAGS} -fPIC -g -c ${SRCDIR}/synapsis.cpp + ${CC} -I${INCLUDEDIR} ${CFLAGS} -fPIC -g -c ${SRCDIR}/Markup.cpp + ${CC} -shared -Wl,-soname,lib$(LIB).so.0 -o lib${LIB}.so.0.0.0 neuralnet.o layer.o neuron.o synapsis.o Markup.o + ar rcs lib${LIB}.a neuralnet.o layer.o neuron.o synapsis.o Markup.o + +install: + mkdir -p ${PREFIX}/lib + mkdir -p ${PREFIX}/${INCLUDEDIR} + install -m 0755 lib${LIB}.so.0.0.0 ${PREFIX}/lib/lib${LIB}.so.0.0.0 + install -m 0644 lib${LIB}.a ${PREFIX}/lib/lib${LIB}.a + install -m 0644 ${INCLUDEDIR}/${LIB}.hpp ${PREFIX}/${INCLUDEDIR} + install -m 0644 ${INCLUDEDIR}/${LIB}_exception.hpp ${PREFIX}/${INCLUDEDIR} + ln -sf ${PREFIX}/lib/lib${LIB}.so.0.0.0 ${PREFIX}/lib/lib${LIB}.so.0 + +uninstall: + rm ${PREFIX}/lib/lib${LIB}.a + rm ${PREFIX}/${INCLUDEDIR}/${LIB}.hpp + rm ${PREFIX}/${INCLUDEDIR}/${LIB}_exception.hpp + rm ${PREFIX}/lib/lib${LIB}.so.0.0.0 + rm ${PREFIX}/lib/lib${LIB}.so.0 + +clean: + rm *.o + rm lib${LIB}.so.0.0.0 + rm lib${LIB}.a diff --git a/examples/adder.net b/examples/adder.net index d7c14b8..ae58fe0 100644 Binary files a/examples/adder.net and b/examples/adder.net differ diff --git a/examples/adderFromScratch b/examples/adderFromScratch deleted file mode 100755 index a274458..0000000 Binary files a/examples/adderFromScratch and /dev/null differ diff --git a/examples/adderFromScratch.cpp b/examples/adderFromScratch.cpp index 652e343..f7ed63e 100644 --- a/examples/adderFromScratch.cpp +++ b/examples/adderFromScratch.cpp @@ -6,7 +6,7 @@ */ #include -#include +#include using namespace neuralpp; int main() { diff --git a/examples/doAdd b/examples/doAdd deleted file mode 100755 index a7965f6..0000000 Binary files a/examples/doAdd and /dev/null differ diff --git a/examples/doAdd.cpp b/examples/doAdd.cpp index bc3aa65..2203d3c 100644 --- a/examples/doAdd.cpp +++ b/examples/doAdd.cpp @@ -6,7 +6,7 @@ */ #include -#include +#include using namespace neuralpp; #define NETFILE "adder.net" diff --git a/examples/learnAdd b/examples/learnAdd deleted file mode 100755 index 716c520..0000000 Binary files a/examples/learnAdd and /dev/null differ diff --git a/examples/learnAdd.cpp b/examples/learnAdd.cpp index 4afda5a..2ea674c 100644 --- a/examples/learnAdd.cpp +++ b/examples/learnAdd.cpp @@ -7,7 +7,7 @@ */ #include -#include +#include using namespace neuralpp; int main() { diff --git a/include/neural++.h b/include/neural++.hpp similarity index 94% rename from include/neural++.h rename to include/neural++.hpp index e4f27ca..85d6e7e 100644 --- a/include/neural++.h +++ b/include/neural++.hpp @@ -11,18 +11,21 @@ * this program. If not, see . * **************************************************************************************************/ -#ifdef __cplusplus +#ifndef __cplusplus +#error "This is a C++ library, you know, so you'd better use a C++ compiler to compile it" +#else #ifndef __NEURALPP #define __NEURALPP #include #include -#include #include #include #include + +#include "neural++_exception.hpp" using namespace std; namespace neuralpp { @@ -36,26 +39,6 @@ namespace neuralpp { class NetworkFileNotFoundException; class InvalidXMLException; - /** - * @class NetworkFileNotFoundException - * @brief Exception thrown when doing an attempt to load a network from an invalid file - */ - class NetworkFileNotFoundException : public exception { - public: - NetworkFileNotFoundException() {} - const char* what() const throw() { return strdup("Attempt to load a neural network from an invalid network file\n"); } - }; - - /** - * @class InvalidXMLException - * @brief Exception thrown when trying parsing an invalid XML - */ - class InvalidXMLException : public exception { - public: - InvalidXMLException() {} - const char* what() const throw() { return strdup("Attempt to load an invalid XML file\n"); } - }; - /** * @class NeuralNet * @brief Main project's class. Use *ONLY* this class, unless you know what you're doing diff --git a/include/neural++_exception.hpp b/include/neural++_exception.hpp new file mode 100644 index 0000000..fee799a --- /dev/null +++ b/include/neural++_exception.hpp @@ -0,0 +1,47 @@ +/************************************************************************************************** + * LibNeural++ v.0.2 - All-purpose library for managing neural networks * + * Copyright (C) 2009, BlackLight * + * * + * This program is free software: you can redistribute it and/or modify it under the terms of the * + * GNU General Public License as published by the Free Software Foundation, either version 3 of * + * the License, or (at your option) any later version. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * + * more details. You should have received a copy of the GNU General Public License along with * + * this program. If not, see . * + **************************************************************************************************/ + +#ifndef __cplusplus +#error "This is a C++ library, you know, so you'd better use a C++ compiler to compile it" +#else + +#ifndef __NEURALPP_EXCEPTION +#define __NEURALPP_EXCEPTION + +#include + +namespace neuralpp { + /** + * @class NetworkFileNotFoundException + * @brief Exception thrown when doing an attempt to load a network from an invalid file + */ + class NetworkFileNotFoundException : public std::exception { + public: + NetworkFileNotFoundException() {} + const char* what() const throw() { return "Attempt to load a neural network from an invalid network file"; } + }; + + /** + * @class InvalidXMLException + * @brief Exception thrown when trying parsing an invalid XML + */ + class InvalidXMLException : public std::exception { + public: + InvalidXMLException() {} + const char* what() const throw() { return "Attempt to load an invalid XML file"; } + }; +} + +#endif +#endif + diff --git a/src/Markup.cpp b/src/Markup.cpp index 03ec7fa..e295d18 100644 --- a/src/Markup.cpp +++ b/src/Markup.cpp @@ -130,7 +130,7 @@ bool CMarkup::SetDoc( MCD_PCSZ pDoc ) MCD_STRCLEAR(m_strError); return x_ParseDoc(); -}; +} bool CMarkup::SetDoc( const MCD_STR& strDoc ) { @@ -1386,7 +1386,7 @@ bool CMarkup::x_ParseDoc() } return IsWellFormed(); -}; +} int CMarkup::x_ParseElem( int iPosParent, TokenPos& token ) { @@ -1675,7 +1675,7 @@ int CMarkup::x_ParseNode( CMarkup::TokenPos& token, CMarkup::NodePos& node ) PD_DOCTYPE = 32, PD_INQUOTE_S = 64, PD_INQUOTE_D = 128, - PD_EQUALS = 256, + PD_EQUALS = 256 }; int nParseFlags = 0; diff --git a/src/layer.cpp b/src/layer.cpp index 451a9f1..c41370a 100644 --- a/src/layer.cpp +++ b/src/layer.cpp @@ -11,7 +11,8 @@ * this program. If not, see . * **************************************************************************************************/ -#include "neural++.h" +#include +#include "neural++.hpp" using namespace neuralpp; /** diff --git a/src/neuralnet.cpp b/src/neuralnet.cpp index 0cfce80..55caba9 100644 --- a/src/neuralnet.cpp +++ b/src/neuralnet.cpp @@ -11,7 +11,7 @@ * this program. If not, see . * **************************************************************************************************/ -#include "neural++.h" +#include "neural++.hpp" #include "Markup.h" #include using namespace neuralpp; diff --git a/src/neuron.cpp b/src/neuron.cpp index 037ca5f..73de928 100644 --- a/src/neuron.cpp +++ b/src/neuron.cpp @@ -11,7 +11,7 @@ * this program. If not, see . * **************************************************************************************************/ -#include "neural++.h" +#include "neural++.hpp" using namespace neuralpp; /** diff --git a/src/synapsis.cpp b/src/synapsis.cpp index cefd1ce..a2ff47f 100644 --- a/src/synapsis.cpp +++ b/src/synapsis.cpp @@ -11,7 +11,8 @@ * this program. If not, see . * **************************************************************************************************/ -#include "neural++.h" +#include +#include "neural++.hpp" using namespace neuralpp; /**