/usr/include/viennacl/linalg/maxmin.hpp is in libviennacl-dev 1.7.1+dfsg1-2.
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 135 136 137 138 139 140 141 142 143 144 145 146 147 | #ifndef VIENNACL_LINALG_MAXMIN_HPP_
#define VIENNACL_LINALG_MAXMIN_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 norm_inf.hpp
@brief Generic interface for the l^infty-norm. See viennacl/linalg/vector_operations.hpp for implementations.
*/
#include <cmath>
#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
{
//
// generic norm_inf function
// uses tag dispatch to identify which algorithm
// should be called
//
namespace linalg
{
// ----------------------------------------------------
// STL
//
template< typename NumericT >
NumericT max(std::vector<NumericT> const & v1)
{
//std::cout << "stl .. " << std::endl;
NumericT result = v1[0];
for (vcl_size_t i=1; i<v1.size(); ++i)
{
if (v1[i] > result)
result = v1[i];
}
return result;
}
// ----------------------------------------------------
// VIENNACL
//
template< typename ScalarType>
viennacl::scalar_expression< const viennacl::vector_base<ScalarType>,
const viennacl::vector_base<ScalarType>,
viennacl::op_max >
max(viennacl::vector_base<ScalarType> const & v1)
{
//std::cout << "viennacl .. " << std::endl;
return viennacl::scalar_expression< const viennacl::vector_base<ScalarType>,
const viennacl::vector_base<ScalarType>,
viennacl::op_max >(v1, v1);
}
// with vector expression:
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_max>
max(viennacl::vector_expression<const LHS, const RHS, OP> const & vector)
{
return viennacl::scalar_expression< const viennacl::vector_expression<const LHS, const RHS, OP>,
const viennacl::vector_expression<const LHS, const RHS, OP>,
viennacl::op_max >(vector, vector);
}
// ----------------------------------------------------
// STL
//
template< typename NumericT >
NumericT min(std::vector<NumericT> const & v1)
{
//std::cout << "stl .. " << std::endl;
NumericT result = v1[0];
for (vcl_size_t i=1; i<v1.size(); ++i)
{
if (v1[i] < result)
result = v1[i];
}
return result;
}
// ----------------------------------------------------
// VIENNACL
//
template< typename ScalarType>
viennacl::scalar_expression< const viennacl::vector_base<ScalarType>,
const viennacl::vector_base<ScalarType>,
viennacl::op_min >
min(viennacl::vector_base<ScalarType> const & v1)
{
//std::cout << "viennacl .. " << std::endl;
return viennacl::scalar_expression< const viennacl::vector_base<ScalarType>,
const viennacl::vector_base<ScalarType>,
viennacl::op_min >(v1, v1);
}
template< typename ScalarType>
viennacl::scalar_expression< const viennacl::vector_base<ScalarType>,
const viennacl::vector_base<ScalarType>,
viennacl::op_min >
min(viennacl::vector<ScalarType> const & v1)
{
//std::cout << "viennacl .. " << std::endl;
return viennacl::scalar_expression< const viennacl::vector_base<ScalarType>,
const viennacl::vector_base<ScalarType>,
viennacl::op_min >(v1, v1);
}
// with vector expression:
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_min>
min(viennacl::vector_expression<const LHS, const RHS, OP> const & vector)
{
return viennacl::scalar_expression< const viennacl::vector_expression<const LHS, const RHS, OP>,
const viennacl::vector_expression<const LHS, const RHS, OP>,
viennacl::op_min >(vector, vector);
}
} // end namespace linalg
} // end namespace viennacl
#endif
|