OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
Classes | Functions | Variables
PySquarePolynomialMap Namespace Reference

Classes

struct  PyPolynomialMap
 

Functions

PyObject * get_coefficients_as_matrix (PyObject *self, PyObject *args, PyObject *kwds)
 
PyObject * index_by_power (PyObject *py_class, PyObject *args, PyObject *kwds)
 
PyObject * evaluate (PyObject *self, PyObject *args, PyObject *kwds)
 
std::vector< std::vector< double > > get_vectors (PyObject *py_floats)
 
PyObject * exact_solve (PyObject *py_class, PyObject *args, PyObject *kwds)
 
PyObject * least_squares (PyObject *py_class, PyObject *args, PyObject *kwds)
 
int _init (PyObject *self, PyObject *args, PyObject *kwds)
 
PyObject * _alloc (PyTypeObject *type, Py_ssize_t nitems)
 
PyObject * _new (PyTypeObject *type, Py_ssize_t nitems)
 
void _dealloc (PyPolynomialMap *self)
 
void _free (PyPolynomialMap *self)
 
PyMODINIT_FUNC initsquare_polynomial_map (void)
 

Variables

std::string get_coefficients_as_matrix_docstring
 
std::string index_by_power_docstring
 
std::string evaluate_docstring
 
std::string exact_solve_docstring
 
std::string least_squares_docstring
 
std::string class_docstring
 

Function Documentation

◆ _alloc()

static PyObject * PySquarePolynomialMap::_alloc ( PyTypeObject *  type,
Py_ssize_t  nitems 
)

_alloc allocates memory for PyPolynomialMap

Parameters
type- pointer to aPyPolynomialMapType object, as defined in PyPolynomialMap.cc

returns a PyPolynomialMap* (cast as a PyObject*); caller owns this memory

Definition at line 474 of file PySquarePolynomialMap.cpp.

References PySquarePolynomialMap::PyPolynomialMap::map.

Referenced by _new(), exact_solve(), and least_squares().

◆ _dealloc()

static void PySquarePolynomialMap::_dealloc ( PyPolynomialMap self)

deallocate memory

@params self an initialised PyPolynomialMap*; memory will be freed by this function

Definition at line 487 of file PySquarePolynomialMap.cpp.

References _free().

Here is the call graph for this function:

◆ _free()

static void PySquarePolynomialMap::_free ( PyPolynomialMap self)

synonym for dealloc

Definition at line 491 of file PySquarePolynomialMap.cpp.

References PySquarePolynomialMap::PyPolynomialMap::map.

Referenced by _dealloc().

◆ _init()

static int PySquarePolynomialMap::_init ( PyObject *  self,
PyObject *  args,
PyObject *  kwds 
)

_init initialises an allocated PyPolynomialMap object

Parameters
selfan initialised PyPolynomialMap* cast as a PyObject*; caller owns this memory
argsnot used
kwdsnot used
Returns
0 on success; -1 on failure

Definition at line 396 of file PySquarePolynomialMap.cpp.

References PySquarePolynomialMap::PyPolynomialMap::map.

◆ _new()

PyObject * PySquarePolynomialMap::_new ( PyTypeObject *  type,
Py_ssize_t  nitems 
)

Definition at line 483 of file PySquarePolynomialMap.cpp.

References _alloc().

Here is the call graph for this function:

◆ evaluate()

static PyObject * PySquarePolynomialMap::evaluate ( PyObject *  self,
PyObject *  args,
PyObject *  kwds 
)

Calculate a polynomial vector

Parameters
selfa PyPolynomialMap
argsarguments to the function (not used)
kwdskeyword arguments to the function - see docstring
Returns
a PyList of floats with ValueDimension

Definition at line 131 of file PySquarePolynomialMap.cpp.

References interpolation::SquarePolynomialVector::F(), PySquarePolynomialMap::PyPolynomialMap::map, interpolation::SquarePolynomialVector::PointDimension(), and interpolation::SquarePolynomialVector::ValueDimension().

Here is the call graph for this function:

◆ exact_solve()

PyObject * PySquarePolynomialMap::exact_solve ( PyObject *  py_class,
PyObject *  args,
PyObject *  kwds 
)

Definition at line 230 of file PySquarePolynomialMap.cpp.

References _alloc(), get_vectors(), PySquarePolynomialMap::PyPolynomialMap::map, QRDecomposition::solve(), and ClassicException::what().

Here is the call graph for this function:

◆ get_coefficients_as_matrix()

static PyObject * PySquarePolynomialMap::get_coefficients_as_matrix ( PyObject *  self,
PyObject *  args,
PyObject *  kwds 
)

Get the PolynomialMap coefficients

Parameters
selfa PyPolynomialMap
argsarguments to the function (not used)
kwdskeyword arguments to the function - see docstring
Returns
a list of lists of floats; each corresponding to a value in the polynomial map

Definition at line 42 of file PySquarePolynomialMap.cpp.

References interpolation::SquarePolynomialVector::GetCoefficientsAsMatrix(), PySquarePolynomialMap::PyPolynomialMap::map, interpolation::MMatrix< Tmplt >::num_col(), and interpolation::MMatrix< Tmplt >::num_row().

Here is the call graph for this function:

◆ get_vectors()

std::vector< std::vector< double > > PySquarePolynomialMap::get_vectors ( PyObject *  py_floats)

Definition at line 190 of file PySquarePolynomialMap.cpp.

Referenced by exact_solve(), and least_squares().

◆ index_by_power()

PyObject * PySquarePolynomialMap::index_by_power ( PyObject *  py_class,
PyObject *  args,
PyObject *  kwds 
)

Definition at line 85 of file PySquarePolynomialMap.cpp.

References interpolation::SquarePolynomialVector::IndexByPower().

Here is the call graph for this function:

◆ initsquare_polynomial_map()

PyMODINIT_FUNC PySquarePolynomialMap::initsquare_polynomial_map ( void  )

Initialise polynomial_map module

This is called by import polynomial_map; it initialises the PolynomialMap type allowing user to construct and call methods on PolynomialMap objects

◆ least_squares()

PyObject * PySquarePolynomialMap::least_squares ( PyObject *  py_class,
PyObject *  args,
PyObject *  kwds 
)

Variable Documentation

◆ class_docstring

std::string PySquarePolynomialMap::class_docstring
Initial value:
=
std::string("PolynomialMap provides routines to calculate multivariate \n")+
std::string("polynomials.\n\n")+
std::string("__init__()\n")+
std::string(" Takes two arguments.\n")+
std::string(" - point_dim: integer which defines the dimension of the\n")+
std::string(" points (abscissa)\n")+
std::string(" - coefficients: list of lists of floats which define the\n")+
std::string(" polynomial\n")+
std::string("The value dimension of the PolynomialMap is the number of rows\n")+
std::string("coefficients matrix\n")

Definition at line 517 of file PySquarePolynomialMap.cpp.

◆ evaluate_docstring

std::string PySquarePolynomialMap::evaluate_docstring
Initial value:
=
std::string("Apply the mapping to a point.\n\n")+
std::string(" - point: list of floats with length equal to the point\n")+
std::string(" dimension of the mapping, corresponding to the abscissa.\n")+
std::string("Return value is a list of floats, with length equal to the\n")+
std::string("value dimension of the mapping; corresponding to the ordinates\n")

Definition at line 124 of file PySquarePolynomialMap.cpp.

◆ exact_solve_docstring

std::string PySquarePolynomialMap::exact_solve_docstring
Initial value:
=
std::string("Find a mapping by solving for the matrix.\n\n")+
std::string(" - points: list, each entry containing a list of floats\n")+
std::string(" corresponding to abscissa, each with length PointDimension.\n")+
std::string(" The list should be as long as the number of coefficients in\n")+
std::string(" the polynomial.\n")+
std::string(" - values: list, each entry containing a list of floats\n")+
std::string(" corresponding to ordinates, each with length ValueDimension.\n")+
std::string(" The list should be as long as points.\n")+
std::string(" - polynomial_order: integer, >= 0, corresponding to the\n")+
std::string(" order of the fitted polynomial; 0 is constant, 1 is linear...\n")+
std::string("Returns a polynomial map.\n")

Definition at line 177 of file PySquarePolynomialMap.cpp.

◆ get_coefficients_as_matrix_docstring

std::string PySquarePolynomialMap::get_coefficients_as_matrix_docstring
Initial value:
=
std::string("Return the coefficients of the matrix. Takes no arguments\n\n")+
std::string("Return value is a list of lists, with polynomial coefficients\n")+
std::string("for y_i = sum_j a_{ij}*prod_n(x_n^j_n) forming the i, j term\n")+
std::string("in the matrix.\n")

Definition at line 36 of file PySquarePolynomialMap.cpp.

◆ index_by_power_docstring

std::string PySquarePolynomialMap::index_by_power_docstring
Initial value:
=
std::string("Maps from the matrix index to the polynomial term.\n\n")+
std::string(" - col: index of the matrix column.\n")+
std::string(" - dim: dimension of the problem.\n")+
std::string("Return value is a list of ints of length dim. Terms in the\n")+
std::string("transfer matrix in the column given by col correspond to the\n")+
std::string("coefficient of the x_j1^k1 ... x_jn^kn term where kn are the\n")+
std::string("integers returned by this method.\n")+
std::string("For example, PolynomialMap.index_by_power(5, 2) returns\n")+
std::string("[2, 1] meaning the 7th column in a two-dimensional problem\n")+
std::string("represents the coefficients of x_0^2 x_1^1\n")

Definition at line 72 of file PySquarePolynomialMap.cpp.

◆ least_squares_docstring

std::string PySquarePolynomialMap::least_squares_docstring
Initial value:
=
std::string("Find a mapping by solving for the matrix.\n\n")+
std::string(" - points: list, each entry containing a list of floats\n")+
std::string(" corresponding to abscissa, each with length PointDimension.\n")+
std::string(" The list should be at least as long as the number of \n")+
std::string(" coefficients in the polynomial.\n")+
std::string(" - values: list, each entry containing a list of floats\n")+
std::string(" corresponding to ordinates, each with length ValueDimension.\n")+
std::string(" The list should be as long as points.\n")+
std::string(" - polynomial_order: integer, >= 0, corresponding to the\n")+
std::string(" order of the fitted polynomial; 0 is constant, 1 is linear...\n")+
std::string(" - coefficients: list of PolynomialCoefficients. Fix these\n")+
std::string(" coefficients to some \n")+
std::string(" - weights: list, of length = 0, corresponding to\n")+
std::string("Returns a polynomial map.\n")

Definition at line 290 of file PySquarePolynomialMap.cpp.