Abstract
We introduce and study finite \emph{Bernoulli seam matrices} and \emph{cyclotomic \(q\)-sweep matrices}. These are explicit finite matrices on the unit group
\[
G_N=(\mathbb Z/N\mathbb Z)^\times
\]
whose character spectra recover special values of Dirichlet \(L\)-functions, imaginary and real quadratic class-number invariants, Gauss-twisted \(q\)-series, Ramanujan sums, and Dedekind correlations.
The normalized Bernoulli seam kernel is
\[
b_N(u)=\frac12-\frac{\widetilde u}{N},
\qquad
u\in G_N,
\]
where \(\widetilde u\in\{1,\dots,N-1\}\) is the standard representative. The primitive Bernoulli seam matrix is
\[
\mathsf A_N=\left(b_N(ab^{-1})\right)_{a,b\in G_N}.
\]
We prove that \(\mathsf A_N\) is diagonalized by the Dirichlet characters modulo \(N\), and that
\[
\boxed{
\mathsf A_Nv_\chi=L_N(0,\overline\chi)v_\chi,
}
\]
where
\[
L_N(0,\chi)=\sum_{a=1}^{N}\chi(a)\left(\frac12-\frac{a}{N}\right)
\]
is the value at \(0\) of the Dirichlet \(L\)-function associated with the character modulo \(N\), including the modulus-\(N\) Euler-factor convention. Equivalently, for the unnormalized seam-defect matrix
\[
\mathsf B_N=2\pi\mathsf A_N,
\]
one has
\[
\boxed{
\mathsf B_Nv_\chi=2\pi L_N(0,\overline\chi)v_\chi.
}
\]
Quadratic eigenspaces give class numbers. If \(D<0\) is a negative fundamental discriminant and \(\chi_D\) is the associated primitive quadratic character, then
\[
\boxed{
\mathsf B_{|D|}v_{\chi_D}
=
\frac{4\pi h(D)}{w_D}v_{\chi_D},
}
\]
where \(h(D)\) is the class number of \(\mathbb Q(\sqrt D)\) and \(w_D=\#\mathcal O_D^\times\). In particular, if \(p\equiv3\pmod4\) is prime and \(p>3\), then
\[
\boxed{
\mathsf A_pv_{\chi_{-p}}=h(-p)v_{\chi_{-p}},
\qquad
\mathsf B_pv_{\chi_{-p}}=2\pi h(-p)v_{\chi_{-p}}.
}
\]
Thus imaginary quadratic class numbers occur as explicit eigenvalues of finite rational matrices.
We derive exact seam Plancherel identities. For \(N>1\),
\[
\boxed{
\sum_{\chi\bmod N}|L_N(0,\chi)|^2
=
\frac{\varphi(N)}{12}
\left(
\varphi(N)+\frac{2}{N}\prod_{p\mid N}(1-p)
\right).
}
\]
For an odd prime \(p\), this becomes
\[
\boxed{
\sum_{\substack{\chi\bmod p\\ \chi(-1)=-1}}
|L(0,\chi)|^2
=
\frac{(p-1)^2(p-2)}{12p}.
}
\]
We also prove seam-dilation floor-sum identities. If \(\chi\) is nonprincipal modulo \(N\) and \((m,N)=1\), then
\[
\boxed{
\sum_{a=1}^{N}\left\lfloor\frac{ma}{N}\right\rfloor\chi(a)
=
\left(\overline{\chi(m)}-m\right)L_N(0,\chi).
}
\]
For \(p\equiv3\pmod4\), \(p>3\), this gives the class-number formula
\[
\boxed{
\sum_{a=1}^{p-1}
\left\lfloor\frac{ma}{p}\right\rfloor
\left(\frac ap\right)
=
\left(\left(\frac mp\right)-m\right)h(-p).
}
\]
In particular, the quadratic half-interval residue excess
\[
E_p=\sum_{1\le a<p/2}\left(\frac ap\right)
\]
satisfies
\[
\boxed{
E_p=
\left(2-\left(\frac2p\right)\right)h(-p)
=
\begin{cases}
h(-p), & p\equiv7\pmod8,\\[0.3em]
3h(-p), & p\equiv3\pmod8.
\end{cases}
}
\]
We also introduce logarithmic cyclotomic seam matrices with kernel
\[
\ell_N(u)=-\log|1-\zeta_N^u|,
\qquad
\zeta_N=e^{2\pi i/N}.
\]
For primitive even nonprincipal characters,
\[
\boxed{
\sum_{u\in G_N}\ell_N(u)\overline{\chi(u)}
=
\tau(\overline\chi)L(1,\chi).
}
\]
Consequently, for positive fundamental discriminants \(D>0\),
\[
\boxed{
\sum_{a=1}^{D}\chi_D(a)\bigl(-\log|1-\zeta_D^a|\bigr)
=
2h(D)\log\varepsilon_D,
}
\]
where \(\varepsilon_D>1\) is the fundamental unit. Equivalently,
\[
\boxed{
\frac{\prod_{\chi_D(a)=-1}|1-\zeta_D^a|}
{\prod_{\chi_D(a)=1}|1-\zeta_D^a|}
=
\varepsilon_D^{2h(D)}.
}
\]
Thus the Bernoulli seam matrix detects imaginary quadratic class numbers, while the logarithmic seam matrix detects real quadratic class-number regulator products.
Finally, for a \(q\)-series \(F(q)=\sum A(n)q^n\), we define cyclotomic \(q\)-sweep matrices
\[
\mathsf S_N(F;q)=\left(F(\zeta_N^{ab^{-1}}q)\right)_{a,b\in G_N}.
\]
They are diagonalized by characters. If \(\chi\) is primitive modulo \(N\), then the \(\chi\)-eigenvalue is
\[
\boxed{
\tau(\overline\chi)\sum_{n\ge1}A(n)\chi(n)q^n.
}
\]
Their \(q\)-sweep Mellin transforms recover the associated twisted Dirichlet series. The resulting finite spectral formalism organizes Bernoulli functions, generalized Bernoulli numbers, class numbers, cyclotomic units, Gauss sums, Ramanujan sums, Dedekind sums, and twisted \(q\)-series into one explicit matrix calculus.