Skip to content

Commit

Permalink
Fix compilation on 32-bits platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-moulard committed May 16, 2014
1 parent 0724b5c commit afa0167
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 11 deletions.
18 changes: 15 additions & 3 deletions include/roboptim/trajectory/b-spline.hh
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,21 @@ namespace roboptim

typedef Polynomial<N> polynomial_t;
typedef Monomial<N> monomial_t;
typedef std::map<int, polynomial_t> cox_map;
typedef std::map<
int,
polynomial_t,
std::less<int>,
Eigen::aligned_allocator<std::pair<const int, polynomial_t> >
> cox_map;
typedef typename cox_map::iterator cox_map_itr_t;

typedef std::vector <
polynomial_t,
Eigen::aligned_allocator<polynomial_t>
> basisPolynomials_t;
typedef std::vector <basisPolynomials_t>
basisPolynomialsVector_t;

/// \brief Instantiate a B-Spline from its definition.
///
/// \param timeRange spline time range: $\f$[t_3,t_n]\f$
Expand Down Expand Up @@ -140,7 +152,7 @@ namespace roboptim
/// done in the BSpline constructor).
///
/// \return constant reference to the basis polynomials.
const std::vector <std::vector <polynomial_t> >&
const basisPolynomialsVector_t&
basisPolynomials () const
{
return basisPolynomials_;
Expand Down Expand Up @@ -175,7 +187,7 @@ namespace roboptim
vector_t knots_;

/// \brief basisPolynomials_[i][j] = B_{i,i+j}
std::vector <std::vector <Polynomial<N> > > basisPolynomials_;
basisPolynomialsVector_t basisPolynomials_;

/// \brief For backward compatibility only.
bool uniform_;
Expand Down
2 changes: 1 addition & 1 deletion include/roboptim/trajectory/b-spline.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ namespace roboptim
for (size_type j = 0; j < nbp_; j++)
{
//calculate basis polynomials for each interval of the knot vector
basisPolynomials_.push_back (std::vector <polynomial_t> ());
basisPolynomials_.push_back (basisPolynomials_t ());
cox_map map = cox_de_boor (j, order_);

for (cox_map_itr_t itr = map.begin(); itr != map.end(); itr++)
Expand Down
16 changes: 13 additions & 3 deletions include/roboptim/trajectory/cubic-b-spline.hh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ namespace roboptim
class CubicBSpline : public Trajectory<3>
{
public:
typedef std::vector<
Polynomial3, Eigen::aligned_allocator<Polynomial3> >
polynomials3vector_t;

typedef std::vector<polynomials3vector_t> polynomials3vectors_t;


/// \brief Instantiate a cubic B-Spline from its definition.
///
/// \param timeRange spline time range: $\f$[t_3,t_n]\f$
Expand Down Expand Up @@ -115,14 +122,14 @@ namespace roboptim

/// \brief Return the polynomial expression of the cubic B-spline on each
/// time interval.
void toPolynomials (std::vector<Polynomial3>& res) const;
void toPolynomials (polynomials3vector_t& res) const;

/// \brief Constant getter for the basis polynomials of the cubic B-spline.
/// \return constant reference to the basis polynomials.
///
/// Note: computeBasisPolynomials() needs to be called beforehand (which is
/// done in the CubicBSpline constructor).
const std::vector <std::vector <Polynomial3> >&
const polynomials3vectors_t&
basisPolynomials() const
{
return basisPolynomials_;
Expand Down Expand Up @@ -174,11 +181,14 @@ namespace roboptim

/// \brief Basis polynomials.
/// basisPolynomials_[i][j] = B_{i,i+j}
std::vector <std::vector <Polynomial3> > basisPolynomials_;
polynomials3vectors_t basisPolynomials_;

/// \brief Whether the B-spline is uniform.
/// Note: for backward compatibility only.
bool uniform_;

public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};

/// @}
Expand Down
6 changes: 6 additions & 0 deletions include/roboptim/trajectory/polynomial.hh
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ namespace roboptim
/// \param t0
/// \param key one of all_zero_coefficients, monomial_coefficients.
Polynomial (value_type t0, special_polynomials key);

public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
}; // class Polynomial

template <int N>
Expand All @@ -221,6 +224,9 @@ namespace roboptim
Monomial (value_type t0)
: parent_t (t0, parent_t::monomial_coefficients)
{}

public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
}; // class Monomial
} // end of namespace roboptim.

Expand Down
9 changes: 5 additions & 4 deletions src/cubic-b-spline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ namespace roboptim
{
std::size_t j_ = static_cast<std::size_t> (j);

basisPolynomials_.push_back (std::vector <Polynomial3> ());
basisPolynomials_.push_back
(polynomials3vector_t ());
// t_j
double t0 = knots_[j_];
// t_{j+1}
Expand Down Expand Up @@ -291,19 +292,19 @@ namespace roboptim
void
CubicBSpline::translateBasisPolynomials (double t1)
{
for (std::vector <std::vector <Polynomial3> >::iterator
for (polynomials3vectors_t::iterator
it = basisPolynomials_.begin ();
it != basisPolynomials_.end ();
++it)
for (std::vector <Polynomial3>::iterator
for (polynomials3vector_t::iterator
p = it->begin ();
p != it->end ();
++p)
p->translateInPlace (t1);
}

void
CubicBSpline::toPolynomials (std::vector<Polynomial3>& res)
CubicBSpline::toPolynomials (polynomials3vector_t& res)
const
{
#ifndef ROBOPTIM_DO_NOT_CHECK_ALLOCATION
Expand Down

1 comment on commit afa0167

@bchretien
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.