Exemplo n.º 1
0
    def __init__(self, *args):

        from numpy import ndarray
        keep_link = False
        own_data = False
        if len(args) == 1:
            if isinstance(args[0], list):
                args = (args[0], len(args[0]))
                own_data = True
            elif isinstance(args[0], ndarray):
                if args[0].dtype != 'float64':
                    raise ValueError('Must be float64 array')
                else:
                    args = (args[0], args[0].shape[0])
                    # in this case, args[0] need to be maintained
                    # in this object.
                    keep_link = True

        this = _vector.new_Vector(*args)
        try:
            self.this.append(this)
        except Exception:
            self.this = this

        if keep_link:
            self._link_to_data = args[0]
        if own_data:
            self.MakeDataOwner()
Exemplo n.º 2
0
    def __init__(self, *args):
        r"""
        __init__(Vector self) -> Vector
        __init__(Vector self, Vector arg2) -> Vector
        __init__(Vector self, int s) -> Vector
        __init__(Vector self, double * _data, int _size) -> Vector
        __init__(Vector self, int size_, mfem::MemoryType mt) -> Vector
        __init__(Vector self, Vector v, int offset, int size) -> Vector
        """

        from numpy import ndarray, ascontiguousarray
        keep_link = False
        own_data = False
        if len(args) == 1:
            if isinstance(args[0], list):
                args = (args[0], len(args[0]))
                own_data = True
            elif isinstance(args[0], ndarray):
                if args[0].dtype != 'float64':
                    raise ValueError('Must be float64 array ' +
                                     str(args[0].dtype) + ' is given')
                else:
                    args = (ascontiguousarray(args[0]), args[0].shape[0])
                    # in this case, args[0] need to be maintained
                    # in this object.
                    keep_link = True

        _vector.Vector_swiginit(self, _vector.new_Vector(*args))

        if keep_link:
            self._link_to_data = args[0]
        if own_data:
            self.MakeDataOwner()
Exemplo n.º 3
0
    def __init__(self, *args):
        """
        __init__(mfem::Vector self) -> Vector
        __init__(mfem::Vector self, Vector arg2) -> Vector
        __init__(mfem::Vector self, int s) -> Vector
        __init__(mfem::Vector self, double * _data, int _size) -> Vector
        __init__(mfem::Vector self, Vector v, int offset, int size) -> Vector
        """

        from numpy import ndarray, ascontiguousarray
        keep_link = False
        own_data = False
        if len(args) == 1:
            if isinstance(args[0], list):
                args = (args[0], len(args[0]))
                own_data = True
            elif isinstance(args[0], ndarray):
                if args[0].dtype != 'float64':
                    raise ValueError('Must be float64 array ' +
                                     str(args[0].dtype) + ' is given')
                else:
                    args = (ascontiguousarray(args[0]), args[0].shape[0])
                    # in this case, args[0] need to be maintained
                    # in this object.
                    keep_link = True

        this = _vector.new_Vector(*args)
        try:
            self.this.append(this)
        except __builtin__.Exception:
            self.this = this

        if keep_link:
            self._link_to_data = args[0]
        if own_data:
            self.MakeDataOwner()
Exemplo n.º 4
0
 def __init__(self, *args):
     this = _vector.new_Vector(*args)
     try:
         self.this.append(this)
     except:
         self.this = this
Exemplo n.º 5
0
 def __init__(self, *args): 
     this = _vector.new_Vector(*args)
     try: self.this.append(this)
     except: self.this = this