Пример #1
0
 def __init__(self, data, dims=None, copy=True, info=None, unit=None):
     data = np.asanyarray(data)
     if isinstance(data, ZArray):
         if data.shape[-1] != data.shape[-2]:
             raise ValueError("%s must be a square matrix" % self.shortname)
         data = _hfarray(inv(data))
         self[:] = data
     _MultiPortArray.__init__(self, data, dims, copy=copy, info=info, unit=unit)
Пример #2
0
def convert(fromP, toP, a):
    """Converts multiports using permutation matrices as described in [#]

    [#] J. Stenarson and K. Yhland "" IEEE Transactions on Instrumentation and
        Measurements 2009 vol. x no. 4 pp. xx-yy.

    """
    PB = inv(toP)
    PA = fromP
    P = matrix_multiply(PA, PB)
    tau1 = P[..., :2, :2]
    sigma1 = P[..., :2, 2:]
    tau2 = P[..., 2:, :2]
    sigma2 = P[..., 2:, 2:]
    A = inv(tau1 - matrix_multiply(a, tau2))
    B = -sigma1 + matrix_multiply(a, sigma2)
    res = matrix_multiply(A, B)
    return res, A, B
Пример #3
0
def convert(fromP, toP, a):
    """Converts multiports using permutation matrices as described in [#]

    [#] J. Stenarson and K. Yhland "" IEEE Transactions on Instrumentation and
        Measurements 2009 vol. x no. 4 pp. xx-yy.

    """
    PB = inv(toP)
    PA = fromP
    P = matrix_multiply(PA, PB)
    tau1 = P[..., :2, :2]
    sigma1 = P[..., :2, 2:]
    tau2 = P[..., 2:, :2]
    sigma2 = P[..., 2:, 2:]
    A = inv(tau1 - matrix_multiply(a, tau2))
    B = -sigma1 + matrix_multiply(a, sigma2)
    res = matrix_multiply(A, B)
    return res, A, B
Пример #4
0
 def __init__(self, data, dims=None, copy=True, info=None, unit=None):
     data = np.asanyarray(data)
     if isinstance(data, ZArray):
         if data.shape[-1] != data.shape[-2]:
             raise ValueError("%s must be a square matrix" % self.shortname)
         data = _hfarray(inv(data))
         self[:] = data
     _MultiPortArray.__init__(self,
                              data,
                              dims,
                              copy=copy,
                              info=info,
                              unit=unit)
Пример #5
0
def switch_correct(b, a):
    Sm = matrix_multiply(b, inv(a))
    return Sm
Пример #6
0
def switch_correct(b, a):
    Sm = matrix_multiply(b, inv(a))
    return Sm
Пример #7
0
 def test_1(self):
     res = hfmath.inv(self.m)
     self.assertAllclose(res, np.linalg.inv([[1., 2], [3, 4]]))
     self.assertEqual(res.shape, (3, 2, 2))
     self.assertEqual(res.dims, (self.J, self.mi, self.mj))