Commit 97d5b3ca authored by Paul's avatar Paul
Browse files

Formatting

parent 86576438
......@@ -5,10 +5,10 @@
namespace rtg {
template<bool... Bs>
struct and_
: std::is_same<and_<Bs...>, and_<(Bs || true)...>>
{};
template <bool... Bs>
struct and_ : std::is_same<and_<Bs...>, and_<(Bs || true)...>>
{
};
#define RTG_REQUIRES(...) class = typename std::enable_if<and_<__VA_ARGS__, true>{}>::type
......
......@@ -62,7 +62,7 @@ struct shape
std::size_t index(std::initializer_list<std::size_t> l) const;
std::size_t index(const std::vector<std::size_t>& l) const;
template<class Iterator>
template <class Iterator>
std::size_t index(Iterator start, Iterator last) const
{
assert(std::distance(start, last) <= this->lens().size());
......
......@@ -6,13 +6,14 @@
namespace rtg {
template<class F>
template <class F>
void shape_for_each(const rtg::shape& s, F f)
{
// Ensure calls to f use const ref to vector
auto call = [&f](const std::vector<std::size_t>& i) { f(i); };
std::vector<std::size_t> indices(s.lens().size());
for(std::size_t i = 0;i < s.elements();i++) {
for(std::size_t i = 0; i < s.elements(); i++)
{
std::transform(s.strides().begin(),
s.strides().end(),
s.lens().begin(),
......@@ -22,7 +23,6 @@ void shape_for_each(const rtg::shape& s, F f)
}
}
} // namespace rtg
#endif
......@@ -63,8 +63,10 @@ std::size_t shape::index(const std::vector<std::size_t>& l) const
std::size_t shape::index(std::size_t i) const
{
assert(this->lens().size() == this->strides().size());
if (this->packed()) return i;
else return std::inner_product(
if(this->packed())
return i;
else
return std::inner_product(
this->lens().begin(),
this->lens().end(),
this->strides().begin(),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment