Let $A \in \mathbb{R}^{n\times m}, B \in \mathbb{R}^m$.
I'm trying to compute the coefficients of $n$ polynomials $C_i = (c_0^i, c_1^i, \cdots, c_{n-1}^i)$.
where $\displaystyle \sum_{j=0}^{n-1} c_j^i x^j = \sum_{k=0}^{m-1} B_k \prod_{l=0, l \neq i}^{n-1}(1+A_{lk}x)$.
Right now I have tried with enumerate each $i$ of $n$ and then enumerate each $j$ of $m$ compute the coefficients for $\displaystyle\prod_{l=0, l \neq i}^{n-1}(1+A_{lk}x)$ first and then sum them up.
And I'm wondering if there are any more efficient approaches?
For example, using a toy example with $n=3, m=2$:
$$ A = \left[ \begin{array}{cc} a_1 & b_1 \\ a_2 & b_2 \\ a_3 & b_3 \\ \end{array} \right], B = \left[\begin{array}{ccc} z_1 \\ z_2\end{array}\right] $$
I'm looking to compute for three polynomial $f_1, f_2, f_3$: $$ \begin{aligned} f_1(x) & = z_1(1+a_2x)(1+a_3x) \\ & + z_2(1+b_2x)(1+b_3x) \end{aligned} $$, $$ \begin{aligned} f_2(x) & = z_1(1+a_1x)(1+a_3x) \\ & + z_2(1+b_1x)(1+b_3x) \end{aligned} $$, $$ \begin{aligned} f_3(x) & = z_1(1+a_1x)(1+a_2x) \\ & + z_2(1+b_1x)(1+b_2x) \end{aligned} $$
Clearly, this is only for illustration purposes, in my real problem, $m$ can be really big at the scale of $2^{20}$, $n$ is typically at $1000$ scale, and I need to do the same type of computing with different $A, B$ for millions of times.