I have a pentadiagonal symmetric matrix , with elements on the diagonal, on the 1st upper-diagonal and 1st lower-diagonal and at the n-th upper and lower diagonal. ( n changes values from one matrix to an other but the form of the matrices is always pentadiagonal )
For example for a 6x6 matrix, if n=4 I have this matrix. ( Notice that A[4,3]=A[3,4]=0 not -0.09) \begin{pmatrix} \ 32.18 & -0.09 & 0 & -16 & 0 &0 \\ -0.09 & 32.18 & -0.09 & 0 & -16& 0 \\ 0 & -0.09 & 32.18 & 0 & 0 & -16 \\ -16 & 0 & 0 & 32.18 & -0.09 & 0 \\0 & -16 & 0 & -0.09 & 32.18 & -0.09 \\ 0 & 0 & -16 & 0 & -0.09 & 32.18 \end{pmatrix}
Is there any way to calculate the A*x product where x is a (6x1) vector, ignoring the multiplications by zeros no matter what the value of n is?
In your particular case, you can partition the matrix into $$ M = \left[\begin{array}{ccc|ccc} \ 32.18 & -0.09 & 0 & -16 & 0 &0 \\ -0.09 & 32.18 & -0.09 & 0 & -16& 0 \\ 0 & -0.09 & 32.18 & 0 & 0 & -16\\ \hline -16 & 0 & 0 & 32.18 & -0.09 & 0 \\0 & -16 & 0 & -0.09 & 32.18 & -0.09 \\ 0 & 0 & -16 & 0 & -0.09 & 32.18 \end{array}\right] = \pmatrix{A & -16 I\\ -16I & A}. $$ If you partition the column-vector $x$ into $x = (x_1,x_2)$, each vector size $3$, then we have $$ Mx = \pmatrix{A & -16I\\-16I & A} \pmatrix{x_1\\x_2} = \pmatrix{Ax_1 - 16x_2\\-16x_1 + Ax_2}. $$ Also, with the vectorization operator $\operatorname{vec}:\Bbb R^{3 \times 2} \to \Bbb R^6$, we have $$ Mx = \operatorname{vec}(A\operatorname{vec}^{-1}(x) + \operatorname{vec}^{-1}(x)B), $$ where $B = \pmatrix{0&-16\\-16 & 0}$. Perhaps these ideas generalize.