
Hi all, I am trying to use boost::accumulators lib and I would appreciate some help. I do not know how to use the tag::density. How do I use : accumulator_set<double, tag::density > angular_acc; and set density::cache_size density::num_bins To have for example 10 subdivisions between -pi and pi ? Then, how do I extract the results of the accumulation ? Regards Olivier -- Le temps des cerises reviendra. Dans l'immédiat, c'est le temps des noyaux. Courage.

Olivier Tournaire wrote:
Hi all,
I am trying to use boost::accumulators lib and I would appreciate some help. I do not know how to use the tag::density. How do I use :
accumulator_set<double, tag::density > angular_acc;
Have a look at the docs: http://boost-sandbox.sourceforge.net/libs/accumulators/doc/html/index.html That should be: accumulator_set<double, features<tag::density> > angular_acc;
and set
density::cache_size density::num_bins
To have for example 10 subdivisions between -pi and pi ? Then, how do I extract the results of the accumulation ?
The docs tell you all this, too. -- Eric Niebler Boost Consulting www.boost-consulting.com

OK, thanks. I finaly wrote this : accumulator_set<double, features<tag::density> > angular_acc(tag::density::num_bins = Constantes::_pi/16.,tag::density::cache_size = 2.*Constantes::_pi); int nb_ech = (int)( (itb->norme()) / pas ); TPoint2D <double> direction = itb->p1 - itb->p2; direction.normaliser(); // On parcourt tous les échantillons for (unsigned int j=0;j<nb_ech;j++) { TPoint2D <double> pt = itb->p1 + direction * j; double angle = atan2( gy(pt) , gx(pt) ); angular_acc(angle); } Now that I am here, how can I extract the histogram ? Regards Eric Niebler a écrit :
Olivier Tournaire wrote:
Hi all,
I am trying to use boost::accumulators lib and I would appreciate some help. I do not know how to use the tag::density. How do I use :
accumulator_set<double, tag::density > angular_acc;
Have a look at the docs: http://boost-sandbox.sourceforge.net/libs/accumulators/doc/html/index.html
That should be:
accumulator_set<double, features<tag::density> > angular_acc;
and set
density::cache_size density::num_bins
To have for example 10 subdivisions between -pi and pi ? Then, how do I extract the results of the accumulation ?
The docs tell you all this, too.
-- Le temps des cerises reviendra. Dans l'immédiat, c'est le temps des noyaux. Courage.

Hi, When I use this std::cout << " count(acc) = " << boost::accumulators::extract::count(angular_acc) << std::endl; to extract a value from my accumulator, I get compile errors : boost\detail\function1.hpp(67) : error C2065: 'UnaryFunction' : identificateur non déclaré ("undeclared identifier") ... boost\detail\function1.hpp(67) : error C2275: 'impl' : utilisation non conforme de ce type comme expression ("*illegal use of this type as an expression")* boost\detail\function1.hpp(67) : error C2059: erreur de syntaxe : ')' ("syntax error") boost\detail\function1.hpp(67) : error C3861: 'BOOST_CONCEPT_ASSERT': identificateur introuvable, même avec une recherche qui dépend de l'argument ("identifier not found") I am using boost 1.34.1 under VC 2003. Any issue ? Regards Olivier Eric Niebler a écrit :
Olivier Tournaire wrote:
Hi all,
I am trying to use boost::accumulators lib and I would appreciate some help. I do not know how to use the tag::density. How do I use :
accumulator_set<double, tag::density > angular_acc;
Have a look at the docs: http://boost-sandbox.sourceforge.net/libs/accumulators/doc/html/index.html
That should be:
accumulator_set<double, features<tag::density> > angular_acc;
and set
density::cache_size density::num_bins
To have for example 10 subdivisions between -pi and pi ? Then, how do I extract the results of the accumulation ?
The docs tell you all this, too.
-- Le temps des cerises reviendra. Dans l'immédiat, c'est le temps des noyaux. Courage.

Olivier Tournaire wrote:
Hi,
When I use this
std::cout << " count(acc) = " << boost::accumulators::extract::count(angular_acc) << std::endl;
to extract a value from my accumulator, I get compile errors :
boost\detail\function1.hpp(67) : error C2065: 'UnaryFunction' : identificateur non déclaré ("undeclared identifier") ... boost\detail\function1.hpp(67) : error C2275: 'impl' : utilisation non conforme de ce type comme expression ("*illegal use of this type as an expression")* boost\detail\function1.hpp(67) : error C2059: erreur de syntaxe : ')' ("syntax error") boost\detail\function1.hpp(67) : error C3861: 'BOOST_CONCEPT_ASSERT': identificateur introuvable, même avec une recherche qui dépend de l'argument ("identifier not found")
I am using boost 1.34.1 under VC 2003. Any issue ?
Ah. The accumulators library uses a newer version of the concopt_check library than what was in 1.34.1. In the accumulators.zip file, the boost/backports directory contains everything you need. Be sure that that directory is in your include path before the rest of boost. HTH, -- Eric Niebler Boost Consulting www.boost-consulting.com

Thank you Eric, it now compiles fine. However, I am still having problem to acces the histogram : typedef iterator_range<std::vector<std::pair<double, double> >::iterator
histogram_type; histogram_type histogram = tag::density(angular_acc); // error C2143: erreur de syntaxe : absence de ';' avant '<' (--> "syntax error : missing ';' before '<'")
for (std::size_t i = 0; i < histogram.size(); ++i) { // problem with small results: epsilon is relative (in percent), not absolute! if ( histogram[i].second > 0.001 ) BOOST_CHECK_CLOSE( 0.5 * (1.0 + erf( histogram[i].first / sqrt(2.0) )), histogram[i].second, epsilon ); } Could you help me ? Regards Olivier Eric Niebler a écrit :
Olivier Tournaire wrote:
Hi,
When I use this
std::cout << " count(acc) = " << boost::accumulators::extract::count(angular_acc) << std::endl;
to extract a value from my accumulator, I get compile errors :
boost\detail\function1.hpp(67) : error C2065: 'UnaryFunction' : identificateur non déclaré ("undeclared identifier") ... boost\detail\function1.hpp(67) : error C2275: 'impl' : utilisation non conforme de ce type comme expression ("*illegal use of this type as an expression")* boost\detail\function1.hpp(67) : error C2059: erreur de syntaxe : ')' ("syntax error") boost\detail\function1.hpp(67) : error C3861: 'BOOST_CONCEPT_ASSERT': identificateur introuvable, même avec une recherche qui dépend de l'argument ("identifier not found")
I am using boost 1.34.1 under VC 2003. Any issue ?
Ah. The accumulators library uses a newer version of the concopt_check library than what was in 1.34.1. In the accumulators.zip file, the boost/backports directory contains everything you need. Be sure that that directory is in your include path before the rest of boost.
HTH,
-- Le temps des cerises reviendra. Dans l'immédiat, c'est le temps des noyaux. Courage.

Olivier Tournaire wrote:
Thank you Eric, it now compiles fine. However, I am still having problem to acces the histogram :
typedef iterator_range<std::vector<std::pair<double, double> >::iterator
histogram_type; histogram_type histogram = tag::density(angular_acc); // error C2143: erreur de syntaxe : absence de ';' avant '<' (--> "syntax error : missing ';' before '<'")
Your problem is here, but I bet you can find it yourself if you read the docs on extracting results: http://tinyurl.com/2q2ttl (http://boost-sandbox.sourceforge.net/libs/accumulators/doc/html/accumulators...) Hint: feature tags are in the "tags" namespace, but extractors are not. And for the return type of the density extractor, you should look at the docs for density: http://tinyurl.com/3ycetz (http://boost-sandbox.sourceforge.net/libs/accumulators/doc/html/accumulators...) -- Eric Niebler Boost Consulting www.boost-consulting.com

Thank you Eric. I finally found the answer thanks to the doc. However in the doc, you use typedef iterator_range<std::vector<std::pair<double, double> >::iterator histogram_type; And it does not compile because iterator_range is in the boost namespace that I did not defined earlier. I had to declare the histogram_type this way : typedef boost::iterator_range<std::vector<std::pair<double, double>
::iterator histogram_type; And, finally, extract the result
histogram_type histogram = density(angular_acc); Now, it works and compile fine. Thank you for this very usefull lib ! Regards, Olivier Eric Niebler a écrit :
Olivier Tournaire wrote:
Thank you Eric, it now compiles fine. However, I am still having problem to acces the histogram :
typedef iterator_range<std::vector<std::pair<double, double> >::iterator
histogram_type; histogram_type histogram = tag::density(angular_acc); // error C2143: erreur de syntaxe : absence de ';' avant '<' (--> "syntax error : missing ';' before '<'")
Your problem is here, but I bet you can find it yourself if you read the docs on extracting results: http://tinyurl.com/2q2ttl (http://boost-sandbox.sourceforge.net/libs/accumulators/doc/html/accumulators...)
Hint: feature tags are in the "tags" namespace, but extractors are not.
And for the return type of the density extractor, you should look at the docs for density: http://tinyurl.com/3ycetz (http://boost-sandbox.sourceforge.net/libs/accumulators/doc/html/accumulators...)
-- Le temps des cerises reviendra. Dans l'immédiat, c'est le temps des noyaux. Courage.
participants (2)
-
Eric Niebler
-
Olivier Tournaire