Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2886_SymRegGrammarEnumeration/ExpressionClustering/flann/include/flann/general.h @ 15840

Last change on this file since 15840 was 15840, checked in by gkronber, 6 years ago

#2886 added utility console program for clustering of expressions

File size: 3.3 KB
Line 
1/***********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright 2008-2009  Marius Muja (mariusm@cs.ubc.ca). All rights reserved.
5 * Copyright 2008-2009  David G. Lowe (lowe@cs.ubc.ca). All rights reserved.
6 *
7 * THE BSD LICENSE
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 *    notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 *    notice, this list of conditions and the following disclaimer in the
17 *    documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *************************************************************************/
30
31#ifndef FLANN_GENERAL_H_
32#define FLANN_GENERAL_H_
33
34#include "defines.h"
35#include <stdexcept>
36#include <cassert>
37
38namespace flann
39{
40
41class FLANNException : public std::runtime_error
42{
43public:
44    FLANNException(const char* message) : std::runtime_error(message) { }
45
46    FLANNException(const std::string& message) : std::runtime_error(message) { }
47};
48
49inline size_t flann_datatype_size(flann_datatype_t type)
50{
51  switch (type) {
52  case FLANN_INT8:
53    return 1;
54  break;
55  case FLANN_INT16:
56    return 2;
57  break;
58  case FLANN_INT32:
59    return 4;
60  break;
61  case FLANN_INT64:
62    return 8;
63  break;
64  case FLANN_UINT8:
65    return 1;
66  break;
67  case FLANN_UINT16:
68    return 2;
69  break;
70  case FLANN_UINT32:
71    return 4;
72  break;
73  case FLANN_UINT64:
74    return 8;
75  break;
76  case FLANN_FLOAT32:
77    return 4;
78  break;
79  case FLANN_FLOAT64:
80    return 8;
81  break;
82  default:
83    return 1;
84  }
85}
86
87template <typename T>
88struct flann_datatype
89{
90  static const flann_datatype_t value = FLANN_NONE;
91};
92
93template<>
94struct flann_datatype<char>
95{
96  static const flann_datatype_t value = FLANN_INT8;
97};
98
99template<>
100struct flann_datatype<short>
101{
102  static const flann_datatype_t value = FLANN_INT16;
103};
104
105template<>
106struct flann_datatype<int>
107{
108  static const flann_datatype_t value = FLANN_INT32;
109};
110
111template<>
112struct flann_datatype<unsigned char>
113{
114  static const flann_datatype_t value = FLANN_UINT8;
115};
116
117template<>
118struct flann_datatype<unsigned short>
119{
120  static const flann_datatype_t value = FLANN_UINT16;
121};
122
123template<>
124struct flann_datatype<unsigned int>
125{
126  static const flann_datatype_t value = FLANN_UINT32;
127};
128
129template<>
130struct flann_datatype<float>
131{
132  static const flann_datatype_t value = FLANN_FLOAT32;
133};
134
135template<>
136struct flann_datatype<double>
137{
138  static const flann_datatype_t value = FLANN_FLOAT64;
139};
140
141}
142
143
144#endif  /* FLANN_GENERAL_H_ */
Note: See TracBrowser for help on using the repository browser.