def __new__(cls, label, indices, eta_dict):
     indices = tuple(indices)
     del(eta_dict)
     if label == 'C' and indices == (0,):
         # C depends on two variables
         indices = (0, 0)
     matrix = [Symbol(label+str(list(indices)), positive=True)]
     new_instance = Matrix.__new__(cls, matrix)
     return new_instance
Beispiel #2
0
 def __new__(cls, *args):
     if len(args) == 1 and isinstance(args[0], Matrix) \
             and args[0].shape == (2, 1):
         temp = args[0]
     elif len(args) == 2:
         temp = ((args[0],), (args[1],))
     else:
         raise ValueError(filldedent('''
             Expecting 2x1 Matrix or the 2 elements of
             the Matrix but got %s''' % str(args)))
     return Matrix.__new__(cls, temp)
Beispiel #3
0
 def __new__(cls, *args):
     if len(args) == 1 and isinstance(args[0], Matrix) \
                       and args[0].shape == (2, 1):
         temp = args[0]
     elif len(args) == 2:
         temp = ((args[0],), (args[1],))
     else:
         raise ValueError(filldedent('''
             Expecting 2x1 Matrix or the 2 elements of
             the Matrix but got %s''' % str(args)))
     return Matrix.__new__(cls, temp)
Beispiel #4
0
    def __new__(cls, *args):

        if len(args) == 4:
            temp = ((args[0], args[1]), (args[2], args[3]))
        elif len(args) == 1 and isinstance(args[0],
                                           Matrix) and args[0].shape == (2, 2):
            temp = args[0]
        else:
            raise ValueError(
                filldedent("""
                Expecting 2x2 Matrix or the 4 elements of
                the Matrix but got %s""" % str(args)))
        return Matrix.__new__(cls, temp)