00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef MTL_DIM_SPLITTER_INCLUDE
00013 #define MTL_DIM_SPLITTER_INCLUDE
00014
00015 #include <algorithm>
00016 #include <boost/numeric/mtl/recursion/utility.hpp>
00017
00018 namespace mtl { namespace recursion {
00019
00020
00021 template <typename Matrix>
00022 struct half_splitter
00023 {
00024 typedef typename Matrix::size_type size_type;
00025
00026 explicit half_splitter(Matrix const& matrix)
00027 {
00028 size_type nr= matrix.num_rows(), nc= matrix.num_cols();
00029 nr-= nr / 2;
00030 nc-= nc / 2;
00031 my_row_split= matrix.begin_row() + nr;
00032 my_col_split= matrix.begin_col() + nc;
00033 }
00034
00035
00036 size_type row_split() const
00037 {
00038 return my_row_split;
00039 }
00040
00041
00042 size_type col_split() const
00043 {
00044 return my_col_split;
00045 }
00046
00047 private:
00048 size_type my_row_split, my_col_split;
00049 };
00050
00051
00052
00053
00054 template <typename Matrix>
00055 struct separate_dim_splitter
00056 {
00057 typedef typename Matrix::size_type size_type;
00058
00059 explicit separate_dim_splitter(Matrix const& matrix)
00060 : my_row_split(matrix.begin_row() + first_part(matrix.num_rows())),
00061 my_col_split(matrix.begin_col() + first_part(matrix.num_cols()))
00062 {}
00063
00064
00065 size_type row_split() const
00066 {
00067 return my_row_split;
00068 }
00069
00070
00071 size_type col_split() const
00072 {
00073 return my_col_split;
00074 }
00075
00076 private:
00077 size_type my_row_split, my_col_split;
00078 };
00079
00080
00081
00082
00083
00084 template <typename Matrix>
00085 struct max_dim_splitter
00086 {
00087 typedef typename Matrix::size_type size_type;
00088
00089 explicit max_dim_splitter(Matrix const& matrix)
00090 :
00091 my_split(std::max(first_part(matrix.num_rows()), first_part(matrix.num_cols()))),
00092 my_row_split(std::min(matrix.begin_row() + my_split, matrix.end_row())),
00093 my_col_split(std::min(matrix.begin_col() + my_split, matrix.end_col()))
00094 {}
00095
00096
00097 size_type row_split() const
00098 {
00099 return my_row_split;
00100 }
00101
00102
00103 size_type col_split() const
00104 {
00105 return my_col_split;
00106 }
00107
00108 private:
00109
00110 size_type my_split,
00111 my_row_split, my_col_split;
00112 };
00113
00114
00115
00116
00117
00118
00119
00120 template <typename Recursator>
00121 struct outer_bound_splitter
00122 {
00123 typedef typename Recursator::size_type size_type;
00124
00125 explicit outer_bound_splitter(Recursator const& recursator)
00126 {
00127 typename Recursator::matrix_type const& matrix= recursator.get_value();
00128 my_row_split= std::min(matrix.begin_row() + recursator.bound() / 2, matrix.end_row());
00129 my_col_split= std::min(matrix.begin_col() + recursator.bound() / 2, matrix.end_col());
00130 }
00131
00132
00133
00134 size_type row_split() const
00135 {
00136 return my_row_split;
00137 }
00138
00139
00140 size_type col_split() const
00141 {
00142 return my_col_split;
00143 }
00144
00145 private:
00146 size_type my_row_split, my_col_split;
00147 };
00148
00149
00150
00151 }}
00152
00153 #endif // MTL_DIM_SPLITTER_INCLUDE