Ejemplo n.º 1
0
    def test_scalar_coefs_ops(self):
        """::Check to make sure the scalar coefficient ops are working            
        """

        _ = sp.ones_coefs(12, 8)
        _ = sp.random_coefs(10, 10) + 1j * sp.random_coefs(10, 10)
        _ = sp.zeros_coefs(21, 18)

        ss = 1j - 2 / (sp.zeros_coefs(5, 4) + .001) + \
                4 * sp.random_coefs(5, 4) / 6.0
        ss += sp.ones_coefs(5, 4, coef_type=sp.scalar)

        _ = 1 + 2 * sp.ones_coefs(3, 3) / 4 * sp.ones_coefs(3, 3) - 2

        ds1 = 1j + 4 * sp.ones_patt_uniform(5, 8) / 3 - \
            sp.ones_patt_uniform(5, 8) - 1 + \
            10 * sp.random_patt_uniform(5, 8)

        ds1.single_val

        sp.array(ds1)

        _ = sp.zeros_coefs(10, 10)

        self.assertTrue(True)
Ejemplo n.º 2
0
    def test_div_same_sizes(self):
        """::can add two VectorPatternUniform that are same sized """
        z1 = sp.ones_patt_uniform(11, 10, patt_type=sp.vector)
        z2 = sp.random_patt_uniform(11, 10, patt_type=sp.vector)
        a = z1 / (z2 + 0.0001)
        b = z1 / (z2 + 0.0001)
        c = a - b

        res = True
        if sp.L2_patt(c) / sp.L2_patt(b) > 1e-13:
            res = False

        self.assertTrue(res)
Ejemplo n.º 3
0
    def test_mult_same_sizes(self):
        """::can mult two ScalarPatternUniform that are same sized """
        z1 = sp.ones_patt_uniform(11, 10)
        z2 = sp.random_patt_uniform(11, 10)
        a = z1 * z2
        b = z1 * z2
        c = a - b

        res = True
        if sp.L2_patt(c) / sp.L2_patt(b) > 1e-13:
            res = False

        self.assertTrue(res)
Ejemplo n.º 4
0
    def test_div_constant_left_right(self):
        """::can mult a scalar to ScalarPatternUniform from both sides"""
        z1 = sp.ones_patt_uniform(11, 10)

        a = z1 / 1j * 1.1
        b = z1 / 1j * 1.1
        c = a - b

        res = True
        if sp.L2_patt(c) / sp.L2_patt(b) > 1e-13:
            res = False

        a = 1j * 1.1 / z1
        b = 1j * 1.1 / z1
        c = a - b

        if sp.L2_patt(c) / sp.L2_patt(b) > 1e-13:
            res = False

        self.assertTrue(res)
Ejemplo n.º 5
0
    def test_sub_constant_left_right(self):
        """::can sub a scalar to VectorPatternUniform from both sides"""
        z1 = sp.ones_patt_uniform(11, 10, patt_type=sp.vector)

        a = z1 - 1j * 1.1
        b = z1 - 1j * 1.1
        c = a - b

        res = True
        if sp.L2_patt(c) / sp.L2_patt(b) > 1e-13:
            res = False

        a = 1j * 1.1 - z1
        b = 1j * 1.1 - z1
        c = a - b

        if sp.L2_patt(c) / sp.L2_patt(b) > 1e-13:
            res = False

        self.assertTrue(res)
Ejemplo n.º 6
0
 def test_div_diff_sizes(self):
     """::can't div two VectorPatternUniform that are different """
     z1 = sp.zeros_patt_uniform(11, 10, patt_type=sp.vector)
     z2 = sp.ones_patt_uniform(12, 12, patt_type=sp.vector)
     with self.assertRaises(ValueError):
         _ = z1 / z2
Ejemplo n.º 7
0
 def test_mult_diff_sizes(self):
     """::can't mult two VectorPatternUniform that are different """
     z1 = sp.ones_patt_uniform(12, 12, patt_type=sp.vector)
     z2 = sp.random_patt_uniform(12, 10, patt_type=sp.vector)
     with self.assertRaises(ValueError):
         _ = z1 * z2
Ejemplo n.º 8
0
 def test_make_sure_even_cols_o(self):
     """::raise an error if I try to set ncol odd ones"""
     with self.assertRaises(ValueError):
         _ = sp.ones_patt_uniform(13, 17, patt_type=sp.vector)
Ejemplo n.º 9
0
 def test_div_diff_sizes(self):
     """::can't divide two ScalarPatternUniform that are different """
     z1 = sp.zeros_patt_uniform(11, 10)
     z2 = sp.ones_patt_uniform(12, 12)
     with self.assertRaises(ValueError):
         _ = z1 / z2
Ejemplo n.º 10
0
 def test_mult_diff_sizes(self):
     """::can't multiply two ScalarPatternUniform that are different """
     z1 = sp.ones_patt_uniform(12, 12)
     z2 = sp.random_patt_uniform(12, 10)
     with self.assertRaises(ValueError):
         _ = z1 * z2
Ejemplo n.º 11
0
    sp.plot_coefs(scoef)

    print scoef[:, 2]

    sp = sp.ispht(scoef, 6, 8)

if T5:
    rr = sp.random_coefs(10, 10) + 1j * sp.random_coefs(10, 10)

    ss = 1j - 2 / (sp.zeros_coefs(5,4) + .001) + \
            4* sp.random_coefs(5,4) / 6.0
    ss += sp.ones_coefs(5, 4, coef_type=sp.scalar)

    qq = 1 + 2 * sp.ones_coefs(3, 3) / 4 * sp.ones_coefs(3, 3) - 2

    ds1 =1j + 4*sp.ones_patt_uniform(5,8)/3 - \
        sp.ones_patt_uniform(5,8) -1 + \
        10*sp.random_patt_uniform(5,8)

    print ds1.single_val

    print sp.array(ds1)

    zc = sp.zeros_coefs(10, 10)
    zc[2, 1] = 1.0
    zc[2, -2] = 3.0
    zc[0, 0] = 1j * 5.0
    zc[5, 1] = 7.0

    print zc[2, 1]
    print zc[2, -2]