I'm doing a digital filter and using a vector and SIMD instructions to make it faster, but during debugging I noticed that when a new vector was created it only initialized half of the items in the vector, for example when creating a vector with length of 8, only the first 4 items of the vector would have value, the rest would be 0, even with the array that is used to create the vector having 31 items, all different than 0. This is causing the filter use only half of the coefficients and half the data.
The relevant code is below.
var simdLength = Vector<float>.Count;
var leftOver = m_filterSize % simdLength;
for (int i = 0; i < m_filterSize - leftOver; i += simdLength)
{
var filterVector = new Vector<float>(m_filter, i);
var dataVector = new Vector<float>(data, i);
filteredValueVector += filterVector * dataVector;
}
There is some code after to treat the left over but it is not a vector and works fine.