NumPy is a Python library for efficient numeric computation. It provides operable arrays and matrices, making familiar arithmetic work across collections of values as well as individual numbers. section 6.3.5 section 10.1.2
Use NumPy to:
- Declare matrices and column vectors. section 6.3.5
- Solve systems of linear equations with np.linalg.solve. section 6.3.5
- Create coordinate grids with linspace and meshgrid for numeric calculations over a region. section 10.1.2
- Adapt scalar functions for array inputs with @np.vectorize when conditional branching makes direct array processing ambiguous. section 10.1.2
Solving a small linear system
Represent the coefficient matrix and right-hand side as NumPy arrays, then call np.linalg.solve(a, b) to obtain the solution vector. section 6.3.5
N = 100 x = np.linspace(-1.4, 1.4, N) #1 y = np.linspace(-1.4, 1.4, N) #1 X, Y = np.meshgrid(x, y) #2 SDF = (X*X + Y*Y)**0.5 - 1
Inspect how linspace and meshgrid turn coordinate ranges into arrays suitable for evaluating a circle’s signed distance function. section 10.1.2






