Skip to content

Commit

Permalink
revert stride computation for vectors.
Browse files Browse the repository at this point in the history
  • Loading branch information
bassoy committed May 28, 2023
1 parent 50e19e5 commit 997df31
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 20 deletions.
4 changes: 2 additions & 2 deletions include/boost/numeric/ublas/tensor/dynamic_strides.hpp
Expand Up @@ -83,8 +83,8 @@ class basic_strides
if( !valid(n) )
throw std::runtime_error("Error in boost::numeric::ublas::basic_strides() : shape is not valid.");

// if( is_vector(s) || is_scalar(s) ) /* */
// return;
if( is_vector(n) || is_scalar(n) ) /* */
return;

const auto p = this->size();

Expand Down
11 changes: 3 additions & 8 deletions include/boost/numeric/ublas/tensor/extents/extents_functions.hpp
Expand Up @@ -184,11 +184,9 @@ template<integral T, class L>
{
auto s = typename extents_core<T>::base_type(e.size(),1ul);

if(empty(e) || is_scalar(e)){
if(empty(e) || is_scalar(e) || is_vector(e)){
return s;
}

// || is_vector(e)
}

if constexpr(std::is_same_v<L,layout::first_order>){
std::transform(begin (e), end (e) - 1, s.begin (), s.begin ()+1, std::multiplies<>{});
Expand All @@ -204,13 +202,10 @@ template<integral T, T n, class L>
auto s = typename extents_core<T,n>::base_type{};
std::fill(s.begin(),s.end(),1ul);

if(empty(e) || is_scalar(e)){
if(empty(e) || is_scalar(e) || is_vector(e)){
return s;
}


// || is_vector(e)

if constexpr(std::is_same_v<L,layout::first_order>){
std::transform(begin (e), end (e) - 1, s.begin (), s.begin ()+1, std::multiplies<>{});
} else {
Expand Down
2 changes: 1 addition & 1 deletion test/tensor/Jamfile
Expand Up @@ -90,7 +90,7 @@ test-suite boost-ublas-tensor-test
#
test_access.cpp
test_einstein_notation.cpp
test_main.cpp
# test_main.cpp
test_multi_index.cpp
test_multi_index_utility.cpp
test_span.cpp
Expand Down
2 changes: 1 addition & 1 deletion test/tensor/algorithm/test_algorithm_trans.cpp
Expand Up @@ -219,7 +219,7 @@ constexpr auto generate_permuated_extents() noexcept{
constexpr auto sz = ublas::size_v<E>;


constexpr auto helper = []<std::size_t... Is>(std::index_sequence<Is...> ids){
constexpr auto helper = []<std::size_t... Is>(std::index_sequence<Is...> /*ids*/){
constexpr auto helper1 = [](){
std::array<std::size_t,sz> pi;
(( pi[sz - Is - 1ul] = ublas::get_v<E,Is> ),...);
Expand Down
4 changes: 2 additions & 2 deletions test/tensor/multiplication/test_multiplication_mtv.cpp
Expand Up @@ -214,9 +214,9 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(test_extents_static,
std::fill(std::begin(b), std::end(b), value_type{1});

using nc_type = decltype( generate_result_extents<extents_type, rank, m>() );
auto nc = ublas::to_array_v<nc_type>;
//auto nc = ublas::to_array_v<nc_type>;
// FIXME: use strides_v after the fix
auto wc = get_strides<layout_type>(nc);
// auto wc = get_strides<layout_type>(nc);
auto c = std::array<value_type, ublas::product_v<nc_type> >();
std::fill(std::begin(c), std::end(c), value_type{0});

Expand Down
12 changes: 6 additions & 6 deletions test/tensor/test_access.cpp
Expand Up @@ -238,12 +238,12 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE( test_compute_multi_index, layout_t, layout_ty
auto const& ii = iref[kk];
auto i = multi_index_t(w.size());
ub::detail::compute_multi_index(jj, w.begin(), w.end(), i.begin(), layout_t{});
// std::cout << "j= " << jj << std::endl;
// std::cout << "i= [ "; for(auto iii : i) std::cout << iii << " "; std::cout << "];" << std::endl;
// std::cout << "ii_ref = [ "; for(auto iii : ii) std::cout << iii << " "; std::cout << "];" << std::endl;
// std::cout << "n= [ "; for(auto iii : n) std::cout << iii << " "; std::cout << "];" << std::endl;
// std::cout << "w= [ "; for(auto iii : w) std::cout << iii << " "; std::cout << "];" << std::endl;
// std::cout << std::endl;
std::cout << "j= " << jj << std::endl;
std::cout << "i= [ "; for(auto iii : i) std::cout << iii << " "; std::cout << "];" << std::endl;
std::cout << "ii_ref = [ "; for(auto iii : ii) std::cout << iii << " "; std::cout << "];" << std::endl;
std::cout << "n= [ "; for(auto iii : n) std::cout << iii << " "; std::cout << "];" << std::endl;
std::cout << "w= [ "; for(auto iii : w) std::cout << iii << " "; std::cout << "];" << std::endl;
std::cout << std::endl;
BOOST_CHECK ( std::equal(i.begin(),i.end(),ii.begin()) ) ;
}
}
Expand Down

0 comments on commit 997df31

Please sign in to comment.