// Copyright 2016 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // iterator.h: Const forward iterators for VectorMap and VectorDup that help // access data in architecture specific way, e.g. 4 elements at a time for NEON. #ifndef GEMMLOWP_INTERNAL_ITERATOR_H_ #define GEMMLOWP_INTERNAL_ITERATOR_H_ namespace gemmlowp { enum class VectorShape; // ConstIterator is a forward only constant iterator that can be made // architecture specific e.g. to return 4 values at once for NEON. template class ConstIterator { // Unused default case. }; template class VectorMap; template class ConstIterator> { public: typedef tScalar Scalar; ConstIterator(const VectorMap& vector_map) : pointer_(vector_map.data()) {} const Scalar operator*() const { return *pointer_; } const Scalar* get() const { return pointer_; } ConstIterator& operator+=(int inc) { pointer_ += inc; return *this; } private: const Scalar* pointer_; }; template ConstIterator> const_iterator( const VectorMap& vector_map) { return ConstIterator>(vector_map); } template class VectorDup; template class ConstIterator> { public: typedef tScalar Scalar; ConstIterator(const VectorDup& vector_dup) : data_(vector_dup(0)) {} const Scalar operator*() const { return data_; } const Scalar* get() const { return &data_; } ConstIterator& operator+=(int inc) { return *this; } private: Scalar data_; }; template ConstIterator> const_iterator( const VectorDup& vector_map) { return ConstIterator>(vector_map); } } // namespace gemmlowp #endif // GEMMLOWP_INTERNAL_ITERATOR_H_