annotate DEPENDENCIES/generic/include/boost/numeric/ublas/operation/begin.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 /**
Chris@16 2 * -*- c++ -*-
Chris@16 3 *
Chris@16 4 * \file begin.hpp
Chris@16 5 *
Chris@16 6 * \brief The \c begin operation.
Chris@16 7 *
Chris@16 8 * Copyright (c) 2009, Marco Guazzone
Chris@16 9 *
Chris@16 10 * Distributed under the Boost Software License, Version 1.0. (See
Chris@16 11 * accompanying file LICENSE_1_0.txt or copy at
Chris@16 12 * http://www.boost.org/LICENSE_1_0.txt)
Chris@16 13 *
Chris@16 14 * \author Marco Guazzone, marco.guazzone@gmail.com
Chris@16 15 */
Chris@16 16
Chris@16 17 #ifndef BOOST_NUMERIC_UBLAS_OPERATION_BEGIN_HPP
Chris@16 18 #define BOOST_NUMERIC_UBLAS_OPERATION_BEGIN_HPP
Chris@16 19
Chris@16 20
Chris@16 21 #include <boost/numeric/ublas/expression_types.hpp>
Chris@16 22 #include <boost/numeric/ublas/fwd.hpp>
Chris@16 23 #include <boost/numeric/ublas/traits/const_iterator_type.hpp>
Chris@16 24 #include <boost/numeric/ublas/traits/iterator_type.hpp>
Chris@16 25
Chris@16 26
Chris@16 27 namespace boost { namespace numeric { namespace ublas {
Chris@16 28
Chris@16 29 namespace detail {
Chris@16 30
Chris@16 31 /**
Chris@16 32 * \brief Auxiliary class for implementing the \c begin operation.
Chris@16 33 * \tparam CategoryT The expression category type (e.g., vector_tag).
Chris@16 34 * \tparam TagT The dimension type tag (e.g., tag::major).
Chris@16 35 * \tparam OrientationT The orientation category type (e.g., row_major_tag).
Chris@16 36 */
Chris@16 37 template <typename CategoryT, typename TagT=void, typename OrientationT=void>
Chris@16 38 struct begin_impl;
Chris@16 39
Chris@16 40
Chris@16 41 /// \brief Specialization of \c begin_impl for iterating vector expressions.
Chris@16 42 template <>
Chris@16 43 struct begin_impl<vector_tag,void,void>
Chris@16 44 {
Chris@16 45 /**
Chris@16 46 * \brief Return an iterator to the first element of the given vector
Chris@16 47 * expression.
Chris@16 48 * \tparam ExprT A model of VectorExpression type.
Chris@16 49 * \param e A vector expression.
Chris@16 50 * \return An iterator over the given vector expression.
Chris@16 51 */
Chris@16 52 template <typename ExprT>
Chris@16 53 static typename ExprT::iterator apply(ExprT& e)
Chris@16 54 {
Chris@16 55 return e.begin();
Chris@16 56 }
Chris@16 57
Chris@16 58
Chris@16 59 /**
Chris@16 60 * \brief Return a const iterator to the first element of the given vector
Chris@16 61 * expression.
Chris@16 62 * \tparam ExprT A model of VectorExpression type.
Chris@16 63 * \param e A vector expression.
Chris@16 64 * \return A const iterator to the first element of the given vector
Chris@16 65 * expression.
Chris@16 66 */
Chris@16 67 template <typename ExprT>
Chris@16 68 static typename ExprT::const_iterator apply(ExprT const& e)
Chris@16 69 {
Chris@16 70 return e.begin();
Chris@16 71 }
Chris@16 72 };
Chris@16 73
Chris@16 74
Chris@16 75 /// \brief Specialization of \c begin_impl for iterating matrix expressions with
Chris@16 76 /// a row-major orientation over the major dimension.
Chris@16 77 template <>
Chris@16 78 struct begin_impl<matrix_tag,tag::major,row_major_tag>
Chris@16 79 {
Chris@16 80 /**
Chris@16 81 * \brief Return an iterator to the first element of the given row-major
Chris@16 82 * matrix expression over the major dimension.
Chris@16 83 * \tparam ExprT A model of MatrixExpression type.
Chris@16 84 * \param e A matrix expression.
Chris@16 85 * \return An iterator over the major dimension of the given matrix
Chris@16 86 * expression.
Chris@16 87 */
Chris@16 88 template <typename ExprT>
Chris@16 89 static typename ExprT::iterator1 apply(ExprT& e)
Chris@16 90 {
Chris@16 91 return e.begin1();
Chris@16 92 }
Chris@16 93
Chris@16 94
Chris@16 95 /**
Chris@16 96 * \brief Return a const iterator to the first element of the given
Chris@16 97 * row-major matrix expression over the major dimension.
Chris@16 98 * \tparam ExprT A model of MatrixExpression type.
Chris@16 99 * \param e A matrix expression.
Chris@16 100 * \return A const iterator over the major dimension of the given matrix
Chris@16 101 * expression.
Chris@16 102 */
Chris@16 103 template <typename ExprT>
Chris@16 104 static typename ExprT::const_iterator1 apply(ExprT const& e)
Chris@16 105 {
Chris@16 106 return e.begin1();
Chris@16 107 }
Chris@16 108 };
Chris@16 109
Chris@16 110
Chris@16 111 /// \brief Specialization of \c begin_impl for iterating matrix expressions with
Chris@16 112 /// a column-major orientation over the major dimension.
Chris@16 113 template <>
Chris@16 114 struct begin_impl<matrix_tag,tag::major,column_major_tag>
Chris@16 115 {
Chris@16 116 /**
Chris@16 117 * \brief Return an iterator to the first element of the given column-major
Chris@16 118 * matrix expression over the major dimension.
Chris@16 119 * \tparam ExprT A model of MatrixExpression type.
Chris@16 120 * \param e A matrix expression.
Chris@16 121 * \return An iterator over the major dimension of the given matrix
Chris@16 122 * expression.
Chris@16 123 */
Chris@16 124 template <typename ExprT>
Chris@16 125 static typename ExprT::iterator2 apply(ExprT& e)
Chris@16 126 {
Chris@16 127 return e.begin2();
Chris@16 128 }
Chris@16 129
Chris@16 130
Chris@16 131 /**
Chris@16 132 * \brief Return a const iterator to the first element of the given
Chris@16 133 * column-major matrix expression over the major dimension.
Chris@16 134 * \tparam ExprT A model of MatrixExpression type.
Chris@16 135 * \param e A matrix expression.
Chris@16 136 * \return A const iterator over the major dimension of the given matrix
Chris@16 137 * expression.
Chris@16 138 */
Chris@16 139 template <typename ExprT>
Chris@16 140 static typename ExprT::const_iterator2 apply(ExprT const& e)
Chris@16 141 {
Chris@16 142 return e.begin2();
Chris@16 143 }
Chris@16 144 };
Chris@16 145
Chris@16 146
Chris@16 147 /// \brief Specialization of \c begin_impl for iterating matrix expressions with
Chris@16 148 /// a row-major orientation over the minor dimension.
Chris@16 149 template <>
Chris@16 150 struct begin_impl<matrix_tag,tag::minor,row_major_tag>
Chris@16 151 {
Chris@16 152 /**
Chris@16 153 * \brief Return an iterator to the first element of the given row-major
Chris@16 154 * matrix expression over the minor dimension.
Chris@16 155 * \tparam ExprT A model of MatrixExpression type.
Chris@16 156 * \param e A matrix expression.
Chris@16 157 * \return An iterator over the minor dimension of the given matrix
Chris@16 158 * expression.
Chris@16 159 */
Chris@16 160 template <typename ExprT>
Chris@16 161 static typename ExprT::iterator2 apply(ExprT& e)
Chris@16 162 {
Chris@16 163 return e.begin2();
Chris@16 164 }
Chris@16 165
Chris@16 166
Chris@16 167 /**
Chris@16 168 * \brief Return a const iterator to the first element of the given
Chris@16 169 * row-major matrix expression over the minor dimension.
Chris@16 170 * \tparam ExprT A model of MatrixExpression type.
Chris@16 171 * \param e A matrix expression.
Chris@16 172 * \return A const iterator over the minor dimension of the given matrix
Chris@16 173 * expression.
Chris@16 174 */
Chris@16 175 template <typename ExprT>
Chris@16 176 static typename ExprT::const_iterator2 apply(ExprT const& e)
Chris@16 177 {
Chris@16 178 return e.begin2();
Chris@16 179 }
Chris@16 180 };
Chris@16 181
Chris@16 182
Chris@16 183
Chris@16 184 /// \brief Specialization of \c begin_impl for iterating matrix expressions with
Chris@16 185 /// a column-major orientation over the minor dimension.
Chris@16 186 template <>
Chris@16 187 struct begin_impl<matrix_tag,tag::minor,column_major_tag>
Chris@16 188 {
Chris@16 189 /**
Chris@16 190 * \brief Return an iterator to the first element of the given column-major
Chris@16 191 * matrix expression over the minor dimension.
Chris@16 192 * \tparam ExprT A model of MatrixExpression type.
Chris@16 193 * \param e A matrix expression.
Chris@16 194 * \return An iterator over the minor dimension of the given matrix
Chris@16 195 * expression.
Chris@16 196 */
Chris@16 197 template <typename ExprT>
Chris@16 198 static typename ExprT::iterator1 apply(ExprT& e)
Chris@16 199 {
Chris@16 200 return e.begin1();
Chris@16 201 }
Chris@16 202
Chris@16 203
Chris@16 204 /**
Chris@16 205 * \brief Return a const iterator to the first element of the given
Chris@16 206 * column-major matrix expression over the minor dimension.
Chris@16 207 * \tparam ExprT A model of MatrixExpression type.
Chris@16 208 * \param e A matrix expression.
Chris@16 209 * \return A const iterator over the minor dimension of the given matrix
Chris@16 210 * expression.
Chris@16 211 */
Chris@16 212 template <typename ExprT>
Chris@16 213 static typename ExprT::const_iterator1 apply(ExprT const& e)
Chris@16 214 {
Chris@16 215 return e.begin1();
Chris@16 216 }
Chris@16 217 };
Chris@16 218
Chris@16 219 } // Namespace detail
Chris@16 220
Chris@16 221
Chris@16 222 /**
Chris@16 223 * \brief An iterator to the first element of the given vector expression.
Chris@16 224 * \tparam ExprT A model of VectorExpression type.
Chris@16 225 * \param e A vector expression.
Chris@16 226 * \return An iterator to the first element of the given vector expression.
Chris@16 227 */
Chris@16 228 template <typename ExprT>
Chris@16 229 BOOST_UBLAS_INLINE
Chris@16 230 typename ExprT::iterator begin(vector_expression<ExprT>& e)
Chris@16 231 {
Chris@16 232 return detail::begin_impl<typename ExprT::type_category>::apply(e());
Chris@16 233 }
Chris@16 234
Chris@16 235
Chris@16 236 /**
Chris@16 237 * \brief A const iterator to the first element of the given vector expression.
Chris@16 238 * \tparam ExprT A model of VectorExpression type.
Chris@16 239 * \param e A vector expression.
Chris@16 240 * \return A const iterator to the first element of the given vector expression.
Chris@16 241 */
Chris@16 242 template <typename ExprT>
Chris@16 243 BOOST_UBLAS_INLINE
Chris@16 244 typename ExprT::const_iterator begin(vector_expression<ExprT> const& e)
Chris@16 245 {
Chris@16 246 return detail::begin_impl<typename ExprT::type_category>::apply(e());
Chris@16 247 }
Chris@16 248
Chris@16 249
Chris@16 250 /**
Chris@16 251 * \brief An iterator to the first element of the given matrix expression
Chris@16 252 * according to its orientation.
Chris@16 253 * \tparam DimTagT A dimension tag type (e.g., tag::major).
Chris@16 254 * \tparam ExprT A model of MatrixExpression type.
Chris@16 255 * \param e A matrix expression.
Chris@16 256 * \return An iterator to the first element of the given matrix expression
Chris@16 257 * according to its orientation.
Chris@16 258 */
Chris@16 259 template <typename TagT, typename ExprT>
Chris@16 260 BOOST_UBLAS_INLINE
Chris@16 261 typename iterator_type<ExprT,TagT>::type begin(matrix_expression<ExprT>& e)
Chris@16 262 {
Chris@16 263 return detail::begin_impl<typename ExprT::type_category, TagT, typename ExprT::orientation_category>::apply(e());
Chris@16 264 }
Chris@16 265
Chris@16 266
Chris@16 267 /**
Chris@16 268 * \brief A const iterator to the first element of the given matrix expression
Chris@16 269 * according to its orientation.
Chris@16 270 * \tparam TagT A dimension tag type (e.g., tag::major).
Chris@16 271 * \tparam ExprT A model of MatrixExpression type.
Chris@16 272 * \param e A matrix expression.
Chris@16 273 * \return A const iterator to the first element of the given matrix expression
Chris@16 274 * according to its orientation.
Chris@16 275 */
Chris@16 276 template <typename TagT, typename ExprT>
Chris@16 277 BOOST_UBLAS_INLINE
Chris@16 278 typename const_iterator_type<ExprT,TagT>::type begin(matrix_expression<ExprT> const& e)
Chris@16 279 {
Chris@16 280 return detail::begin_impl<typename ExprT::type_category, TagT, typename ExprT::orientation_category>::apply(e());
Chris@16 281 }
Chris@16 282
Chris@16 283
Chris@16 284 /**
Chris@16 285 * \brief An iterator to the first element over the dual dimension of the given
Chris@16 286 * iterator.
Chris@16 287 * \tparam IteratorT A model of Iterator type.
Chris@16 288 * \param it An iterator.
Chris@16 289 * \return An iterator to the first element over the dual dimension of the given
Chris@16 290 * iterator.
Chris@16 291 */
Chris@16 292 template <typename IteratorT>
Chris@16 293 BOOST_UBLAS_INLINE
Chris@16 294 typename IteratorT::dual_iterator_type begin(IteratorT& it)
Chris@16 295 {
Chris@16 296 return it.begin();
Chris@16 297 }
Chris@16 298
Chris@16 299
Chris@16 300 /**
Chris@16 301 * \brief A const iterator to the first element over the dual dimension of the
Chris@16 302 * given iterator.
Chris@16 303 * \tparam IteratorT A model of Iterator type.
Chris@16 304 * \param it An iterator.
Chris@16 305 * \return A const iterator to the first element over the dual dimension of the
Chris@16 306 * given iterator.
Chris@16 307 */
Chris@16 308 template <typename IteratorT>
Chris@16 309 BOOST_UBLAS_INLINE
Chris@16 310 typename IteratorT::dual_iterator_type begin(IteratorT const& it)
Chris@16 311 {
Chris@16 312 return it.begin();
Chris@16 313 }
Chris@16 314
Chris@16 315 }}} // Namespace boost::numeric::ublas
Chris@16 316
Chris@16 317
Chris@16 318 #endif // BOOST_NUMERIC_UBLAS_OPERATION_BEGIN_HPP