automatic commit
[mlp.git] / misc.h
diff --git a/misc.h b/misc.h
new file mode 100644 (file)
index 0000000..3a8b43d
--- /dev/null
+++ b/misc.h
@@ -0,0 +1,47 @@
+/*
+ *  mlp-mnist is an implementation of a multi-layer neural network.
+ *
+ *  Copyright (c) 2008 Idiap Research Institute, http://www.idiap.ch/
+ *  Written by Francois Fleuret <francois.fleuret@idiap.ch>
+ *
+ *  This file is part of mlp-mnist.
+ *
+ *  mlp-mnist is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 3 as
+ *  published by the Free Software Foundation.
+ *
+ *  mlp-mnist 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 mlp-mnist.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef MISC_H
+#define MISC_H
+
+#ifdef DEBUG
+#define ASSERT(x, s) if(!(x)) { std::cerr << "ASSERT FAILED IN " << __FILE__ << ":" << __LINE__ << " [" << (s) << "]\n"; abort(); }
+#else
+#define ASSERT(x, s)
+#endif
+
+typedef float scalar_t;
+
+template<class T> T sq(T x) { return x*x; }
+
+template<class T> T pos(T x) { if(x < 0) return 0.0; else return x; }
+
+struct Couple {
+  int index;
+  double value;
+};
+
+int compare_couple(const void *a, const void *b);
+
+int factorial(int k);
+
+#endif