求适用于带对角矩阵的LUDecomposition函数(NURBS全局插值用)
Great question—since you're working through The NURBS Book by Piegl and Tiller and already leveraging Numerical Recipes in C (Press88) for forward/backward substitution, you’re actually closer than you think to finding the right LUDecomposition function for your semi-banded matrix:
Start with Numerical Recipes in C itself
The book includes dedicated implementations for banded matrix operations that match your exact needs. Look for thebandecfunction (which handles LU decomposition of a banded matrix with specified semi-bandwidthsbw) andbanbks(the corresponding forward/backward substitution routine). These functions are built for compact banded storage (only storing non-zero elements within the semi-bandwidth), so you can adaptbandecdirectly to fit yourLUDecomposition(A, q, sbw)signature. This is ideal since you’re already familiar with the book’s code style.Check The NURBS Book’s supplementary content
Piegl and Tiller often include NURBS-tailored numerical method pseudocode in appendices or companion materials. Even if the main text focuses on interpolation theory, you might find simplified banded matrix LU decomposition steps that align perfectly with the global interpolation algorithm you’re implementing. Translating this pseudocode into working code will be straightforward given your existing work onForwardBackward.Reference open-source NURBS libraries
Battle-tested open-source NURBS implementations frequently include optimized banded matrix solvers. For example, the GLU NURBS library (part of the OpenGL utility toolkit) has source code for banded LU decomposition designed specifically for NURBS interpolation tasks. Examining these implementations can give you practical insights into edge cases and optimizations you might not find in general-purpose numerical texts.Build it from scratch (if you prefer)
If you want to implement the function yourself, the core logic for semi-banded LU decomposition focuses on restricting operations to the non-zero band:- For each row
i, compute the pivot element within the semi-bandwidth range. - Normalize the row using the pivot, then eliminate corresponding elements in subsequent rows (only within
sbwpositions below the current row). - Store the decomposition in the same compact banded storage format as the input matrix to save memory and computation time.
- For each row
内容的提问来源于stack exchange,提问作者nonremovable

