This is a pre-release version (latest). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy latest / numpy / f2py / crackfortran / getlincoef

function

numpy.f2py.crackfortran:getlincoef

source: build-install/usr/lib/python3.14/site-packages/numpy/f2py/crackfortran.py :2280

Signature

def   getlincoef ( e xset )

Summary

Obtain a and b when e == "a*x+b", where x is a symbol in xset.

Extended Summary

>>> getlincoef('2*x + 1', {'x'})
(2, 1, 'x')
>>> getlincoef('3*x + x*2 + 2 + 1', {'x'})
(5, 3, 'x')
>>> getlincoef('0', {'x'})
(0, 0, None)
>>> getlincoef('0*x', {'x'})
(0, 0, 'x')
>>> getlincoef('x*x', {'x'})
(None, None, None)

This can be tricked by sufficiently complex expressions

>>> getlincoef('(x - 0.5)*(x - 1.5)*(x - 1)*x + 2*x + 3', {'x'})
(2.0, 3.0, 'x')

Aliases

  • numpy.f2py.crackfortran.getlincoef