Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vectorised RooLandau #1

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ba1a4fe
[RF] Change evaluatePartition interface for test statistics.
hageboeck Feb 5, 2019
0edc1cb
[RF] Initial cleanups before touching RooVectorDataStore.
hageboeck Feb 5, 2019
9aa6af2
Remove dead code in RooGaussian.
hageboeck Feb 6, 2019
7c3e29d
Fix some typos in docs.
hageboeck Feb 7, 2019
0fecdee
WIP before sed-ing RooFit::DataBatch to RooSpan.
hageboeck Feb 8, 2019
4897f28
Make pointees of span backport writable.
hageboeck Feb 15, 2019
3cd7efd
[RF] Add a RooSpan to enable batched function evaluations.
hageboeck Feb 15, 2019
4d6803a
Add vdt math function to vectorised Gaussian prototype.
hageboeck Feb 18, 2019
4852d12
Further cleanups.
hageboeck Feb 22, 2019
6f5946a
Change batch evaluation interface.
hageboeck Mar 7, 2019
f0e2732
Vectorise exponential, extend its analytical integral.
hageboeck Apr 4, 2019
07c0a77
Make Gaussian integral not return zero, but 1E-300 if it vanishes.
hageboeck Apr 4, 2019
9667252
Clean up RooAddition, RooConstraintSum of member iterators.
hageboeck Apr 4, 2019
2cedee6
Disable cout in ProdPdf, make RooUnitTest failures more informative.
hageboeck Apr 4, 2019
28ba4dd
Add `BatchMode` switch for fitTo to switch on BatchMode.
hageboeck Apr 4, 2019
8b44331
Hacky batch&vector version for RooAddPdf.
hageboeck Apr 8, 2019
39abfc0
Add Pdf-local batch storage.
hageboeck Apr 23, 2019
2183424
[Mathmore] Vectorise Kahan summation algorithm.
hageboeck May 2, 2019
4c4c36f
Fix computation errors in batch-local storage strategy.
hageboeck May 20, 2019
a6583a7
[RF] Add generic evaluateBatch to RooAbsReal.
hageboeck Jul 3, 2019
a1b489f
[RF] Change batch evaluation interface to begin+size indexing.
hageboeck Jul 8, 2019
581a13d
[RF] Vectorise error checking in RooAbsPdf.
hageboeck Jul 11, 2019
3a3c906
[RF] Prevent empty names for RooAbsArgs.
hageboeck Jul 11, 2019
2be0476
[RF] Vectorised Landau PDF
Jul 26, 2019
f2abe2d
[RF]
Jul 26, 2019
a2b8483
[RF] Merged header file into pdf source file
Jul 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 42 additions & 38 deletions core/foundation/inc/ROOT/span.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <stdexcept>
#include <memory>
#include <type_traits>
#include <vector>
#include <initializer_list>

namespace ROOT {
Expand Down Expand Up @@ -158,15 +157,16 @@ public:
/*
* types
*/
typedef T value_type;
typedef value_type const* pointer;
typedef value_type const* const_pointer;
typedef value_type const& reference;
typedef value_type const& const_reference;
typedef value_type const* iterator;
typedef value_type const* const_iterator;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T element_type;
typedef std::remove_cv<T> value_type;
typedef element_type * pointer;
typedef element_type const* const_pointer;
typedef element_type & reference;
typedef element_type const& const_reference;
typedef element_type * iterator;
typedef element_type const* const_iterator;
typedef ptrdiff_t difference_type;
typedef std::size_t index_type;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;

Expand All @@ -182,39 +182,43 @@ public:

// Note:
// This constructor can't be constexpr because & operator can't be constexpr.
template<size_type N>
template<index_type N>
/*implicit*/ span(std::array<T, N> const& a) noexcept
: length_(N), data_(N > 0 ? a.data() : nullptr)
{}

// Note:
// This constructor can't be constexpr because & operator can't be constexpr.
template<size_type N>
template<index_type N>
/*implicit*/ span(T const (& a)[N]) noexcept
: length_(N), data_(N > 0 ? std::addressof(a[0]) : nullptr)
{
static_assert(N > 0, "Zero-length array is not permitted in ISO C++.");
}

/*implicit*/ span(std::vector<T> const& v) noexcept
/*implicit*/ span(std::vector<typename std::remove_cv<T>::type> const& v) noexcept
: length_(v.size()), data_(v.empty() ? nullptr : v.data())
{}

/*implicit*/ span(std::vector<typename std::remove_cv<T>::type> & v) noexcept
: length_(v.size()), data_(v.empty() ? nullptr : v.data())
{}

/*implicit*/ constexpr span(T const* a, size_type const n) noexcept
/*implicit*/ constexpr span(pointer a, index_type const n) noexcept
: length_(n), data_(a)
{}

template<
class InputIterator,
class = typename std::enable_if<
std::is_same<
T,
typename std::remove_cv<T>::type,
typename std::iterator_traits<InputIterator>::value_type
>::value
>::type
>
explicit span(InputIterator start, InputIterator last)
: length_(std::distance(start, last)), data_(start)
span(InputIterator start, InputIterator last)
: length_(std::distance(start, last)), data_(&*start)
{}

span(std::initializer_list<T> const& l)
Expand All @@ -227,11 +231,11 @@ public:
/*
* iterator interfaces
*/
constexpr const_iterator begin() const noexcept
constexpr iterator begin() const noexcept
{
return data_;
}
constexpr const_iterator end() const noexcept
constexpr iterator end() const noexcept
{
return data_ + length_;
}
Expand All @@ -243,11 +247,11 @@ public:
{
return end();
}
const_reverse_iterator rbegin() const
reverse_iterator rbegin() const
{
return {end()};
}
const_reverse_iterator rend() const
reverse_iterator rend() const
{
return {begin()};
}
Expand All @@ -263,34 +267,34 @@ public:
/*
* access
*/
constexpr size_type size() const noexcept
constexpr index_type size() const noexcept
{
return length_;
}
constexpr size_type length() const noexcept
constexpr index_type length() const noexcept
{
return size();
}
constexpr size_type max_size() const noexcept
constexpr index_type max_size() const noexcept
{
return size();
}
constexpr bool empty() const noexcept
{
return length_ == 0;
}
constexpr const_reference operator[](size_type const n) const noexcept
constexpr reference operator[](index_type const n) const noexcept
{
return *(data_ + n);
}
constexpr const_reference at(size_type const n) const
constexpr reference at(index_type const n) const
{
//Works only in C++14
//if (n >= length_) throw std::out_of_range("span::at()");
//return *(data_ + n);
return n >= length_ ? throw std::out_of_range("span::at()") : *(data_ + n);
}
constexpr const_pointer data() const noexcept
constexpr pointer data() const noexcept
{
return data_;
}
Expand All @@ -308,7 +312,7 @@ public:
*/
// slice with indices {{{
// check bound {{{
constexpr span<T> slice(check_bound_t, size_type const pos, size_type const slicelen) const
constexpr span<T> slice(check_bound_t, index_type const pos, index_type const slicelen) const
{
//Works only in C++14
//if (pos >= length_ || pos + slicelen >= length_) {
Expand All @@ -317,7 +321,7 @@ public:
//return span<T>{begin() + pos, begin() + pos + slicelen};
return pos >= length_ || pos + slicelen >= length_ ? throw std::out_of_range("span::slice()") : span<T>{begin() + pos, begin() + pos + slicelen};
}
constexpr span<T> slice_before(check_bound_t, size_type const pos) const
constexpr span<T> slice_before(check_bound_t, index_type const pos) const
{
//Works only in C++14
//if (pos >= length_) {
Expand All @@ -326,7 +330,7 @@ public:
//return span<T>{begin(), begin() + pos};
return pos >= length_ ? std::out_of_range("span::slice()") : span<T>{begin(), begin() + pos};
}
constexpr span<T> slice_after(check_bound_t, size_type const pos) const
constexpr span<T> slice_after(check_bound_t, index_type const pos) const
{
//Works only in C++14
//if (pos >= length_) {
Expand All @@ -337,15 +341,15 @@ public:
}
// }}}
// not check bound {{{
constexpr span<T> slice(size_type const pos, size_type const slicelen) const
constexpr span<T> slice(index_type const pos, index_type const slicelen) const
{
return span<T>{begin() + pos, begin() + pos + slicelen};
}
constexpr span<T> slice_before(size_type const pos) const
constexpr span<T> slice_before(index_type const pos) const
{
return span<T>{begin(), begin() + pos};
}
constexpr span<T> slice_after(size_type const pos) const
constexpr span<T> slice_after(index_type const pos) const
{
return span<T>{begin() + pos, end()};
}
Expand Down Expand Up @@ -406,9 +410,9 @@ public:
/*
* others
*/
template<class Allocator = std::allocator<T>>
template<class Allocator = std::allocator<typename std::remove_cv<T>::type>>
auto to_vector(Allocator const& alloc = Allocator{}) const
-> std::vector<T, Allocator>
-> std::vector<typename std::remove_cv<T>::type, Allocator>
{
return {begin(), end(), alloc};
}
Expand All @@ -428,8 +432,8 @@ private:
}

private:
size_type const length_;
const_pointer const data_;
index_type const length_;
pointer const data_;
};
// }}}
} // inline namespace __ROOT
Expand Down Expand Up @@ -554,7 +558,7 @@ span<T> make_view(T const (&a)[N])

template<class T>
inline constexpr
span<T> make_view(T const* p, typename span<T>::size_type const n)
span<T> make_view(T const* p, typename span<T>::index_type const n)
{
return span<T>{p, n};
}
Expand Down
Loading