ellphi.solver
The solver module dispatches tangency computations to the best available backend:
- C++ / Eigen — compiled extension, used automatically when available (
backend="auto"). - Pure Python — SciPy-based fallback, always available.
The default method "brentq+newton" uses a short bracketing phase followed by Newton refinement, which is significantly faster than pure Brent's method for high-dimensional inputs.
from ellphi import tangency, pdist_tangency, build_info
print(build_info()) # shows cpp_backend_available, cpp_linalg_kind, etc.
result = tangency(p, q)
print(result.t, result.point, result.mu)
dists = pdist_tangency(cloud) # condensed array
ellphi.solver
BuildInfo
dataclass
Summary of solver backends and C++ build details.
Notes
backend_choicesare the accepted values for thebackendargument in solver functions ("auto", "python", "cpp").cpp_linalg_kindreports the linear algebra implementation used by the C++ implementation ("eigen" or "internal").
Source code in src/ellphi/solver.py
build_info()
Return build information for solver selection and C++ backend details.
Source code in src/ellphi/solver.py
cpp_linalg_kind()
Return the C++ linear algebra build kind.
Returns:
| Type | Description |
|---|---|
str | None
|
The linear algebra kind ("eigen" or "internal") if the C++ backend is |
str | None
|
available, otherwise |
has_cpp_backend()
Checks if the compiled C++ backend for tangency calculations is available.
Returns:
| Type | Description |
|---|---|
bool
|
|
pdist_tangency(ellcloud, *, parallel=True, n_jobs=-1, backend='auto')
Computes pairwise tangency distances for a cloud of ellipses.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ellcloud |
Iterable[FloatArray]
|
A collection of ellipse coefficient arrays or an
|
required |
parallel |
bool
|
If |
True
|
n_jobs |
int | None
|
The number of jobs to run in parallel. |
-1
|
backend |
str
|
The backend to use for the computation. Can be one of "auto", "python", or "cpp". |
'auto'
|
Returns:
| Type | Description |
|---|---|
FloatArray
|
A condensed distance matrix of tangency distances. |
Source code in src/ellphi/solver.py
tangency(pcoef, qcoef, *, method='brentq+newton', bracket=(0.0, 1.0), x0=None, backend='auto', hybrid_bracket_maxiter=None, hybrid_newton_maxiter=None, failsafe=True)
Computes the tangency point between two ellipses.
This function returns the tangency time t, the tangent point point,
and the pencil parameter μ at which the two ellipses are tangent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pcoef |
FloatArray
|
The coefficient vector for the first ellipse. |
required |
qcoef |
FloatArray
|
The coefficient vector for the second ellipse. |
required |
method |
MethodName | str
|
The root-finding method to use. Can be one of "brentq+newton", "brentq", "brenth", "bisect", or "newton". |
'brentq+newton'
|
bracket |
Tuple[float, float]
|
The bracketing interval for bracket methods. |
(0.0, 1.0)
|
x0 |
float | None
|
An optional initial guess for Newton's method. Required if
|
None
|
backend |
str
|
The backend to use for the computation. Can be one of "auto", "cpp", or "python". |
'auto'
|
hybrid_bracket_maxiter |
int | None
|
An optional maximum number of iterations for the bracket phase in the hybrid method. |
None
|
hybrid_newton_maxiter |
int | None
|
An optional maximum number of iterations for the Newton phase in the hybrid method. |
None
|
failsafe |
bool
|
If |
True
|
Returns:
| Type | Description |
|---|---|
TangencyResult
|
A |
Source code in src/ellphi/solver.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |