SHOGUN  6.0.0
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 #ifdef HAVE_VIENNACL
37 #include <shogun/lib/GPUMatrix.h>
38 #include <shogun/lib/GPUVector.h>
39 #include <viennacl/matrix.hpp>
40 #include <viennacl/linalg/vector_operations.hpp>
41 #endif
42 
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 
115 #ifndef SET_GLOBAL_BACKEND
116 #define SET_GLOBAL_BACKEND(BACKEND) \
117  SET_MODULE_BACKEND(Linsolver, BACKEND) \
118  SET_MODULE_BACKEND(Eigsolver, BACKEND)
119 #endif // SET_GLOBAL_BACKEND
120 
122 #ifdef USE_EIGEN3_GLOBAL
123  SET_GLOBAL_BACKEND(EIGEN3)
124 #elif USE_VIENNACL_GLOBAL
125  SET_GLOBAL_BACKEND(VIENNACL)
126 #else
127 
131 #ifdef USE_EIGEN3_LINSLV
132  SET_MODULE_BACKEND(Linsolver, EIGEN3)
133 #elif USE_VIENNACL_LINSLV
134  SET_MODULE_BACKEND(Linsolver, VIENNACL)
135 #else // the default case
136  SET_MODULE_BACKEND(Linsolver, DEFAULT)
137 #endif
138 
140 #ifdef USE_EIGEN3_EIGSLV
141  SET_MODULE_BACKEND(Eigsolver, EIGEN3)
142 #elif USE_VIENNACL_EIGSLV
143  SET_MODULE_BACKEND(Eigsolver, VIENNACL)
144 #else // the default case
145  SET_MODULE_BACKEND(Eigsolver, DEFAULT)
146 #endif
147 
148 #endif // end of global settings
149 
150 #undef SET_GLOBAL_BACKEND
151 #undef SET_MODULE_BACKEND
152 
153 #endif // DOXYGEN_SHOULD_SKIP_THIS
154 }
155 
156 }
157 
161 
162 #endif // LINALG_H_
Backend
All currently supported linear algebra backend libraries, with a default backend, which will be used ...
Definition: linalg.h:74
General purpose linalg_traits for compile time information about backends set per module (see below)...
Definition: linalg.h:91
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18

SHOGUN Machine Learning Toolbox - Documentation