44 #include <viennacl/linalg/matrix_operations.hpp>
45 #include <viennacl/linalg/vector_operations.hpp>
46 #endif // HAVE_VIENNACL
54 namespace implementation
60 template <enum Backend,
class Matrix>
64 typedef typename Matrix::Scalar
T;
74 static void compute(Matrix A, Matrix B, Matrix C, T alpha, T beta);
80 template <
class Matrix>
81 struct add<Backend::EIGEN3, Matrix>
84 typedef typename Matrix::Scalar
T;
106 "Dimension mismatch! A(%d x %d) vs B(%d x %d)\n",
130 C_eig=alpha*A_eig+beta*B_eig;
144 "A(%d) vs B(%d)\n", A.
vlen, B.
vlen);
167 C_eig=alpha*A_eig+beta*B_eig;
176 template <
class Matrix>
177 struct add<Backend::VIENNACL, Matrix>
180 typedef typename Matrix::Scalar
T;
190 static CGPUMatrix<T>
compute(CGPUMatrix<T> A, CGPUMatrix<T> B, T alpha=1, T beta=1)
192 REQUIRE(A.matrix,
"Matrix A is not initialized!\n");
193 REQUIRE(B.matrix,
"Matrix B is not initialized!\n");
195 REQUIRE(A.num_rows == B.num_rows && A.num_cols == B.num_cols,
196 "Dimension mismatch! A(%d x %d) vs B(%d x %d)\n",
197 A.num_rows, A.num_cols, B.num_rows, B.num_cols);
199 CGPUMatrix<T> C(A.num_rows, A.num_cols);
213 static void compute(CGPUMatrix<T> A, CGPUMatrix<T> B, CGPUMatrix<T> C,
216 C.vcl_matrix()=alpha*A.vcl_matrix()+beta*B.vcl_matrix();
227 static CGPUVector<T>
compute(CGPUVector<T> A, CGPUVector<T> B, T alpha=1, T beta=1)
229 REQUIRE(A.vlen == B.vlen,
"Vectors should have same length! "
230 "A(%d) vs B(%d)\n", A.vlen, B.vlen);
232 CGPUVector<T> C(A.vlen);
246 static void compute(CGPUVector<T> A, CGPUVector<T> B, CGPUVector<T> C,
249 C.vcl_vector()=alpha*A.vcl_vector()+beta*B.vcl_vector();
253 #endif // HAVE_VIENNACL
260 #endif // ADD_IMPL_H_
static SGVector< T > compute(SGVector< T > A, SGVector< T > B, T alpha=1, T beta=1)
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > MatrixXt
void add(Matrix A, Matrix B, Matrix C, typename Matrix::Scalar alpha=1.0, typename Matrix::Scalar beta=1.0)
Generic class which is specialized for different backends to perform addition.
Eigen::Matrix< T, Eigen::Dynamic, 1 > VectorXt
static void compute(Matrix A, Matrix B, Matrix C, T alpha, T beta)
static void compute(SGVector< T > A, SGVector< T > B, SGVector< T > C, T alpha, T beta)
static void compute(SGMatrix< T > A, SGMatrix< T > B, SGMatrix< T > C, T alpha, T beta)
all of classes and functions are contained in the shogun namespace
static SGMatrix< T > compute(SGMatrix< T > A, SGMatrix< T > B, T alpha=1, T beta=1)