/usr/include/viennacl/linalg/sum.hpp is in libviennacl-dev 1.7.1+dfsg1-2ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | #ifndef VIENNACL_LINALG_REDUCE_HPP_
#define VIENNACL_LINALG_REDUCE_HPP_
/* =========================================================================
Copyright (c) 2010-2016, Institute for Microelectronics,
Institute for Analysis and Scientific Computing,
TU Wien.
Portions of this software are copyright by UChicago Argonne, LLC.
-----------------
ViennaCL - The Vienna Computing Library
-----------------
Project Head: Karl Rupp rupp@iue.tuwien.ac.at
(A list of authors and contributors can be found in the manual)
License: MIT (X11), see file LICENSE in the base directory
============================================================================= */
/** @file viennacl/linalg/sum.hpp
@brief Stub routines for the summation of elements in a vector, or all elements in either a row or column of a dense matrix.
*/
#include "viennacl/forwards.h"
#include "viennacl/tools/tools.hpp"
#include "viennacl/meta/enable_if.hpp"
#include "viennacl/meta/tag_of.hpp"
#include "viennacl/meta/result_of.hpp"
namespace viennacl
{
namespace linalg
{
//
// Sum of vector entries
//
/** @brief User interface function for computing the sum of all elements of a vector */
template<typename NumericT>
viennacl::scalar_expression< const viennacl::vector_base<NumericT>,
const viennacl::vector_base<NumericT>,
viennacl::op_sum >
sum(viennacl::vector_base<NumericT> const & x)
{
return viennacl::scalar_expression< const viennacl::vector_base<NumericT>,
const viennacl::vector_base<NumericT>,
viennacl::op_sum >(x, x);
}
/** @brief User interface function for computing the sum of all elements of a vector specified by a vector operation.
*
* Typical use case: double my_sum = viennacl::linalg::sum(x + y);
*/
template<typename LHS, typename RHS, typename OP>
viennacl::scalar_expression<const viennacl::vector_expression<const LHS, const RHS, OP>,
const viennacl::vector_expression<const LHS, const RHS, OP>,
viennacl::op_sum>
sum(viennacl::vector_expression<const LHS, const RHS, OP> const & x)
{
return viennacl::scalar_expression< const viennacl::vector_expression<const LHS, const RHS, OP>,
const viennacl::vector_expression<const LHS, const RHS, OP>,
viennacl::op_sum >(x, x);
}
//
// Sum of entries in rows of a matrix
//
/** @brief User interface function for computing the sum of all elements of each row of a matrix. */
template<typename NumericT>
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)
{
return viennacl::vector_expression< const viennacl::matrix_base<NumericT>,
const viennacl::matrix_base<NumericT>,
viennacl::op_row_sum >(A, A);
}
/** @brief User interface function for computing the sum of all elements of each row of a matrix specified by a matrix operation.
*
* Typical use case: vector<double> my_sums = viennacl::linalg::row_sum(A + B);
*/
template<typename LHS, typename RHS, typename OP>
viennacl::vector_expression<const viennacl::matrix_expression<const LHS, const RHS, OP>,
const viennacl::matrix_expression<const LHS, const RHS, OP>,
viennacl::op_row_sum>
row_sum(viennacl::matrix_expression<const LHS, const RHS, OP> const & A)
{
return viennacl::vector_expression< const viennacl::matrix_expression<const LHS, const RHS, OP>,
const viennacl::matrix_expression<const LHS, const RHS, OP>,
viennacl::op_row_sum >(A, A);
}
//
// Sum of entries in columns of a matrix
//
/** @brief User interface function for computing the sum of all elements of each column of a matrix. */
template<typename NumericT>
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)
{
return viennacl::vector_expression< const viennacl::matrix_base<NumericT>,
const viennacl::matrix_base<NumericT>,
viennacl::op_col_sum >(A, A);
}
/** @brief User interface function for computing the sum of all elements of each column of a matrix specified by a matrix operation.
*
* Typical use case: vector<double> my_sums = viennacl::linalg::column_sum(A + B);
*/
template<typename LHS, typename RHS, typename OP>
viennacl::vector_expression<const viennacl::matrix_expression<const LHS, const RHS, OP>,
const viennacl::matrix_expression<const LHS, const RHS, OP>,
viennacl::op_col_sum>
column_sum(viennacl::matrix_expression<const LHS, const RHS, OP> const & A)
{
return viennacl::vector_expression< const viennacl::matrix_expression<const LHS, const RHS, OP>,
const viennacl::matrix_expression<const LHS, const RHS, OP>,
viennacl::op_col_sum >(A, A);
}
} // end namespace linalg
} // end namespace viennacl
#endif
|