X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=mlp.git;a=blobdiff_plain;f=misc.cc;fp=misc.cc;h=2f6fa3dfc865be84d8bc2379b323171a9aa3f184;hp=0000000000000000000000000000000000000000;hb=713c683d77fc94a4257c4031b0c51ef4669a3d4a;hpb=751279426fb49172dfe95d85dd277e06a970577e diff --git a/misc.cc b/misc.cc new file mode 100644 index 0000000..2f6fa3d --- /dev/null +++ b/misc.cc @@ -0,0 +1,37 @@ +/* + * 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 . + * + */ + +// $Id: misc.cc,v 1.1 2005-12-13 17:19:11 fleuret Exp $ + +#include "misc.h" + +int compare_couple(const void *a, const void *b) { + if(((Couple *) a)->value < ((Couple *) b)->value) return -1; + else if(((Couple *) a)->value > ((Couple *) b)->value) return 1; + else return 0; +} + +int factorial(int k) { + int n = 1; + for(int l = 1; l <= k; l++) n *= l; + return n; +}