MCPcopy Create free account
hub / github.com/numpy/numpy / linear_solve

Method linear_solve

numpy/f2py/symbolic.py:774–788  ·  view source on GitHub ↗

Return a, b such that a * symbol + b == self. If self is not linear with respect to symbol, raise RuntimeError.

(self, symbol)

Source from the content-addressed store, hash-verified

772 return found
773
774 def linear_solve(self, symbol):
775 """Return a, b such that a * symbol + b == self.
776
777 If self is not linear with respect to symbol, raise RuntimeError.
778 """
779 b = self.substitute({symbol: as_number(0)})
780 ax = self - b
781 a = ax.substitute({symbol: as_number(1)})
782
783 zero, _ = as_numer_denom(a * symbol - ax)
784
785 if zero != as_number(0):
786 raise RuntimeError(f'not a {symbol}-linear equation:'
787 f' {a} * {symbol} + {b} == {self}')
788 return a, b
789
790
791def normalize(obj):

Callers 2

analyzevarsFunction · 0.80
test_linear_solveMethod · 0.80

Calls 3

substituteMethod · 0.95
as_numberFunction · 0.85
as_numer_denomFunction · 0.85

Tested by 1

test_linear_solveMethod · 0.64