ViennaCL - The Vienna Computing Library: viennacl/linalg/reduce.hpp Source File

ViennaCL - The Vienna Computing Library 1.6.2 Free open-source GPU-accelerated linear algebra and solver library. |

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
reduce.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-2013, 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 PDF 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"
27 #include "viennacl/meta/enable_if.hpp"
28 #include "viennacl/meta/tag_of.hpp"
29 #include "viennacl/meta/result_of.hpp"
30
31 namespace viennacl
32 {
33
34 namespace linalg
35 {
36
37 template<typename OP, typename NumericT>
38 viennacl::scalar_expression< const vector_base<NumericT>, const vector_base<NumericT>, viennacl::op_reduce_vector<OP> >
39 reduce(vector_base<NumericT> const & vector)
40 {
41 return viennacl::scalar_expression< const vector_base<NumericT>,
42 const vector_base<NumericT>,
43 viennacl::op_reduce_vector<OP> >(vector, vector);
44 }
45
46 template< typename ROP, typename LHS, typename RHS, typename OP>
47 viennacl::scalar_expression< const viennacl::vector_expression<LHS, RHS, OP>,
48 const viennacl::vector_expression<LHS, RHS, OP>,
49 viennacl::op_reduce_vector<ROP> >
50 reduce(viennacl::vector_expression<LHS, RHS, OP> const & vector)
51 {
52 return viennacl::scalar_expression< const viennacl::vector_expression<LHS, RHS, OP>,
53 const viennacl::vector_expression<LHS, RHS, OP>,
54 viennacl::op_reduce_vector<ROP> >(vector,vector);
55 }
56
57 //row-wise reduction
58 template<typename ROP, typename NumericT>
59 viennacl::vector_expression<const matrix_base<NumericT>, const matrix_base<NumericT>, viennacl::op_reduce_rows<ROP> >
60 reduce_rows(matrix_base<NumericT> const & mat)
61 {
62 return viennacl::vector_expression<const matrix_base<NumericT>, const matrix_base<NumericT>, viennacl::op_reduce_rows<ROP> >(mat, mat);
63 }
64
65 //column-wise reduction
66 template<typename ROP, typename NumericT>
67 viennacl::vector_expression<const matrix_base<NumericT>, const matrix_base<NumericT>, viennacl::op_reduce_columns<ROP> >
68 reduce_columns(matrix_base<NumericT> const & mat)
69 {
70 return viennacl::vector_expression<const matrix_base<NumericT>, const matrix_base<NumericT>, viennacl::op_reduce_columns<ROP> >(mat, mat);
71 }
72
73
74 } // end namespace linalg
75 } // end namespace viennacl
76 #endif
77
78
tag_of.hpp
Dispatch facility for distinguishing between ublas, STL and ViennaCL types.
viennacl::op_reduce_columns
Definition: forwards.h:121
tools.hpp
Various little tools used here and there in ViennaCL.
viennacl::matrix_base< NumericT >
forwards.h
This file provides the forward declarations for the main types used within ViennaCL.
viennacl::scalar_expression
A proxy for scalar expressions (e.g. from inner vector products)
Definition: forwards.h:229
viennacl::vector_expression
An expression template class that represents a binary operation that yields a vector.
Definition: forwards.h:238
viennacl::linalg::reduce_columns
viennacl::vector_expression< const matrix_base< NumericT >, const matrix_base< NumericT >, viennacl::op_reduce_columns< ROP > > reduce_columns(matrix_base< NumericT > const &mat)
Definition: reduce.hpp:68
viennacl::op_reduce_vector
Definition: forwards.h:115
viennacl::linalg::reduce_rows
viennacl::vector_expression< const matrix_base< NumericT >, const matrix_base< NumericT >, viennacl::op_reduce_rows< ROP > > reduce_rows(matrix_base< NumericT > const &mat)
Definition: reduce.hpp:60
viennacl::op_reduce_rows
Definition: forwards.h:118
viennacl::linalg::reduce
viennacl::scalar_expression< const vector_base< NumericT >, const vector_base< NumericT >, viennacl::op_reduce_vector< OP > > reduce(vector_base< NumericT > const &vector)
Definition: reduce.hpp:39
viennacl::vector_base< NumericT >
viennacl::vector
Definition: forwards.h:265
result_of.hpp
A collection of compile time type deductions.
enable_if.hpp
Simple enable-if variant that uses the SFINAE pattern.