SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DenseEigen3DotProduct.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014, Shogun Toolbox Foundation
3  * All rights reserved.
4  *
5  * Written (W) 2014 Sunil K. Mahendrakar
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,
11  * this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  *
17  * 3. Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived from this
19  * software without specific prior written permission.
20 
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  *
33  */
34 
35 #include <shogun/lib/config.h>
36 
37 #ifdef HAVE_EIGEN3
40 #include <shogun/lib/SGVector.h>
41 #include <shogun/io/SGIO.h>
42 
43 namespace shogun
44 {
45 
46 template<class T>
47 T DenseEigen3DotProduct<T>::compute(SGVector<T> vector1, SGVector<T> vector2) const
48 {
49  REQUIRE(vector1.vlen==vector2.vlen,
50  "Dimension of vector1 (%d) is not equal to that of vector2 (%d)",
51  vector1.vlen, vector2.vlen);
52 
53  Map<Matrix<T, Dynamic, 1> > vec1(vector1.vector, vector1.vlen);
54  Map<Matrix<T, Dynamic, 1> > vec2(vector2.vector, vector2.vlen);
55  return vec1.dot(vec2);
56 }
57 
58 template class DenseEigen3DotProduct<bool>;
59 template class DenseEigen3DotProduct<char>;
60 template class DenseEigen3DotProduct<int8_t>;
61 template class DenseEigen3DotProduct<uint8_t>;
62 template class DenseEigen3DotProduct<int16_t>;
63 template class DenseEigen3DotProduct<uint16_t>;
64 template class DenseEigen3DotProduct<int32_t>;
65 template class DenseEigen3DotProduct<uint32_t>;
66 template class DenseEigen3DotProduct<int64_t>;
67 template class DenseEigen3DotProduct<uint64_t>;
68 template class DenseEigen3DotProduct<float32_t>;
69 template class DenseEigen3DotProduct<float64_t>;
70 template class DenseEigen3DotProduct<floatmax_t>;
71 template class DenseEigen3DotProduct<complex128_t>;
72 
73 }
74 #endif //HAVE_EIGEN3

SHOGUN Machine Learning Toolbox - Documentation