## Feature #1731

### python API interface to legacy PolynomailMap class

Added by Rogers, Chris almost 8 years ago.
Updated almost 8 years ago.

Start date:

14 August 2015

**Description**

As part of the alignment analysis, it would be useful to provide an interface to the legacy PolynomialMap class.

Would like to make an interface to the following functions:

- initialisation
`Matrix<double> GetCoefficientsAsMatrix() const`

: return a list of lists instead of matrix
- SetCoefficients(int point_dim): use a list of lists
`void F(const double * point, double * value) const;`

should take a list as argument (point) and return a list (value)
`int PointDimension() const`

`int ValueDimension() const`

`std::ostream& operator<<(std::ostream&, const PolynomialMap&)`

: should be used to make a *str* function
static PolynomialMap* PolynomialLeastSquaresFit(
const std::vector< std::vector<double> >& points,
const std::vector< std::vector<double> >& values,
unsigned int polynomialOrder,
const std::vector<double>& weights = std::vector<double>());

vectors should be lists or lists of lists

Nb the class is not in legacy, it is in `src/common_cpp/Maths`

So I have a pretty good first pass at `bzr+ssh://bazaar.launchpad.net/~chris-rogers/maus/1731/`

I have implemented and tested

- init
- get_coefficients_as_matrix
- evaluate (was F)
- least_squares_fit

I found that SetCoefficients throws an exception; I might have a look at that later on. But basically this is done and working.

**Status** changed from *Open* to *Closed*
**% Done** changed from *0* to *100*

Closed at r914

I could at some stage add point_dimension, value_dimension *str*() interfaces; these can be got at by doing

len(p_map.get_coefficients_as_matrix()) # value_dimension
len(p_map.get_coefficients_as_matrix()[0]) # point_dimension
str(p_map.get_coefficients_as_matrix()) # string representation

so it would be more a convenience than anything else... and hence low priority

Also available in: Atom
PDF