Skip to content

Commit

Permalink
create and use col_ct, row_ct and dim_ct
Browse files Browse the repository at this point in the history
  • Loading branch information
bebuch committed Dec 15, 2016
1 parent c0b535d commit e0b9aa7
Show file tree
Hide file tree
Showing 55 changed files with 2,972 additions and 2,928 deletions.
4 changes: 2 additions & 2 deletions benchmark/benchmark/binary_op/size/Eigen_ct_stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ void bm(benchmark::State& state, Op op, D1, D2){

using namespace Eigen;

Matrix< T, D1::ct_rows, D1::ct_cols > m1;
Matrix< T, size_t(D1::ct_rows), size_t(D1::ct_cols) > m1;
for(int y = 0; y < m1.rows(); ++y){
for(int x = 0; x < m1.cols(); ++x){
m1(y, x) = dis(gen);
}
}

Matrix< T, D2::ct_rows, D2::ct_cols > m2;
Matrix< T, size_t(D2::ct_rows), size_t(D2::ct_cols) > m2;
for(int y = 0; y < m2.rows(); ++y){
for(int x = 0; x < m2.cols(); ++x){
m2(y, x) = dis(gen);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ int main(int argc, char** argv) {
using f4 = float;
using f8 = double;

using dt = auto_dim_pair_t< 0, 0 >;
using dt = auto_dim_pair_t< 0_C, 0_R >;

for(auto& d: std::vector< dt >{
{1024_cd, 1024_rd}
Expand Down
2 changes: 1 addition & 1 deletion benchmark/benchmark/make/constant_value/Eigen_ct_stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ template < typename T, typename D >
[[gnu::noinline]]
void bm(benchmark::State& state, T v, D){
while(state.KeepRunning()){
Eigen::Matrix< T, D::ct_rows, D::ct_cols > m;
Eigen::Matrix< T, size_t(D::ct_rows), size_t(D::ct_cols) > m;
m.fill(v);

benchmark::DoNotOptimize(m);
Expand Down
3 changes: 2 additions & 1 deletion benchmark/benchmark/make/random_value/Eigen_ct_stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ void bm(benchmark::State& state, D d){
auto r = mitrax::random_vector< T >(d.point_count());

while(state.KeepRunning()){
auto m = Eigen::Matrix< T, D::ct_rows, D::ct_cols >(r.data());
auto m = Eigen::Matrix< T, size_t(D::ct_rows), size_t(D::ct_cols) >(
r.data());

benchmark::DoNotOptimize(m);
}
Expand Down
2 changes: 1 addition & 1 deletion benchmark/include/Eigen/convert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace mitrax{
});
}

template < typename M, size_t C, size_t R >
template < typename M, col_ct C, row_ct R >
constexpr auto convert(matrix< M, C, R > const& m){
Eigen::Matrix<
value_type_t< M >,
Expand Down
2 changes: 1 addition & 1 deletion benchmark/include/uBLAS/convert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace mitrax{
});
}

template < typename M, size_t C, size_t R >
template < typename M, col_ct C, row_ct R >
constexpr auto convert(matrix< M, C, R > const& m){
ublas::matrix< value_type_t< M > > res(size_t(m.cols()), size_t(m.rows()));

Expand Down
4 changes: 2 additions & 2 deletions include/mitrax/area_search.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace mitrax{


template < bool Cct, size_t C, bool Rct, size_t R, typename F >
template < bool Cct, col_ct C, bool Rct, row_ct R, typename F >
constexpr bool square_area_search(
col_t< Cct, C > c,
row_t< Rct, R > r,
Expand Down Expand Up @@ -63,7 +63,7 @@ namespace mitrax{
return false;
}

template < bool Cct, size_t C, bool Rct, size_t R, typename F >
template < bool Cct, col_ct C, bool Rct, row_ct R, typename F >
constexpr bool square_area_search(
dim_pair_t< Cct, C, Rct, R > const& dims,
size_t x, size_t y,
Expand Down
12 changes: 6 additions & 6 deletions include/mitrax/compare.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ namespace mitrax{


template <
typename M1, size_t C1, size_t R1,
typename M2, size_t C2, size_t R2
typename M1, col_ct C1, row_ct R1,
typename M2, col_ct C2, row_ct R2
> constexpr bool operator==(
matrix< M1, C1, R1 > const& m1,
matrix< M2, C2, R2 > const& m2
){
auto size = get_dims(m2, m1);

for(size_t y = 0; y < size.rows(); ++y){
for(size_t x = 0; x < size.cols(); ++x){
for(size_t y = 0; y < size_t(size.rows()); ++y){
for(size_t x = 0; x < size_t(size.cols()); ++x){
if(m1(x, y) != m2(x, y)) return false;
}
}
Expand All @@ -36,8 +36,8 @@ namespace mitrax{
}

template <
typename M1, size_t C1, size_t R1,
typename M2, size_t C2, size_t R2
typename M1, col_ct C1, row_ct R1,
typename M2, col_ct C2, row_ct R2
> constexpr bool operator!=(
matrix< M1, C1, R1 > const& m1,
matrix< M2, C2, R2 > const& m2
Expand Down
36 changes: 18 additions & 18 deletions include/mitrax/convert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ namespace mitrax{


template <
typename T, bool Cct1, size_t C1, bool Rct1, size_t R1,
typename M, size_t C2, size_t R2
typename T, bool Cct1, col_ct C1, bool Rct1, row_ct R1,
typename M, col_ct C2, row_ct R2
> constexpr auto convert(
matrix< M, C2, R2 >& m,
col_t< Cct1, C1 > c,
Expand All @@ -49,8 +49,8 @@ namespace mitrax{
}

template <
typename T, bool Cct1, size_t C1, bool Rct1, size_t R1,
typename M, size_t C2, size_t R2
typename T, bool Cct1, col_ct C1, bool Rct1, row_ct R1,
typename M, col_ct C2, row_ct R2
> constexpr auto convert(
matrix< M, C2, R2 > const& m,
col_t< Cct1, C1 > c,
Expand All @@ -60,8 +60,8 @@ namespace mitrax{
}

template <
typename T, bool Cct1, size_t C1, bool Rct1, size_t R1,
typename M, size_t C2, size_t R2
typename T, bool Cct1, col_ct C1, bool Rct1, row_ct R1,
typename M, col_ct C2, row_ct R2
> constexpr auto convert(
matrix< M, C2, R2 >&& m,
col_t< Cct1, C1 > c,
Expand All @@ -73,8 +73,8 @@ namespace mitrax{


template <
bool Cct1, size_t C1, bool Rct1, size_t R1,
typename M, size_t C2, size_t R2
bool Cct1, col_ct C1, bool Rct1, row_ct R1,
typename M, col_ct C2, row_ct R2
> constexpr auto convert(
matrix< M, C2, R2 >& m,
col_t< Cct1, C1 > c,
Expand All @@ -85,8 +85,8 @@ namespace mitrax{
}

template <
bool Cct1, size_t C1, bool Rct1, size_t R1,
typename M, size_t C2, size_t R2
bool Cct1, col_ct C1, bool Rct1, row_ct R1,
typename M, col_ct C2, row_ct R2
> constexpr auto convert(
matrix< M, C2, R2 > const& m,
col_t< Cct1, C1 > c,
Expand All @@ -97,8 +97,8 @@ namespace mitrax{
}

template <
bool Cct1, size_t C1, bool Rct1, size_t R1,
typename M, size_t C2, size_t R2
bool Cct1, col_ct C1, bool Rct1, row_ct R1,
typename M, col_ct C2, row_ct R2
> constexpr auto convert(
matrix< M, C2, R2 >&& m,
col_t< Cct1, C1 > c,
Expand All @@ -108,35 +108,35 @@ namespace mitrax{
detail::make_convert_fn< value_type_t< M > >(std::move(m)));
}

template < typename T, typename M, size_t C, size_t R >
template < typename T, typename M, col_ct C, row_ct R >
constexpr auto convert(matrix< M, C, R >& m){
return make_matrix_fn(m.dims(), detail::make_convert_fn< T >(m));
}

template < typename T, typename M, size_t C, size_t R >
template < typename T, typename M, col_ct C, row_ct R >
constexpr auto convert(matrix< M, C, R > const& m){
return make_matrix_fn(m.dims(), detail::make_convert_fn< T >(m));
}

template < typename T, typename M, size_t C, size_t R >
template < typename T, typename M, col_ct C, row_ct R >
constexpr auto convert(matrix< M, C, R >&& m){
return make_matrix_fn(m.dims(),
detail::make_convert_fn< T >(std::move(m)));
}

template < typename M, size_t C, size_t R >
template < typename M, col_ct C, row_ct R >
constexpr auto as_std_matrix(matrix< M, C, R >& m){
return make_matrix_fn(m.dims(),
detail::make_convert_fn< value_type_t< M > >(m));
}

template < typename M, size_t C, size_t R >
template < typename M, col_ct C, row_ct R >
constexpr auto as_std_matrix(matrix< M, C, R > const& m){
return make_matrix_fn(m.dims(),
detail::make_convert_fn< value_type_t< M > >(m));
}

template < typename M, size_t C, size_t R >
template < typename M, col_ct C, row_ct R >
constexpr auto as_std_matrix(matrix< M, C, R >&& m){
return make_matrix_fn(m.dims(),
detail::make_convert_fn< value_type_t< M > >(std::move(m)));
Expand Down
26 changes: 13 additions & 13 deletions include/mitrax/convolution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ namespace mitrax{


template <
typename M1, size_t C1, size_t R1,
typename M2, size_t C2, size_t R2,
typename M1, col_ct C1, row_ct R1,
typename M2, col_ct C2, row_ct R2,
typename SumOp, typename MulOp
> struct convolution_worker{
constexpr auto operator()(size_t x, size_t y)const{
auto v = std::decay_t< decltype(
sum(mul(i(0, 0), m(0, 0)), mul(i(0, 0), m(0, 0)))) >();
for(size_t b = 0; b < m.rows(); ++b){
for(size_t a = 0; a < m.cols(); ++a){
for(size_t b = 0; b < size_t(m.rows()); ++b){
for(size_t a = 0; a < size_t(m.cols()); ++a){
v = sum(v, mul(i(x + a, y + b), m(a, b)));
}
}
Expand All @@ -45,8 +45,8 @@ namespace mitrax{


template <
typename M1, size_t C1, size_t R1,
typename M2, size_t C2, size_t R2,
typename M1, col_ct C1, row_ct R1,
typename M2, col_ct C2, row_ct R2,
typename SumOp = std::plus<>,
typename MulOp = std::multiplies<>
> constexpr auto convolution(
Expand All @@ -56,8 +56,8 @@ namespace mitrax{
MulOp const& mul = std::multiplies<>()
){
static_assert(
(C1 == 0 || C2 == 0 || C1 >= C2) &&
(R1 == 0 || R2 == 0 || R1 >= R2),
(C1 == 0_C || C2 == 0_C || C1 >= C2) &&
(R1 == 0_R || R2 == 0_R || R1 >= R2),
"convolution matrix is bigger then image"
);

Expand All @@ -66,18 +66,18 @@ namespace mitrax{
}

return make_matrix_fn(
cols< 1 >() + i.cols() - m.cols(),
rows< 1 >() + i.rows() - m.rows(),
1_c + i.cols() - m.cols(),
1_r + i.rows() - m.rows(),
detail::convolution_worker< M1, C1, R1, M2, C2, R2, SumOp, MulOp >{
i, m, sum, mul
});
}


template <
typename M1, size_t C1, size_t R1,
typename M2, size_t R2,
typename M3, size_t C3,
typename M1, col_ct C1, row_ct R1,
typename M2, row_ct R2,
typename M3, col_ct C3,
typename SumOp = std::plus<>,
typename MulOp = std::multiplies<>
> constexpr auto convolution(
Expand Down
Loading

0 comments on commit e0b9aa7

Please sign in to comment.