Skip to content

Conversation

@jfisac
Copy link
Member

@jfisac jfisac commented Sep 5, 2018

Added some wrappers for RecursiveGradientInterpolator (and now also RecursiveValueInterpolator) to also work.

Be sure to take a look, I tried not to break anything but let's make sure!

@jfisac jfisac requested a review from dfridovi September 5, 2018 19:49
typename PD, typename RS, typename RD, typename B>
VectorXd MatlabValueFunction<TS, TC, TD, PS, PC, PD, RS, RD, B>::
RecursiveGradientInterpolator(const VectorXd& x, size_t idx) const {
return RecursiveMultilinearInterpolator(x idx, true);
Copy link
Member Author

Choose a reason for hiding this comment

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

Ah crap this is a typo, will fix!

VectorXd DirectionToCenter(const VectorXd& x) const;

// Accessor for precomputed value at the given state.
VectorXd ValueAccessor(const VectorXd& x) const;
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be outputting a double?

const size_t idx = StateToIndex(x);

VectorXd value(x.size());
for (size_t ii = 0; ii < value.size(); ii++) value(ii) = data_[ii][idx];
Copy link
Member

Choose a reason for hiding this comment

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

This won't work. Remember, data_ is a std::vector<double>, i.e. it's flattened. Also value output should be a double.

// Recursive helper function for value or gradient multilinear interpolation.
// Takes in a state and index along which to interpolate, and a boolean
// determining whether this is for the gradient or, otherwise, for the value.
VectorXd RecursiveMultilinearInterpolator(const VectorXd& x, size_t idx,
Copy link
Member

Choose a reason for hiding this comment

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

Ooooooh cool idea. Instead of passing in a bool flag, could template the function itself on the accessor function, like:

template <typename Accessor, typename OutputType>
OutputType RecursiveMultilinearInterpolator(const VectorXd& x, size_t idx) const;

Copy link
Member

Choose a reason for hiding this comment

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

In any case, since the output type can be either double or VectorXd you need to template that.

Copy link
Member

@dfridovi dfridovi left a comment

Choose a reason for hiding this comment

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

Main issue is that Value should output a double, not a VectorXd. Also suggesting a cleaner template approach to the recursive helper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants