trsl logo
Template Range Sampling Library Documentation
http://renaud-detry.net/trsl

TRSL is a C++ library that implements several sampling schemes behind an (STL-like) iterator interface. The library may be used e.g. in particle filtering or probabilistic inference frameworks. For an overview of the functionalities provided by TRSL, refer to the Products page.

News

2011-04-06
Released TRSL 0.2.2. This release contains minor updates, see Version History for a list of changes.
2008-05-21
The Boost Software License is now Open Source (certified by OSI since Feb. 2008).
2008-05-18
Released TRSL 0.2.1. This release contains minor updates only, see Version History for a list of changes.
2008-03-27
TRSL 0.2.0 is out. See Version History for a list of changes.
2008-01-02
TRSL 0.1.1 is out. See Version History for a list of changes.

License

TRSL is distributed under the Boost Software License (BSL). BSL is a GPL-compatible free-software license, very similar to the BSD license and the MIT license; see Boost Software License Background. BSL is also open-source; see Boost Software License 1.0 on the Open Source Initiative website.

Source

TRSL is in a usable state. However, it is likely to grow and change interface in the future.

The latest sources are available through GitHub.

TRSL is meant to be OS Portable. It has been tested on Linux and MacOS X with GCC 4 and LLVM 2.8 (with clang).

Feedback

The preferred method of communication is currently via GitHub issues.

Products

See the Products page for the complete list of functionalities offered by TRSL.

The central TRSL product is trsl::is_picked_systematic, a predicate functor to use in combination with trsl::persistent_filter_iterator to form a sample iterator. The sample iterator accesses a population of elements through a range defined by a pair of Forward Iterators (begin/end), and provides on-the-fly iteration through a sample of the population.

Let us assume a particle filter implementation, which manages a population of particles (struct Particle { weight; x; y; }) stored in a container ParticleCollection. The following bit of code shows an example of how to iterate through a sample of the population after having implemented ParticleCollection::sample_begin(size_t) and ParticleCollection::sample_end() using e.g. trsl::is_picked_systematic.

const size_t POPULATION_SIZE = 100;
const size_t SAMPLE_SIZE = 10;
//-----------------------//
// Generate a population //
//-----------------------//
ParticleCollection population;
for (size_t i = 0; i < POPULATION_SIZE; ++i)
{
Particle p(double(rand())/RAND_MAX, // weight
double(rand())/RAND_MAX, // position (x)
double(rand())/RAND_MAX); // position (y)
population.add(p);
}
//----------------------------//
// Sample from the population //
//----------------------------//
ParticleCollection sample;
//-- population contains 100 elements. --//
for (ParticleCollection::const_sample_iterator
si = population.sample_begin(SAMPLE_SIZE),
se = population.sample_end();
si != se; ++si)
{
Particle p = *si;
p.setWeight(1);
sample.add(p);
// ... or do something else with *si ...
}
//-- sample contains 10 elements. --//
assert(sample.size() == SAMPLE_SIZE);

Authors

TRSL is developped by Renaud Detry.

Credits

TRSL is based on the excellent Boost Iterator Library.

Several concept implementations (e.g. accessors) are inspired from libkdtree++.

© Copyright 2007-2011 Renaud Detry.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at www.boost.org/LICENSE_1_0.txt.)
Revised Wed Jan 8 2020 14:43:32.