# M62. Spectral elements: a factorization that uses what the matrix is **Package:** C16, its second half: the sparse system of the points that elements share is factorized as a general complex matrix, on one core, whatever the problem. A real problem has a real matrix, and a symmetric operator a symmetric one: a factorization that uses both takes a fraction of the memory and of the time. ## What was built - **`methods::sparse`**: the sparse matrix of a shape, factorized as what it is. A matrix with a complex entry by the general factorization in complex numbers, as before. A real one in real numbers. A real one that is symmetric and of one sign by Cholesky's method. - **Given values on the right-hand side.** A value that a condition gives was an equation of its own, with the value still an unknown in the equations of its neighbours. It is now taken to their right-hand sides, which leaves the matrix of a symmetric operator symmetric. - **The points inside elements in real numbers** where the equation and all it is given are real: the dense blocks of an element are held and solved as real matrices. - **One factorization for many right-hand sides**, which the modes of a shape use, is real throughout. - **A shift that is found.** The modes of a shape need the operator shifted until it is positive. Cholesky's method tells whether it is. Where it is not, the shift is raised fourfold and the operator factorized again. A condition through which the boundary feeds the modes, which decision D58.2 refused, is solved. - **Twice the points for a real problem**: a plan may hold 160 000 on the sides of elements, and the planner solves with up to 60 000. ## What it reaches On a rectangle with a ridge, whose two corners with a singularity have 18 layers each (2 256 elements), on four cores: | Problem | Degree | Before | After | |---|---|---|---| | $-\nabla^2 u = 1$ | 8 | 1.5 s, 0.9 GB | 0.4 s, 0.3 GB | | $-\nabla^2 u = 1$ | 12 | 4.8 s, 2.0 GB | 1.3 s, 0.7 GB | | $-\nabla^2 u = 1$ | 16 | 11 s, 3.7 GB | 2.8 s, 1.3 GB | | $\nabla^2 u + 30u = 1$ | 12 | 4.2 s, 2.0 GB | 2.3 s, 1.1 GB | | Two modes, no slope on the wall | 8 | 2.9 s, 1.0 GB | 1.0 s, 0.4 GB | | Two modes, no slope on the wall | 12 | 10.7 s, 2.9 GB | 3.1 s, 1.0 GB | On the unit disk at the degree 8, by what the matrix is: | Points on the sides of elements | Real, of one sign | Real | Complex | |---|---|---|---| | 24 900 | 0.3 GB, 0.3 s | 0.4 GB, 0.7 s | 0.7 GB, 1.3 s | | 49 900 | 0.4 GB, 0.7 s | 0.9 GB, 1.9 s | 1.6 GB, 4.0 s | | 99 500 | 0.8 GB, 1.6 s | 2.3 GB, 6.1 s | | | 145 200 | 1.1 GB, 2.4 s | | | The planners gain with it. For the membrane on the L-shape the planner takes 0.9 s where it took 2.9 s. On the rectangle with a ridge the planner for a stationary problem stopped at 30 000 points and reported the solution as not resolved. It now goes on to the degree 12 and says what is true: that what is left is the singularity inside the innermost layer. Six modes of the L-shape take 3.7 s where they took 8.0 s. The solutions are the same to rounding: the values on the ridge agree with those before to thirteen digits. The tests of every problem on a shape pass unchanged, but for the two that expected a refusal which is no longer one. ## Decisions ### D62.1. What a matrix is, is read off its entries *Developer, 2026-11-20.* The assembly on a shape is one code for every equation, in complex numbers. To know that a matrix is real or symmetric, the code that factorizes it could be told so by every path that assembles one, each of which would then have to be right about it for good. It reads the entries: a matrix without an imaginary part is real, and one whose two triangles hold the same places with values that agree to $10^{-10}$ of the largest is symmetric. That costs a pass over the entries and a sort, and no path can be wrong about it. ### D62.2. Cholesky's method is tried, where the equation suggests it *Developer, 2026-11-20.* Whether a symmetric matrix is of one sign cannot be read off its entries. Cholesky's method finds out: a pivot that is not positive ends it, and the general factorization is taken. A failed attempt costs up to a factorization, so it is made only where the term without derivatives does not work against the second derivatives, as it does in the Helmholtz equation. The sign of the leading coefficient says which of the matrix and its negative to try. ### D62.3. A given value is no unknown *Developer, 2026-11-20.* With the row of a given value replaced by the value, and its column left in the other rows, the matrix of Poisson's equation is not symmetric. The column is taken to the right-hand side as the matrix is assembled, for every equation: for a general matrix it changes nothing that matters, and it is one code. ### D62.4. Real blocks, complex assembly *Developer, 2026-11-20.* The dense blocks of the elements are generic over the number they are held in, real or complex. The assembly that fills them is not: it stays in complex numbers, and a real block takes the real parts. To make the assembly generic would have changed every formula of the method for a part of the work that is small. Whether a problem is real is decided before the elimination, from its coefficients, its conditions and what it is given. ### D62.5. The shift of a mode problem is found, not known *Developer, 2026-11-20.* Decision D58.2 refused a condition through which the boundary feeds the modes, since no shift was known that makes the operator positive, and a shift that is too small returns modes that are not the lowest without a sign of it. The sign is now there: Cholesky's method does not go through. The shift starts where it did and is raised fourfold, at most ten times, until it does. A square whose sides feed it has the lowest eigenvalue $-2k^2$ with $k\tanh(k/2) = 1$, which the test checks. ### D62.6. Twice the points for a real problem *Developer, 2026-11-20.* The limits on the points of a plan and of the planner stand for memory: four gigabytes, and one. A real problem takes half the memory of a complex one, and a third where its matrix is of one sign. Its limits are doubled, whether or not its matrix is symmetric, so that the limit is known before anything is assembled. ### D62.7. Not done here *Developer, 2026-11-20.* The factorization still runs on one core. The library can use threads in it, behind a feature that is off, and what would have to be shown is that the bits of a solution do not depend on their number (decision D69). A real symmetric matrix of both signs, as of the Helmholtz equation, has a factorization with pivots on the diagonal, at half the memory of the general one: the library offers it through its low-level interface only, with the workspace and the permutation in the caller's hands. A system on a shape is factorized and eliminated as before. Each is a part of its own. ## What is left - The sparse factorization on several cores. - A symmetric matrix of both signs. - Systems on a shape in real numbers. - The elimination inside elements gains little from real numbers: by Cholesky's method for a symmetric block it would take half.