  We generalize recent matrix-based factorization theorems for Lambert series
generating functions generating the coefficients $(f \ast 1)(n)$ for some
arithmetic function $f$. Our new factorization theorems provide analogs to
these established expansions generating sums of the form $\sum_{d: (d,n)=1}
f(d)$ (type I) and the Anderson-Apostol sums $\sum_{d|(m,n)} f(d) g(n/d)$ (type
II) for any arithmetic functions $f$ and $g$. Our treatment of the type II sums
includes a matrix-based factorization method relating the partition function
$p(n)$ to arbitrary arithmetic functions $f$. We also conclude the last section
of the article by directly expanding new formulas for an arithmetic function
$g$ by the type II sums using discrete Fourier transforms for functions over
inputs of greatest common divisors and by suitably defined orthogonal
polynomial sequences whose weight function we can define by a discrete time
Fourier transform (DTFT) involving the partition function $p(n)$. There are
numerous applications and special cases of our new results which we are able to
cite as examples in the article. Particular cases of the applications we give
in the article include new identities for Euler's totient function, the
Ramanujan sums $c_q(n)$, the generalized sum-of-divisors functions, the Mertens
function which is the summatory function of the M\"obius function, and the
cyclotomic polynomials.
