SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
linalg.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) The Shogun Machine Learning Toolbox
3  * Written (w) 2014 Soumyajit De
4  * Written (w) 2014 Khaled Nasr
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice, this
11  * list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright notice,
13  * this list of conditions and the following disclaimer in the documentation
14  * and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  * The views and conclusions contained in the software and documentation are those
28  * of the authors and should not be interpreted as representing official policies,
29  * either expressed or implied, of the Shogun Development Team.
30  */
31 
32 #ifndef LINALG_H_
33 #define LINALG_H_
34 
35 #include <shogun/lib/config.h>
36 
42 #if defined(HAVE_CXX0X) || defined(HAVE_CXX11)
43 namespace shogun
44 {
45 
51 namespace linalg
52 {
53 
74 enum class Backend
75 {
76  EIGEN3,
77 #ifdef HAVE_VIENNACL
78  VIENNACL,
79 #endif
80  NATIVE,
81  DEFAULT = 0
82 };
83 
90 template <class Module>
91 struct linalg_traits : Module
92 {
93 };
94 
95 #ifndef DOXYGEN_SHOULD_SKIP_THIS
96 
100 #ifndef SET_MODULE_BACKEND
101 #define SET_MODULE_BACKEND(MODULE, BACKEND) \
102 struct MODULE \
103 { \
104  const static Backend backend = Backend::BACKEND; \
105 };
106 #endif // SET_MODULE_BACKEND
107 
116 #ifndef SET_GLOBAL_BACKEND
117 #define SET_GLOBAL_BACKEND(BACKEND) \
118  SET_MODULE_BACKEND(Core, BACKEND) \
119  SET_MODULE_BACKEND(Redux, BACKEND) \
120  SET_MODULE_BACKEND(Linsolver, BACKEND) \
121  SET_MODULE_BACKEND(Eigsolver, BACKEND)
122 #endif // SET_GLOBAL_BACKEND
123 
125 #ifdef USE_EIGEN3
126  SET_GLOBAL_BACKEND(EIGEN3)
127 #elif USE_VIENNACL
128  SET_GLOBAL_BACKEND(VIENNACL)
129 #else
130 
134 #ifdef USE_EIGEN3_CORE
135  SET_MODULE_BACKEND(Core, EIGEN3)
136 #elif USE_VIENNACL_CORE
137  SET_MODULE_BACKEND(Core, VIENNACL)
138 #else // the default case
139  SET_MODULE_BACKEND(Core, DEFAULT)
140 #endif
141 
143 #ifdef USE_EIGEN3_REDUX
144  SET_MODULE_BACKEND(Redux, EIGEN3)
145 #elif USE_VIENNACL_REDUX
146  SET_MODULE_BACKEND(Redux, VIENNACL)
147 #else // the default case
148  SET_MODULE_BACKEND(Redux, DEFAULT)
149 #endif
150 
152 #ifdef USE_EIGEN3_LINSLV
153  SET_MODULE_BACKEND(Linsolver, EIGEN3)
154 #elif USE_VIENNACL_LINSLV
155  SET_MODULE_BACKEND(Linsolver, VIENNACL)
156 #else // the default case
157  SET_MODULE_BACKEND(Linsolver, DEFAULT)
158 #endif
159 
161 #ifdef USE_EIGEN3_EIGSLV
162  SET_MODULE_BACKEND(Eigsolver, EIGEN3)
163 #elif USE_VIENNACL_EIGSLV
164  SET_MODULE_BACKEND(Eigsolver, VIENNACL)
165 #else // the default case
166  SET_MODULE_BACKEND(Eigsolver, DEFAULT)
167 #endif
168 
169 #endif // end of global settings
170 
171 #undef SET_GLOBAL_BACKEND
172 #undef SET_MODULE_BACKEND
173 
174 #endif // DOXYGEN_SHOULD_SKIP_THIS
175 }
176 
177 }
178 
184 
187 
189 
190 #endif // defined(HAVE_CXX0X) || defined(HAVE_CXX11)
191 #endif // LINALG_H_
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18

SHOGUN Machine Learning Toolbox - Documentation