function generalized_cosine_window(M, a_0) {
    if (M < 1) {
        return new Float64Array();
    }
    if (M === 1) {
        return new Float64Array([1]);
    }

    const a_1 = 1 - a_0;
    const factor = 2 * Math.PI / (M - 1);

    const cos_vals = new Float64Array(M);
    for (let i = 0; i < M; ++i) {
        cos_vals[i] = a_0 - a_1 * Math.cos(i * factor);
    }
    return cos_vals;
}
Helper function to generate windows that are special cases of the generalized cosine window.
See https://www.mathworks.com/help/signal/ug/generalized-cosine-windows.html for more information.
@param {number} M Number of points in the output window. If zero or less, an empty array is returned.
@param {number} a_0 Offset for the generalized cosine window.
@returns {Float64Array} The generated window.