Matrix arithmetic in multi-double formats
- Cost
- terms for an by product, each double operations (about 140 for ); the block recursive LU decomposition and triangular solving cost a constant times the product.
The plain formats of dfloat (dfloat.h) implement the matrix methods of the generic rings, so that gr_mat_mul, gr_mat_lu, gr_mat_nonsingular_solve, gr_mat_inv and the eigensolvers of gr_mat run on them with the generic block algorithms and fast base cases. This page describes the product kernel and the base cases; the expansions themselves and their error-free transformations are described in Double-word and multi-double arithmetic.
One double#
For the product is flint_dgemm, an optimised BLAS-like double precision product. A complex product is a single real product of twice the size: the complex matrix , read as an real matrix of parts, times the real matrix
(with interleaved rows and columns, a copy of ), whose result is the matrix of the parts of .
The product kernel#
For the product is a SIMD kernel. The columns of are packed, a block of columns at a time ( with AVX2 or NEON and 8 with AVX-512), in structure-of-arrays form: component of the entries is one vector register. Each row of then runs along a block, its entries broadcast to the lanes, so that the lanes compute entries of in parallel.
The terms of a dot product are not renormalised one by one. The product of two expansions and splits into order sums , where collects the products with and the error terms of the products of the order below (as in the scalar multiplication kernel; exact except for the plain additions of the last order, which are relative to the term). These go into accumulators of the order sums of the whole dot product: each addition into is a TwoSum whose error term goes on to , and only the additions into the extra accumulator round. The accumulators are renormalised every 32 terms, before their magnitudes can drift apart, and at the end. For d4 this costs about 140 double operations per term, a third fewer than a renormalised product followed by a renormalised sum, and it is more accurate than a dot product of rounded products: the error is that of one rounding of the exact dot product plus the terms dropped from each product. For it was measured at most for entries of uniform magnitude and for magnitudes spread over , against 1.0 and 5.1 for the classical algorithm with the scalar operations. (Without the extra accumulator the kernel lost five to eight bits.)
Only exact operations and fused multiply-subtracts (for the error terms of products) are used, so the results do not depend on the vector width. A complex term is four real terms; with real entries the zero imaginary parts cost nothing extra, since the additions of an exact zero are exact. Two rows of are processed together, sharing the loads of . The rows of are split into panels small enough for the panel and a packed block of to stay in the L2 cache, and the panels run in parallel with the threads FLINT is set to use. An entry whose result is not finite is recomputed with the scalar operations.
The kernel is used from dimension 2. Its cost is cubic, while the block algorithms of arb_mat_approx_mul and acb_mat_approx_mul (exact integer matrix products through BLAS) are cheaper per term for large matrices; from dimension 1600, 1000 and 600 (d2, d3, d4; complex: 1500, 900, 500) the entries are converted to arf_t and multiplied at bits, with an accuracy in the norm of the blocks rather than entrywise. This makes dfloat depend on arb_mat and acb_mat, which it otherwise sits below; it is a provisional solution until a fast arbitrary-precision floating-point matrix product is available at a lower level.
LU decomposition and triangular solving#
gr_mat_lu is the block recursive algorithm (gr_mat_lu_recursive) above 16 rows and columns, which spends most of its time in matrix products . It leaves to the base case the factorization of tall panels of a few columns, where the generic classical algorithm, working along the short rows, pays a function call per entry. The base case has the same pivoting (the entry of largest magnitude, judged by the head of the expansion) and the same layout of as gr_mat_lu_classical, but eliminates column by column, four rows at a time in the SIMD lanes: the multipliers for the rows below the pivot , then with broadcast. The results are those of the scalar operations.
The triangular solvers are the block recursive algorithms above 16. In the base case, for four or more right-hand sides the rows of the solution are computed as vectors, , with the SIMD products of a vector by a scalar; for fewer, by the classical algorithm with dot products along the rows of .
The recursion subtracts each product from the block it updates in a separate pass, for want of a fused operation in gr_mat; such an operation, as a ring method tuned for each type, would save a temporary matrix and a pass over it.
Accuracy#
The decompositions are those of Gaussian elimination with partial pivoting in the arithmetic of the format, backward stable in the usual sense with the unit roundoff replaced by the effective accuracy of the format, a small multiple of . Measured on random linear systems, the solutions are as accurate as with arf_t at bits to within a bit; see Floating-point backends for the approximate functions for how the approximate functions of arb_mat use this.
Use in FLINT#
- The methods
GR_METHOD_MAT_MUL,GR_METHOD_MAT_LU,GR_METHOD_MAT_NONSINGULAR_SOLVE_TRILandGR_METHOD_MAT_NONSINGULAR_SOLVE_TRIUof the plain real and complexdfloatrings; timings in Linear algebra. - The approximate functions of
arb_matandacb_mat(LU decomposition, solving, inversion, eigenvalues) convert to these rings when they are faster.
Referenced from#
- Verified linear algebra (algorithm)
gr_ctx_init_dfloat
The FLINT team, “Matrix arithmetic in multi-double formats,” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/algorithms/floating-point/dfloat-matrices.html (generated 2026-11-07).
@misc{flint-doc-algorithms-floating-point-dfloat-matrices,
author = {{The FLINT team}},
title = {{Matrix arithmetic in multi-double formats}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/algorithms/floating-point/dfloat-matrices.html},
note = {Generated 2026-11-07}
}