2 * svrt is the ``Synthetic Visual Reasoning Test'', an image
3 * generator for evaluating classification performance of machine
4 * learning systems, humans and primates.
6 * Copyright (c) 2009 Idiap Research Institute, http://www.idiap.ch/
7 * Written by Francois Fleuret <francois.fleuret@idiap.ch>
9 * This file is part of svrt.
11 * svrt is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License version 3 as
13 * published by the Free Software Foundation.
15 * svrt is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with svrt. If not, see <http://www.gnu.org/licenses/>.
37 typedef double scalar_t;
38 // typedef float scalar_t;
40 const int buffer_size = 1024;
45 #define ASSERT(x) if(!(x)) { \
46 std::cerr << "ASSERT FAILED IN " << __FILE__ << ":" << __LINE__ << endl; \
54 T **allocate_array(int a, int b) {
55 T *tmp = new T[a * b];
56 T **array = new T *[a];
57 for(int k = 0; k < a; k++) {
65 void deallocate_array(T **array) {
71 void write_var(ostream *os, const T *x) { os->write((char *) x, sizeof(T)); }
74 void read_var(istream *is, T *x) { is->read((char *) x, sizeof(T)); }
81 inline scalar_t log2(scalar_t x) {
82 return log(x)/log(2.0);
86 void grow(int *nb_max, int nb, T** current, int factor) {
89 T *tmp = new T[*nb_max * factor];
90 memcpy(tmp, *current, *nb_max * sizeof(T));