yat  0.14.5pre
KernelMatrix.h
1 #ifndef _theplu_yat_utility_kernel_matrix_
2 #define _theplu_yat_utility_kernel_matrix_
3 
4 // $Id: KernelMatrix.h 3190 2014-03-30 07:47:40Z peter $
5 
6 /*
7  Copyright (C) 2014 Peter Johansson
8 
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10 
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15 
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with yat. If not, see <http://www.gnu.org/licenses/>.
23 */
24 
25 #include "Container2DIterator.h"
26 #include "StrideIterator.h"
27 
28 namespace theplu {
29 namespace yat {
30 namespace utility {
31 
63  template <class RandomAccessRange1, class RandomAccessRange2,
64  class BinaryFunctor>
66  {
67  public:
69  typedef typename BinaryFunctor::result_type value_type;
70 
73 
77 
80 
83 
90  KernelMatrix(const RandomAccessRange1& r1, const RandomAccessRange2& r2)
91  : range1_(r1), range2_(r2) {}
92 
96  KernelMatrix(const RandomAccessRange1& r1, const RandomAccessRange2& r2,
97  const BinaryFunctor& bf)
98  : range1_(r1), range2_(r2), func_(bf) {}
99 
106  const_iterator begin(void) const { return const_iterator(*this, 0, 0); }
107 
108 
114  const_column_iterator begin_column(size_t column) const
115  {
116  return const_column_iterator(const_iterator(*this, 0, column),
117  this->columns());
118  }
119 
120 
126  const_row_iterator begin_row(size_t row) const
127  { return const_row_iterator(*this, row, 0); }
128 
129 
133  const_iterator end(void) const
134  { return const_iterator(*this, rows(), 0); }
135 
136 
140  const_column_iterator end_column(size_t column) const
141  {
142  return const_column_iterator(const_iterator(*this, this->rows(), column),
143  this->columns());
144  }
145 
146 
150  const_row_iterator end_row(size_t row) const
151  { return const_row_iterator(*this, row, this->columns()); }
152 
153 
159  typename RandomAccessRange2::size_type columns(void) const
160  { return range2_.size(); }
161 
162 
168  typename RandomAccessRange1::size_type rows(void) const
169  { return range1_.size(); }
170 
171 
181  const_reference operator()(size_t row, size_t column) const
182  { return func_(range1_[row], range2_[column]); }
183 
184  private:
185  RandomAccessRange1 range1_;
186  RandomAccessRange2 range2_;
187  BinaryFunctor func_;
188  };
189 
190 }}} // of namespace utility, yat, and theplu
191 
192 #endif
KernelMatrix(const RandomAccessRange1 &r1, const RandomAccessRange2 &r2)
constructor
Definition: KernelMatrix.h:90
const_iterator begin(void) const
Definition: KernelMatrix.h:106
const_iterator end(void) const
Definition: KernelMatrix.h:133
Container2DIterator< const KernelMatrix, value_type, const_reference > const_iterator
const_iterator
Definition: KernelMatrix.h:76
const_column_iterator end_column(size_t column) const
Definition: KernelMatrix.h:140
const_iterator const_row_iterator
const_row_iterator_iterator
Definition: KernelMatrix.h:82
Iterator for a Container2D.
Definition: Container2DIterator.h:61
const_column_iterator begin_column(size_t column) const
Definition: KernelMatrix.h:114
StrideIterator< const_iterator > const_column_iterator
const_column_iterator
Definition: KernelMatrix.h:79
BinaryFunctor::result_type value_type
value_type is same as BinaryFunctor&#39;s result_type
Definition: KernelMatrix.h:69
value_type const_reference
const_reference is same as value_type
Definition: KernelMatrix.h:72
const_row_iterator end_row(size_t row) const
Definition: KernelMatrix.h:150
KernelMatrix(const RandomAccessRange1 &r1, const RandomAccessRange2 &r2, const BinaryFunctor &bf)
constructor
Definition: KernelMatrix.h:96
const_row_iterator begin_row(size_t row) const
Definition: KernelMatrix.h:126
RandomAccessRange1::size_type rows(void) const
Definition: KernelMatrix.h:168
const_reference operator()(size_t row, size_t column) const
Element access operator.
Definition: KernelMatrix.h:181
RandomAccessRange2::size_type columns(void) const
Definition: KernelMatrix.h:159
A KernelMatrix is a Container2D.
Definition: KernelMatrix.h:65
Adaptor using a stride on underlying iterator.
Definition: StrideIterator.h:50

Generated on Tue Sep 26 2017 02:33:29 for yat by  doxygen 1.8.5