Skip to content

xt::variance() bug? #85

@DavisVaughan

Description

@DavisVaughan

Any idea why this compiles without variance but not with it?

// [[Rcpp::depends(xtensorrr)]]
// [[Rcpp::plugins(cpp14)]]

#include <xtensor-r/rarray.hpp>
#include <Rcpp.h>
using namespace Rcpp;


// [[Rcpp::export]]
xt::rarray<double> xtensor_sum(xt::rarray<double> x) {
  std::vector<std::size_t> axes;
  axes.push_back(0);
  return xt::sum(x, axes);
}

// [[Rcpp::export]]
xt::rarray<double> xtensor_variance(xt::rarray<double> x) {
  std::vector<std::size_t> axes;
  axes.push_back(0);
  return xt::variance(x, axes);
}
In file included from test.cpp:4:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/xtensorrr/include/xtensor-r/rarray.hpp:17:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/xtensorrr/include/xtensor/xbuffer_adaptor.hpp:20:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/xtensorrr/include/xtensor/xstorage.hpp:21:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/xtensorrr/include/xtensor/xtensor_simd.hpp:14:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/xtensorrr/include/xtensor/xutils.hpp:1183:31: error: implicit instantiation of undefined template 'xt::rebind_container<long, xt::xbuffer_adaptor<int *, xt::no_ownership, std::__1::allocator<int> > >'
        using type = typename rebind_container<std::ptrdiff_t, S>::type;
                              ^
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/xtensorrr/include/xtensor/xutils.hpp:1196:5: note: in instantiation of template class 'xt::get_strides_type<xt::xbuffer_adaptor<int *, xt::no_ownership, std::__1::allocator<int> > >' requested here
    using get_strides_t = typename get_strides_type<C>::type;
    ^
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/xtensorrr/include/xtensor/xstrided_view.hpp:631:9: note: in instantiation of template type alias 'get_strides_t' requested here
        get_strides_t<shape_type> strides;
        ^
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/xtensorrr/include/xtensor/xmath.hpp:1919:24: note: in instantiation of function template specialization 'xt::reshape_view<xt::xfunction<xt::detail::divides, xt::xreducer<xt::xreducer_functors<std::__1::plus<double>, xtl::identity, std::__1::plus<double> >, const xt::rarray<double> &, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > >, xt::xscalar<double> >, xt::xbuffer_adaptor<int *, xt::no_ownership, std::__1::allocator<int> > >' requested here
        auto mrv = xt::reshape_view(std::move(inner_mean), std::move(keep_dim_shape));
                       ^
test.cpp:20:14: note: in instantiation of function template specialization 'xt::variance<xt::rarray<double> &, std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > &, xt::evaluation_strategy::lazy, xt::concept_check_successful>' requested here
  return xt::variance(x, axes);
             ^
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/xtensorrr/include/xtensor/xutils.hpp:80:12: note: template is declared here
    struct rebind_container;
           ^
1 error generated.
make: *** [test.o] Error 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions