X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=mlp.git;a=blobdiff_plain;f=misc.h;fp=misc.h;h=3a8b43d0d5bd259f0a2d73a96f115b58a594fa8a;hp=0000000000000000000000000000000000000000;hb=713c683d77fc94a4257c4031b0c51ef4669a3d4a;hpb=751279426fb49172dfe95d85dd277e06a970577e diff --git a/misc.h b/misc.h new file mode 100644 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 + * + * 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 . + * + */ + +#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 T sq(T x) { return x*x; } + +template 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