SHOGUN  4.1.0
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
linalg.h
浏览该文件的文档.
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 
75 enum class Backend
76 {
77 #ifdef HAVE_EIGEN3
78  EIGEN3,
79 #endif
80 #ifdef HAVE_VIENNACL
81  VIENNACL,
82 #endif
83  NATIVE,
84  DEFAULT = 0
85 };
86 
93 template <class Module>
94 struct linalg_traits : Module
95 {
96 };
97 
98 #ifndef DOXYGEN_SHOULD_SKIP_THIS
99 
103 #ifndef SET_MODULE_BACKEND
104 #define SET_MODULE_BACKEND(MODULE, BACKEND) \
105 struct MODULE \
106 { \
107  const static Backend backend = Backend::BACKEND; \
108 };
109 #endif // SET_MODULE_BACKEND
110 
119 #ifndef SET_GLOBAL_BACKEND
120 #define SET_GLOBAL_BACKEND(BACKEND) \
121  SET_MODULE_BACKEND(Core, BACKEND) \
122  SET_MODULE_BACKEND(Redux, BACKEND) \
123  SET_MODULE_BACKEND(Linsolver, BACKEND) \
124  SET_MODULE_BACKEND(Eigsolver, BACKEND)
125 #endif // SET_GLOBAL_BACKEND
126 
128 #ifdef USE_EIGEN3
129  SET_GLOBAL_BACKEND(EIGEN3)
130 #elif USE_VIENNACL
131  SET_GLOBAL_BACKEND(VIENNACL)
132 #else
133 
137 #ifdef USE_EIGEN3_CORE
138  SET_MODULE_BACKEND(Core, EIGEN3)
139 #elif USE_VIENNACL_CORE
140  SET_MODULE_BACKEND(Core, VIENNACL)
141 #else // the default case
142  SET_MODULE_BACKEND(Core, DEFAULT)
143 #endif
144 
146 #ifdef USE_EIGEN3_REDUX
147  SET_MODULE_BACKEND(Redux, EIGEN3)
148 #elif USE_VIENNACL_REDUX
149  SET_MODULE_BACKEND(Redux, VIENNACL)
150 #else // the default case
151  SET_MODULE_BACKEND(Redux, DEFAULT)
152 #endif
153 
155 #ifdef USE_EIGEN3_LINSLV
156  SET_MODULE_BACKEND(Linsolver, EIGEN3)
157 #elif USE_VIENNACL_LINSLV
158  SET_MODULE_BACKEND(Linsolver, VIENNACL)
159 #else // the default case
160  SET_MODULE_BACKEND(Linsolver, DEFAULT)
161 #endif
162 
164 #ifdef USE_EIGEN3_EIGSLV
165  SET_MODULE_BACKEND(Eigsolver, EIGEN3)
166 #elif USE_VIENNACL_EIGSLV
167  SET_MODULE_BACKEND(Eigsolver, VIENNACL)
168 #else // the default case
169  SET_MODULE_BACKEND(Eigsolver, DEFAULT)
170 #endif
171 
172 #endif // end of global settings
173 
174 #undef SET_GLOBAL_BACKEND
175 #undef SET_MODULE_BACKEND
176 
177 #endif // DOXYGEN_SHOULD_SKIP_THIS
178 }
179 
180 }
181 
187 
190 
192 
193 #endif // defined(HAVE_CXX0X) || defined(HAVE_CXX11)
194 #endif // LINALG_H_
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18

SHOGUN 机器学习工具包 - 项目文档