Example #1
0
def sobol_test03():
    """
    sobol_test03 tests i4_bit_lo0.
    """
    print('\nSOBOL_TEST03'
          '  I4_BIT_LO0 returns the location of the low 0 bit.'
          '\n     I     I4_BIT_LO0(I)')

    seed = 123456789

    target = ([[22, 1], [96, 1], [83, 3], [56, 1], [41, 2], [6, 1], [26, 1],
               [11, 3], [4, 1], [64, 1]])

    results = np.full((10, 2), np.nan)
    for test in range(10):

        [i, seed] = i4_uniform(0, 100, seed)
        j = i4_bit_lo0(i)

        results[test, :] = i, j

        print('%6d %6d' % (i, j))

    assert np.all(target == results), "Array values not as expected"

    return
Example #2
0
def sobol_test02():
    """
    sobol_test02 tests i4_bit_hi1.
    """
    print('\nSOBOL_TEST02'
          '  I4_BIT_HI1 returns the location of the high 1 bit.'
          '\n     I     I4_BIT_HI1(I)\n')

    seed = 123456789

    target = np.array([[22, 5], [96, 7], [83, 7], [56, 6], [41, 6], [6, 3],
                       [26, 5], [11, 4], [4, 3], [64, 7]])

    results = np.full((10, 2), np.nan)
    for test in range(10):

        [i, seed] = i4_uniform(0, 100, seed)

        j = i4_bit_hi1(i)
        results[test, :] = i, j

        print('%6d %6d' % (i, j))

    assert np.all(target == results), "Array values not as expected"

    return
Example #3
0
def sobol_test01():
    """
    sobol_test01 tests bitxor.
    """
    print(
        "\nSOBOL_TEST01"
        "------------"
        "  BITXOR is a MATLAB intrinsic function which returns"
        "  the bitwise exclusive OR of two integers."
        "\n     I     J     BITXOR(I,J)"
    )

    seed = 123456789

    target = np.array(
        [
            [22, 96, 118],
            [83, 56, 107],
            [41, 6, 47],
            [26, 11, 17],
            [4, 64, 68],
            [6, 45, 43],
            [40, 76, 100],
            [80, 0, 80],
            [90, 35, 121],
            [9, 1, 8],
        ]
    )

    results = np.full((10, 3), np.nan)
    for test in range(10):

        [i, seed] = i4_uniform(0, 100, seed)
        [j, seed] = i4_uniform(0, 100, seed)
        k = np.bitwise_xor(i, j)
        results[test, :] = i, j, k

        print("%6d  %6d  %6d" % (i, j, k))

    assert np.all(target == results), "Array values not as expected"

    return
Example #4
0
def sobol_test03():
    """
    sobol_test03 tests i4_bit_lo0.
    """
    print("\nSOBOL_TEST03" "  I4_BIT_LO0 returns the location of the low 0 bit." "\n     I     I4_BIT_LO0(I)")

    seed = 123456789

    target = [[22, 1], [96, 1], [83, 3], [56, 1], [41, 2], [6, 1], [26, 1], [11, 3], [4, 1], [64, 1]]

    results = np.full((10, 2), np.nan)
    for test in range(10):

        [i, seed] = i4_uniform(0, 100, seed)
        j = i4_bit_lo0(i)

        results[test, :] = i, j

        print("%6d %6d" % (i, j))

    assert np.all(target == results), "Array values not as expected"

    return
Example #5
0
def sobol_test02():
    """
    sobol_test02 tests i4_bit_hi1.
    """
    print("\nSOBOL_TEST02" "  I4_BIT_HI1 returns the location of the high 1 bit." "\n     I     I4_BIT_HI1(I)\n")

    seed = 123456789

    target = np.array([[22, 5], [96, 7], [83, 7], [56, 6], [41, 6], [6, 3], [26, 5], [11, 4], [4, 3], [64, 7]])

    results = np.full((10, 2), np.nan)
    for test in range(10):

        [i, seed] = i4_uniform(0, 100, seed)

        j = i4_bit_hi1(i)
        results[test, :] = i, j

        print("%6d %6d" % (i, j))

    assert np.all(target == results), "Array values not as expected"

    return