A wave of power \$k\$ is an infinite array that looks like \$1,2,\dots,k,k-1,\dots,1,\dots,k,\dots,1,\dots\$, and so on. For example, a wave of power 3 starts with \$1,2,3,2,1,2,3,2,1,...\$, and repeats indefinitely. A wave of power 1 is an infinite array of ones. They happen to be beautifully expressed as $$w_k[t] = k - |(t - 1)\bmod(2k - 2) - k + 1|\text{, 1-indexed}$$
In this challenge, all waves are trimmed to their first \$n\$ elements, where \$n\$ is the length of the input array.
A decomposition of an array into waves is an array of coefficients of length \$n\$ such that the original array equals the sum of the waves multiplied by their corresponding coefficients. Formally, if the original array is \$A\$, the decomposition is an array \$B\$ such that for any \$i\$ (\$1 \le i \le n\$) the following equality holds: $$A[i] = \sum_{j=1}^\infty B[j] \cdot w_j[i]\text{, 1-indexed}$$
The waviness of an array is the index of the last non-zero value in its decomposition into waves.
The task is, given a positive integer array of length \$n\$, to calculate its waviness. Note that the decomposition can still include non-integer and negative numbers.
Test cases
All test cases below are 1-indexed. Your solution may use 0-indexing instead.
[1, 1, 1] -> 1 (decomposition: [1, 0, 0])
[1, 2, 1] -> 2 (decomposition: [0, 1, 0])
[1, 2, 3] -> 3 (decomposition: [0, 0, 1])
[1, 1, 2] -> 3 (decomposition: [1, -0.5, 0.5])
[1, 3, 3, 3, 1] -> 3 (decomposition: [-1, 1, 1, 0, 0])
[1, 2, 2, 4] -> 4 (decomposition: [0, 0.5, -0.5, 1]
[4, 6, 9, 1, 4, 3, 5] -> 7 (decomposition: [2, -0.5, 5, -5, 6.5, -1, -3]
[4, 6, 9, 1, 4, 3, 5, 7] -> 8 (decomposition: [2, -0.5, 5, -5, 6.5, -1, -10.5, 7.5])
This is tagged code-golf an uncommon justification, so the shortest answer wins.