def __init__(self, *args, **kwargs): """Create a vector. There are different ways to construct a new vector: `vector(dtype, len)` will construct a new uninitialized vector of type ``dtype`` and length ``len``. `vector(dtype, len, value)` will construct a new vector of type ``dtype`` and length ``len`` initialized to ``value``. `vector(array=A)` will construct a vector from an existing sequence. data type and length will be inferred from ``A`` `vector(block=B)` will construct a vector from an existing block ``B``. data type and length will be inferred from ``B``.""" self.block = None #: the block object self.dtype = None #: the vector's data type if args: if len(args) == 2: self.block = _block.block(args[0], (args[1],)) elif len(args) == 3: self.block = _block.block(args[0], (args[1],), args[2]) else: raise ValueError, 'Invalid arguments' elif 'block' in kwargs: self.block = kwargs['block'] elif 'array' in kwargs: self.block = _block.block(array=kwargs['array']) else: raise ValueError, 'Invalid arguments' self.dtype = self.block.dtype
def __init__(self, *args, **kwargs): """Create a vector. There are different ways to construct a new vector: `vector(dtype, len)` will construct a new uninitialized vector of type ``dtype`` and length ``len``. `vector(dtype, len, value)` will construct a new vector of type ``dtype`` and length ``len`` initialized to ``value``. `vector(array=A)` will construct a vector from an existing sequence. data type and length will be inferred from ``A`` `vector(block=B)` will construct a vector from an existing block ``B``. data type and length will be inferred from ``B``.""" self.block = None #: the block object self.dtype = None #: the vector's data type if args: if len(args) == 2: self.block = _block.block(args[0], (args[1], )) elif len(args) == 3: self.block = _block.block(args[0], (args[1], ), args[2]) else: raise ValueError, 'Invalid arguments' elif 'block' in kwargs: self.block = kwargs['block'] elif 'array' in kwargs: self.block = _block.block(array=kwargs['array']) else: raise ValueError, 'Invalid arguments' self.dtype = self.block.dtype
def __init__(self, *args, **kwargs): """Create a matrix. There are different ways to construct a new matrix: `matrix(dtype, rows, cols)` will construct a new uninitialized matrix of type `dtype` and shape `(rows, cols)`. `matrix(dtype, rows, cols, value)` will construct a new matrix of type `dtype` and shape `(rows, cols)` initialized to value. `matrix(array=A)` will construct a matrix from an existing sequence. data type and length will be inferred from `A` `matrix(block=B)` will construct a matrix from an existing block `B`. data type and length will be inferred from `B`.""" self.block = None #: the block object self.dtype = None #: the data type if args: if len(args) == 3: self.block = _block.block(args[0], (args[1], args[2])) elif len(args) == 4: self.block = _block.block(args[0], (args[1], args[2]), args[3]) else: raise ValueError, 'Invalid arguments' elif 'block' in kwargs: self.block = kwargs['block'] elif 'array' in kwargs: self.block = _block.block(array=kwargs['array']) else: raise ValueError, 'Invalid arguments' self.dtype = self.block.dtype
def __init__(self, *args, **kwargs): """Create a matrix. There are different ways to construct a new matrix: `matrix(dtype, rows, cols)` will construct a new uninitialized matrix of type `dtype` and shape `(rows, cols)`. `matrix(dtype, rows, cols, value)` will construct a new matrix of type `dtype` and shape `(rows, cols)` initialized to value. `matrix(array=A)` will construct a matrix from an existing sequence. data type and length will be inferred from `A` `matrix(block=B)` will construct a matrix from an existing block `B`. data type and length will be inferred from `B`.""" self.block = None #: the block object self.dtype = None #: the data type if args: if len(args) == 3: self.block = _block.block(args[0], (args[1],args[2])) elif len(args) == 4: self.block = _block.block(args[0], (args[1],args[2]), args[3]) else: raise ValueError, 'Invalid arguments' elif 'block' in kwargs: self.block = kwargs['block'] elif 'array' in kwargs: self.block = _block.block(array=kwargs['array']) else: raise ValueError, 'Invalid arguments' self.dtype = self.block.dtype