Moved setZero template function above calcualteY for correct compilation.