MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / test1

Function test1

matrix/sherman_morrison.py:245–260  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

243if __name__ == "__main__":
244
245 def test1() -> None:
246 # a^(-1)
247 ainv = Matrix(3, 3, 0)
248 for i in range(3):
249 ainv[i, i] = 1
250 print(f"a^(-1) is {ainv}")
251 # u, v
252 u = Matrix(3, 1, 0)
253 u[0, 0], u[1, 0], u[2, 0] = 1, 2, -3
254 v = Matrix(3, 1, 0)
255 v[0, 0], v[1, 0], v[2, 0] = 4, -2, 5
256 print(f"u is {u}")
257 print(f"v is {v}")
258 print(f"uv^T is {u * v.transpose()}")
259 # Sherman Morrison
260 print(f"(a + uv^T)^(-1) is {ainv.sherman_morrison(u, v)}")
261
262 def test2() -> None:
263 import doctest

Callers

nothing calls this directly

Calls 3

transposeMethod · 0.95
sherman_morrisonMethod · 0.95
MatrixClass · 0.70

Tested by

no test coverage detected