Exemple #1
0
    public static double[] daub2_matrix(int n)

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    DAUB2_MATRIX returns the DAUB2 matrix.
    //
    //  Discussion:
    //
    //    The DAUB2 matrix is the Daubechies wavelet transformation matrix
    //    with 2 coefficients.
    //
    //    The DAUB2 matrix is also known as the Haar matrix.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    10 May 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    //  Parameters:
    //
    //    Input, int N, the order of the matrix.
    //    N must be at least 2 and a multiple of 2.
    //
    //    Output, double DAUB2_MATRIX[N*N], the matrix.
    //
    {
        int i;

        if (n < 2 || n % 2 != 0)
        {
            Console.WriteLine("");
            Console.WriteLine("DAUB2_MATRIX - Fatal error!");
            Console.WriteLine("  Order N must be at least 2 and a multiple of 2.");
            return(null);
        }

        double[] a = typeMethods.r8mat_zero_new(n, n);

        double[] c = Coefficients.daub_coefficients(2);

        for (i = 0; i < n - 1; i += 2)
        {
            a[i + i * n]       = c[0];
            a[i + (i + 1) * n] = c[1];

            a[i + 1 + i * n]       = c[1];
            a[i + 1 + (i + 1) * n] = -c[0];
        }

        return(a);
    }
Exemple #2
0
    public static double[] daub12_matrix(int n)

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    DAUB12_MATRIX returns the DAUB12 matrix.
    //
    //  Discussion:
    //
    //    The DAUB12 matrix is the Daubechies wavelet transformation matrix
    //    with 12 coefficients.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    11 May 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    //  Parameters:
    //
    //    Input, int N, the order of the matrix.
    //    N must be at least 12 and a multiple of 2.
    //
    //    Output, double DAUB12_MATRIX[N*N], the matrix.
    //
    {
        int i;

        if (n < 12 || n % 2 != 0)
        {
            Console.WriteLine("");
            Console.WriteLine("DAUB12_MATRIX - Fatal error!");
            Console.WriteLine("  Order N must be at least 12 and a multiple of 2.");
            return(null);
        }

        double[] a = typeMethods.r8mat_zero_new(n, n);

        double[] c = Coefficients.daub_coefficients(12);

        for (i = 0; i < n - 1; i += 2)
        {
            int j = i;
            a[i + j * n] = c[0];
            j            = i + 1;
            a[i + j * n] = c[1];
            j            = typeMethods.i4_wrap(i + 2, 0, n - 1);
            a[i + j * n] = c[2];
            j            = typeMethods.i4_wrap(i + 3, 0, n - 1);
            a[i + j * n] = c[3];
            j            = typeMethods.i4_wrap(i + 4, 0, n - 1);
            a[i + j * n] = c[4];
            j            = typeMethods.i4_wrap(i + 5, 0, n - 1);
            a[i + j * n] = c[5];
            j            = typeMethods.i4_wrap(i + 6, 0, n - 1);
            a[i + j * n] = c[6];
            j            = typeMethods.i4_wrap(i + 7, 0, n - 1);
            a[i + j * n] = c[7];
            j            = typeMethods.i4_wrap(i + 8, 0, n - 1);
            a[i + j * n] = c[8];
            j            = typeMethods.i4_wrap(i + 9, 0, n - 1);
            a[i + j * n] = c[9];
            j            = typeMethods.i4_wrap(i + 10, 0, n - 1);
            a[i + j * n] = c[10];
            j            = typeMethods.i4_wrap(i + 11, 0, n - 1);
            a[i + j * n] = c[11];

            j = i;
            a[i + 1 + j * n] = c[11];
            j = i + 1;
            a[i + 1 + j * n] = -c[10];
            j = typeMethods.i4_wrap(i + 2, 0, n - 1);
            a[i + 1 + j * n] = c[9];
            j = typeMethods.i4_wrap(i + 3, 0, n - 1);
            a[i + 1 + j * n] = -c[8];
            j = typeMethods.i4_wrap(i + 4, 0, n - 1);
            a[i + 1 + j * n] = c[7];
            j = typeMethods.i4_wrap(i + 5, 0, n - 1);
            a[i + 1 + j * n] = -c[6];
            j = typeMethods.i4_wrap(i + 6, 0, n - 1);
            a[i + 1 + j * n] = c[5];
            j = typeMethods.i4_wrap(i + 7, 0, n - 1);
            a[i + 1 + j * n] = -c[4];
            j = typeMethods.i4_wrap(i + 8, 0, n - 1);
            a[i + 1 + j * n] = c[3];
            j = typeMethods.i4_wrap(i + 9, 0, n - 1);
            a[i + 1 + j * n] = -c[2];
            j = typeMethods.i4_wrap(i + 10, 0, n - 1);
            a[i + 1 + j * n] = c[1];
            j = typeMethods.i4_wrap(i + 11, 0, n - 1);
            a[i + 1 + j * n] = -c[0];
        }

        return(a);
    }