iRoCS Toolbox  1.1.0
svm_defines.hh
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * Copyright (C) 2004-2015 Olaf Ronneberger, Florian Pigorsch, Jörg Mechnich,
4  * Thorsten Falk
5  *
6  * Image Analysis Lab, University of Freiburg, Germany
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software Foundation,
20  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  **************************************************************************/
23 
24 /**************************************************************************
25 ** Title:
26 ** $RCSfile$
27 ** $Revision: 509 $$Name$
28 ** $Date: 2004-09-03 13:35:04 +0200 (Fri, 03 Sep 2004) $
29 ** Copyright: LGPL $Author: ronneber $
30 ** Description:
31 **
32 ** some simple definitions and helper functions
33 **
34 **-------------------------------------------------------------------------
35 **
36 ** $Log$
37 ** Revision 1.2 2004/09/03 11:35:03 ronneber
38 ** - replaced Chi-Jen Lin's own min,max,swap with std::min,
39 ** std::max. std::swap to compile with programs, that "#include
40 ** <algorithm>" and do a "using namespace std;"
41 **
42 ** Revision 1.1 2004/08/26 08:36:59 ronneber
43 ** initital import
44 **
45 **
46 **
47 **************************************************************************/
48 
49 #ifndef SVM_DEFINES_HH
50 #define SVM_DEFINES_HH
51 
52 #ifdef HAVE_CONFIG_H
53 #include <config.hh>
54 #endif
55 
56 #include <cstdio>
57 #include <cstdarg>
58 #include <cstring> // memcpy
59 #include <algorithm> // std::min, std::max, std::swap
60 
61 // If user specifies unique ID's above this, libsvmtl will
62 // throw an error
63 const unsigned int MAX_BELIEVABLE_UNIQUE_ID = 100000000;
64 
65 
66 typedef float Qfloat;
67 typedef signed char schar;
68 /*-------------------------------------------------------------------------
69  * replaced Chi-Jen-Lin's min, max and swap everywhere with std::min,
70  * std::max, std::swap to compile with programs, that "#include
71  * <algorithm>" and do "using namespace std;"
72  *-------------------------------------------------------------------------*/
73 // #ifndef min
74 // template <class T> inline T min(T x,T y) { return (x<y)?x:y; }
75 // #endif
76 // #ifndef max
77 // template <class T> inline T max(T x,T y) { return (x>y)?x:y; }
78 // #endif
79 // template <class T> inline void swap(T& x, T& y) { T t=x; x=y; y=t; }
80 template <class S, class T> inline void clone(T*& dst, S* src, int n)
81 {
82  dst = new T[n];
83  std::memcpy((void *)dst,(void *)src,sizeof(T)*n);
84 }
85 #define INF HUGE_VAL
86 #define Malloc(type,n) (type *)malloc((n)*sizeof(type))
87 #if 1
88 inline void info(char *fmt,...)
89 {
90  va_list ap;
91  va_start(ap,fmt);
92  vprintf(fmt,ap);
93  va_end(ap);
94 }
95 inline void info_flush()
96 {
97  fflush(stdout);
98 }
99 #else
100 inline void info(char *fmt,...) {}
101 inline void info_flush() {}
102 #endif
103 
104 #endif
signed char schar
Definition: svm_defines.hh:67
const unsigned int MAX_BELIEVABLE_UNIQUE_ID
Definition: svm_defines.hh:63
void info_flush()
Definition: svm_defines.hh:95
void info(char *fmt,...)
Definition: svm_defines.hh:88
void clone(T *&dst, S *src, int n)
Definition: svm_defines.hh:80
float Qfloat
Definition: svm_defines.hh:66