pyoptools.misc.function_2d.function_2d module

class pyoptools.misc.function_2d.function_2d.Function2D

Bases: object

Abstract base class for 2D functions defined in Cartesian coordinates.

This class provides a framework for representing and evaluating 2D mathematical functions, including their partial derivatives. All concrete implementations should inherit from this class and implement the required methods.

Notes

The class provides two main evaluation methods: - eval2d: A nogil Cython method using Eigen matrices - eval: A Python-accessible method using NumPy arrays

Subclasses must implement: - eval_cy: Core evaluation function - dx: x-derivative - dy: y-derivative

dxdy()

Compute both partial derivatives simultaneously.

Returns:

A tuple containing (∂f/∂x, ∂f/∂y)

Return type:

tuple[Function2D, Function2D]

Notes

This method must be implemented by all subclasses.

eval(x, y)

Evaluate the function for arrays of x and y coordinates.

Parameters:
  • x (ndarray) – 2D array of x coordinates

  • y (ndarray) – 2D array of y coordinates

Returns:

2D array containing function values at each (x,y) point

Return type:

ndarray

Notes

This is the Python-accessible implementation using NumPy arrays. Decorated for maximum performance with bounds checking disabled.