Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51172 - in sandbox: miscellanea_algorithm/boost/algorithm miscellanea_algorithm/libs/algorithm/doc miscellanea_iterator_facade/libs/iterator/doc monomials_horner_rule/libs/math/doc
From: erwann.rogard_at_[hidden]
Date: 2009-02-10 03:37:53


Author: e_r
Date: 2009-02-10 03:37:51 EST (Tue, 10 Feb 2009)
New Revision: 51172
URL: http://svn.boost.org/trac/boost/changeset/51172

Log:
//////////////////////////////////////////////////////////////////////////////
// monomials_horner_rule
// (C) Copyright 2009 Erwann Rogard
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
///////////
/ Contact /
///////////

Please send questions or suggestions to erwann.rogard_at_[hidden]

/////////////
/ Overview /
/////////////

This collection of C++ classes computes multivariate monomials and derived quantities using Horner's rule a.k.a. graded lexicographic ordering.
Individual classes contain specific documentation.

//////////////////
/ Requirements /
//////////////////

Compiles fine under

gcc version i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5490)

The compiler search path must include
boost_1_37_0
boost/sandbox/miscellanea_iterator_facade/
boost/sandbox/monomials_horner_rule/

///////////////////////
/ Output from main.cpp /
///////////////////////
-> example_monomials

 -> d=1
  ->p=1
1 0 <-
  ->p=2
1 0 0 <-
  ->p=3
1 0 0 0 <-
  ->p=4
1 0 0 0 0 <-
 <-
 -> d=2
  ->p=1
1 0 1 <-
  ->p=2
1 0 1 0 0 1 <-
  ->p=3
1 0 1 0 0 1 0 0 0 1 <-
  ->p=4
1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 <-
 <-
 -> d=3
  ->p=1
1 0 1 2 <-
  ->p=2
1 0 1 2 0 0 0 1 2 4 <-
  ->p=3
1 0 1 2 0 0 0 1 2 4 0 0 0 0 0 0 1 2 4 8 <-
  ->p=4
1 0 1 2 0 0 0 1 2 4 0 0 0 0 0 0 1 2 4 8 0 0 0 0 0 0 0 0 0 0 1 2 4 8 16 <-
 <-
 -> d=4
  ->p=1
1 0 1 2 3 <-
  ->p=2
1 0 1 2 3 0 0 0 0 1 2 3 4 6 9 <-
  ->p=3
1 0 1 2 3 0 0 0 0 1 2 3 4 6 9 0 0 0 0 0 0 0 0 0 0 1 2 3 4 6 9 8 12 18 27 <-
  ->p=4
1 0 1 2 3 0 0 0 0 1 2 3 4 6 9 0 0 0 0 0 0 0 0 0 0 1 2 3 4 6 9 8 12 18 27 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 6 9 8 12 18 27 16 24 36 54 81 <-
 <-
<-
-> example_multi_indexes
0 0 0
1 0 0
0 1 0
0 0 1
2 0 0
1 1 0
1 0 1
0 2 0
0 1 1
0 0 2

0 0 0
1 0 0
0 1 0
0 0 1
2 0 0
1 1 0
1 0 1
0 2 0
0 1 1
0 0 2
3 0 0
2 1 0
2 0 1
1 2 0
1 1 1
1 0 2
0 3 0
0 2 1
0 1 2
0 0 3
<-
-> example_multi_factorial
 -> multi_factorial<3>::degree(5)
1 1 1 1 2 1 1 2 1 2 6 2 2 2 1 2 6 2 2 6 24 6 6 4 2 4 6 2 2 6 24 6 4 6 24 120 24 24 12 6 12 12 4 4 12 24 6 4 6 24 120 24 12 12 24 120
 -> multi_degree<3>::degree(5)
0 1 1 1 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
 -> multi_p2df<3>::degree(5)
1 2 2 2 2 4 4 2 4 2 1.33333 4 4 4 8 4 1.33333 4 4 1.33333 0.666667 2.66667 2.66667 4 8 4 2.66667 8 8 2.66667 0.666667 2.66667 4 2.66667 0.666667 0.266667 1.33333 1.33333 2.66667 5.33333 2.66667 2.66667 8 8 2.66667 1.33333 5.33333 8 5.33333 1.33333 0.266667 1.33333 2.66667 2.66667 1.33333 0.266667
<-

Text files modified:
   sandbox/miscellanea_algorithm/boost/algorithm/l2_norm.hpp | 25 ++++++++-----------------
   sandbox/miscellanea_algorithm/libs/algorithm/doc/readme.txt | 1 +
   sandbox/miscellanea_iterator_facade/libs/iterator/doc/readme.txt | 1 +
   sandbox/monomials_horner_rule/libs/math/doc/readme.txt | 1 +
   4 files changed, 11 insertions(+), 17 deletions(-)

Modified: sandbox/miscellanea_algorithm/boost/algorithm/l2_norm.hpp
==============================================================================
--- sandbox/miscellanea_algorithm/boost/algorithm/l2_norm.hpp (original)
+++ sandbox/miscellanea_algorithm/boost/algorithm/l2_norm.hpp 2009-02-10 03:37:51 EST (Tue, 10 Feb 2009)
@@ -6,34 +6,25 @@
 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 #ifndef BOOST_ALGORITHM_L2_NORM_HPP_ER_2009
 #define BOOST_ALGORITHM_L2_NORM_HPP_ER_2009
-#include <numeric>
 #include <cmath>
 #include <boost/range.hpp>
 #include <boost/range/value_type.hpp>
+#include <boost/algorithm/l2_norm_squared.hpp>
 namespace boost{
 
-class l2_norm{
+class l2_norm : l2_norm_squared{//EBO
+ typedef l2_norm_squared super_t;
     public:
- l2_norm(){}
+ l2_norm():super_t(){}
     template<typename R0>
     typename range_value<R0>::type
- operator()(const R0& r0){
+ operator()(const R0& r0)const{
         typedef typename range_value<R0>::type result_type;
- return std::sqrt(std::accumulate(
- boost::begin(r0),
- boost::end(r0),
- (result_type)(0),
- bin_op<result_type>()
- ));
+ const super_t& ref = static_cast<const super_t&>(*this);
+ result_type sq = ref(r0);
+ return std::sqrt(sq);
     };
 
- private:
-
- template<typename T>
- struct bin_op{
- bin_op(){}
- T operator()(T x,T y)const{ return x + y*y; }
- };
 };
 
 }

Modified: sandbox/miscellanea_algorithm/libs/algorithm/doc/readme.txt
==============================================================================
--- sandbox/miscellanea_algorithm/libs/algorithm/doc/readme.txt (original)
+++ sandbox/miscellanea_algorithm/libs/algorithm/doc/readme.txt 2009-02-10 03:37:51 EST (Tue, 10 Feb 2009)
@@ -33,6 +33,7 @@
 The compiler search path must include
 boost_1_37_0
 boost/sandbox/miscellanea_iterator_facade
+boost/sandbox/miscellanea_algorithm
 
 ////////////////////////
 / Output from main.cpp /

Modified: sandbox/miscellanea_iterator_facade/libs/iterator/doc/readme.txt
==============================================================================
--- sandbox/miscellanea_iterator_facade/libs/iterator/doc/readme.txt (original)
+++ sandbox/miscellanea_iterator_facade/libs/iterator/doc/readme.txt 2009-02-10 03:37:51 EST (Tue, 10 Feb 2009)
@@ -31,6 +31,7 @@
 
 The compiler search path must include
 boost_1_37_0
+sandbox/boost/miscellanea_iterator_facade
 
 ////////////////////////
 / Output from main.cpp /

Modified: sandbox/monomials_horner_rule/libs/math/doc/readme.txt
==============================================================================
--- sandbox/monomials_horner_rule/libs/math/doc/readme.txt (original)
+++ sandbox/monomials_horner_rule/libs/math/doc/readme.txt 2009-02-10 03:37:51 EST (Tue, 10 Feb 2009)
@@ -28,6 +28,7 @@
 The compiler search path must include
 boost_1_37_0
 boost/sandbox/miscellanea_iterator_facade/
+boost/sandbox/monomials_horner_rule/
 
 ///////////////////////
 / Output from main.cpp /


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk