ViennaCL - The Vienna Computing Library  1.7.1
Free open-source GPU-accelerated linear algebra and solver library.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sum.hpp
Go to the documentation of this file.
1 #ifndef VIENNACL_LINALG_REDUCE_HPP_
2 #define VIENNACL_LINALG_REDUCE_HPP_
3 
4 /* =========================================================================
5  Copyright (c) 2010-2016, Institute for Microelectronics,
6  Institute for Analysis and Scientific Computing,
7  TU Wien.
8  Portions of this software are copyright by UChicago Argonne, LLC.
9 
10  -----------------
11  ViennaCL - The Vienna Computing Library
12  -----------------
13 
14  Project Head: Karl Rupp rupp@iue.tuwien.ac.at
15 
16  (A list of authors and contributors can be found in the manual)
17 
18  License: MIT (X11), see file LICENSE in the base directory
19 ============================================================================= */
20 
25 #include "viennacl/forwards.h"
26 #include "viennacl/tools/tools.hpp"
28 #include "viennacl/meta/tag_of.hpp"
30 
31 namespace viennacl
32 {
33 namespace linalg
34 {
35 
36 //
37 // Sum of vector entries
38 //
39 
41 template<typename NumericT>
46 {
49  viennacl::op_sum >(x, x);
50 }
51 
56 template<typename LHS, typename RHS, typename OP>
61 {
64  viennacl::op_sum >(x, x);
65 }
66 
67 
68 //
69 // Sum of entries in rows of a matrix
70 //
71 
73 template<typename NumericT>
78 {
81  viennacl::op_row_sum >(A, A);
82 }
83 
88 template<typename LHS, typename RHS, typename OP>
93 {
96  viennacl::op_row_sum >(A, A);
97 }
98 
99 
100 //
101 // Sum of entries in columns of a matrix
102 //
103 
105 template<typename NumericT>
110 {
113  viennacl::op_col_sum >(A, A);
114 }
115 
120 template<typename LHS, typename RHS, typename OP>
125 {
128  viennacl::op_col_sum >(A, A);
129 }
130 
131 
132 } // end namespace linalg
133 } // end namespace viennacl
134 #endif
135 
136 
A tag class representing the summation of all columns of a matrix.
Definition: forwards.h:122
Dispatch facility for distinguishing between ublas, STL and ViennaCL types.
viennacl::scalar_expression< const viennacl::vector_base< NumericT >, const viennacl::vector_base< NumericT >, viennacl::op_sum > sum(viennacl::vector_base< NumericT > const &x)
User interface function for computing the sum of all elements of a vector.
Definition: sum.hpp:45
A tag class representing the summation of a vector.
Definition: forwards.h:116
A tag class representing the summation of all rows of a matrix.
Definition: forwards.h:119
Various little tools used here and there in ViennaCL.
viennacl::vector_expression< const viennacl::matrix_base< NumericT >, const viennacl::matrix_base< NumericT >, viennacl::op_row_sum > row_sum(viennacl::matrix_base< NumericT > const &A)
User interface function for computing the sum of all elements of each row of a matrix.
Definition: sum.hpp:77
Expression template class for representing a tree of expressions which ultimately result in a matrix...
Definition: forwards.h:341
This file provides the forward declarations for the main types used within ViennaCL.
A proxy for scalar expressions (e.g. from inner vector products)
Definition: forwards.h:230
An expression template class that represents a binary operation that yields a vector.
Definition: forwards.h:239
viennacl::vector_expression< const viennacl::matrix_base< NumericT >, const viennacl::matrix_base< NumericT >, viennacl::op_col_sum > column_sum(viennacl::matrix_base< NumericT > const &A)
User interface function for computing the sum of all elements of each column of a matrix...
Definition: sum.hpp:109
A collection of compile time type deductions.
Simple enable-if variant that uses the SFINAE pattern.