petsc4py.PETSc.Vec

Package petsc4py :: Module PETSc :: Class Vec |
[hide private]
[frames] | no frames]

# Class Vec

Nested Classes | [hide private]
| Option
| Type

Instance Methods | [hide private]
__abs__() <==> abs(x) |
__add__(y) x+y |
__delitem__(y) del x[y] |
__div__(y) x/y |
__dlpack__(self, stream=-1) |
__dlpack_device__(self) |
__enter__(self) |
__exit__(self, *exc) |
__getitem__(y) x[y] |
__iadd__(y) x+=y |
__idiv__(y) x/=y |
__imul__(y) x*=y |
__isub__(y) x-=y |
__itruediv__(y) x/=y |
__mul__(y) x*y |
__neg__() -x |
a new object with type S, a subtype of T |
__new__(S, ...) |
__pos__() +x |
__radd__(y) y+x |
__rdiv__(y) y/x |
__rmul__(y) y*x |
__rsub__(y) y-x |
__rtruediv__(y) y/x |
__setitem__(i, y) x[i]=y |
__sub__(y) x-y |
__truediv__(y) x/y |
abs(self) |
appendOptionsPrefix(self, prefix) |
assemble(self) |
assemblyBegin(self) |
assemblyEnd(self) |
attachDLPackInfo(self, Vec vec=None, dltensor=None) Attach the tensor information from an input vector (vec) or a DLPack tensor if it is not available in current vector. |
axpby(self, alpha, beta, Vec y) |
axpy(self, alpha, Vec x) |
aypx(self, alpha, Vec x) |
bindToCPU(self, flg) If *flg* is *True*, all subsequent operations of *self* would be performed on CPU. |
boundToCPU(self) |
chop(self, tol) |
clearDLPackInfo(self) Clear the tensor information See also :meth:`Vec.attachDLPackInfo`. |
conjugate(self) |
copy(self, Vec result=None) |
create(self, comm=None) |
createCUDAWithArrays(self, cpuarray=None, cudahandle=None, size=None, bsize=None, comm=None) Returns an instance of :class:`Vec`, a VECCUDA with user provided memory spaces for CPU and GPU arrays. |
createGhost(self, ghosts, size, bsize=None, comm=None) |
createGhostWithArray(self, ghosts, array, size=None, bsize=None, comm=None) |
createHIPWithArrays(self, cpuarray=None, hiphandle=None, size=None, bsize=None, comm=None) Returns an instance of :class:`Vec`, a VECHIP with user provided memory spaces for CPU and GPU arrays. |
createLocalVector(self) |
createMPI(self, size, bsize=None, comm=None) |
createNest(self, vecs, isets=None, comm=None) |
createSeq(self, size, bsize=None, comm=None) |
createShared(self, size, bsize=None, comm=None) |
createViennaCLWithArrays(self, cpuarray=None, viennaclvechandle=None, size=None, bsize=None, comm=None) Returns an instance :class:`Vec`, a VECVIENNACL with user provided memory spaces for CPU and GPU arrays. |
createWithArray(self, array, size=None, bsize=None, comm=None) |
createWithDLPack(self, dltensor, size=None, bsize=None, comm=None) Returns an instance :class:`Vec`, a PETSc vector from a DLPack object sharing the same memory. |
destroy(self) |
dot(self, Vec vec) |
dotBegin(self, Vec vec) |
dotEnd(self, Vec vec) |
duplicate(self, array=None) |
equal(self, Vec vec) |
exp(self) |
getArray(self, readonly=False) |
getBlockSize(self) |
getBuffer(self, readonly=False) |
getCLContextHandle(self) Returns a Vec's CL Context as :class:`int`. |
getCLMemHandle(self, mode='rw') Returns a Vec's CL buffer as :class:`int`. |
getCLQueueHandle(self) Returns a Vec's CL Context as :class:`int`. |
getCUDAHandle(self, mode='rw') |
getDM(self) |
getHIPHandle(self, mode='rw') |
getLGMap(self) |
getLocalSize(self) |
getLocalVector(self, Vec lvec, readonly=False) |
getNestSubVecs(self) |
getOffloadMask(self) Returns :class:`int` of the Vec's PetscOffloadMask enum value. |
getOptionsPrefix(self) |
getOwnershipRange(self) |
getOwnershipRanges(self) |
getSize(self) |
getSizes(self) |
getSubVector(self, IS iset, Vec subvec=None) |
getType(self) |
getValue(self, index) |
getValues(self, indices, values=None) |
getValuesStagStencil(self, indices, values=None) |
ghostUpdate(self, addv=None, mode=None) |
ghostUpdateBegin(self, addv=None, mode=None) |
ghostUpdateEnd(self, addv=None, mode=None) |
isaxpy(self, IS idx, alpha, Vec x) |
isset(self, IS idx, alpha) |
load(self, Viewer viewer) |
localForm(self) Intended for use in context manager: |
log(self) |
mDot(self, vecs, out=None) |
mDotBegin(self, vecs, out=None) |
mDotEnd(self, vecs, out=None) |
max(self) |
maxPointwiseDivide(self, Vec vec) |
maxpy(self, alphas, vecs) |
min(self) |
mtDot(self, vecs, out=None) |
mtDotBegin(self, vecs, out=None) |
mtDotEnd(self, vecs, out=None) |
norm(self, norm_type=None) |
normBegin(self, norm_type=None) |
normEnd(self, norm_type=None) |
normalize(self) |
permute(self, IS order, invert=False) |
placeArray(self, array) |
pointwiseDivide(self, Vec x, Vec y) |
pointwiseMax(self, Vec x, Vec y) |
pointwiseMaxAbs(self, Vec x, Vec y) |
pointwiseMin(self, Vec x, Vec y) |
pointwiseMult(self, Vec x, Vec y) |
reciprocal(self) |
resetArray(self, force=False) |
restoreCLMemHandle(self) To be called after accessing a Vec's cl_mem in 'w' or 'rw' modes. |
restoreCUDAHandle(self, handle, mode='rw') |
restoreHIPHandle(self, handle, mode='rw') |
restoreLocalVector(self, Vec lvec, readonly=False) |
restoreSubVector(self, IS iset, Vec subvec) |
scale(self, alpha) |
set(self, alpha) |
setArray(self, array) |
setBlockSize(self, bsize) |
setDM(self, DM dm) |
setFromOptions(self) |
setLGMap(self, LGMap lgmap) |
setMPIGhost(self, ghosts) Alternative to createGhost() |
setNestSubVecs(self, sx, idxm=None) |
setOption(self, option, flag) |
setOptionsPrefix(self, prefix) |
setRandom(self, Random random=None) |
setSizes(self, size, bsize=None) |
setType(self, vec_type) |
setUp(self) |
setValue(self, index, value, addv=None) |
setValueLocal(self, index, value, addv=None) |
setValues(self, indices, values, addv=None) |
setValuesBlocked(self, indices, values, addv=None) |
setValuesBlockedLocal(self, indices, values, addv=None) |
setValuesLocal(self, indices, values, addv=None) |
setValuesStagStencil(self, indices, values, addv=None) |
shift(self, alpha) |
sqrtabs(self) |
strideGather(self, field, Vec vec, addv=None) |
strideMax(self, field) |
strideMin(self, field) |
strideNorm(self, field, norm_type=None) |
strideScale(self, field, alpha) |
strideScatter(self, field, Vec vec, addv=None) |
strideSum(self, field) |
sum(self) |
swap(self, Vec vec) |
tDot(self, Vec vec) |
tDotBegin(self, Vec vec) |
tDotEnd(self, Vec vec) |
toDLPack(self, mode='rw') Return a DLPack capsule. |
view(self, Viewer viewer=None) |
waxpy(self, alpha, Vec x, Vec y) |
zeroEntries(self) |
Inherited from `Object`: `__copy__`, `__deepcopy__`, `__eq__`, `__ge__`, `__gt__`, `__le__`, `__lt__`, `__ne__`, `__nonzero__`, `compose`, `decRef`, `getAttr`, `getClassId`, `getClassName`, `getComm`, `getDict`, `getName`, `getRefCount`, `getTabLevel`, `incRef`, `incrementTabLevel`, `query`, `setAttr`, `setName`, `setTabLevel`, `stateGet`, `stateIncrease`, `stateSet`, `viewFromOptions` Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__init__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties | [hide private]
| __array_interface__
| array
| array_r Vec array (read-only)
| array_w Vec array (writable)
| block_size
| buffer
| buffer_r Vec buffer (read-only)
| buffer_w Vec buffer (writable)
| local_size
| owner_range
| owner_ranges
| size
| sizes
Inherited from `Object`: `classid`, `comm`, `fortran`, `handle`, `klass`, `name`, `prefix`, `refcount`, `type` Inherited from `object`: `__class__`

Method Details | [hide private]

### __new__(S, ...) |
Returns: a new object with type S, a subtype of T Overrides: object.__new__

### appendOptionsPrefix(self, prefix) |
Overrides: Object.appendOptionsPrefix

### attachDLPackInfo(self, Vec vec=None, dltensor=None) |
    Attach the tensor information from an input vector (vec) or a
    DLPack tensor if it is not available in current vector. The input
    vector is typically created with createWithDlpack(). This operation
    does not copy the data from the input parameters, it simply uses
    their meta information.

    Note that the auxiliary tensor information is required when converting
    a PETSc vector to a DLPack object.

    See also :meth:`Vec.clearDLPackInfo`.

    :arg vec: A :class:'Vec' containing auxiliary tensor information
    :arg dltensor: A DLPack tensor object

### bindToCPU(self, flg) |
    If *flg* is *True*, all subsequent operations of *self* would be
    performed on CPU. If *flg* is *False*, all subsequent operations of
    *self* would be offloaded to the device, provided that the VecType is
    capable of offloading.

    :arg flg: An instance of :class:`bool`.

### createCUDAWithArrays(self, cpuarray=None, cudahandle=None, size=None, bsize=None, comm=None) |
    Returns an instance of :class:`Vec`, a VECCUDA with user provided
    memory spaces for CPU and GPU arrays.

    :arg cpuarray: A :class:`numpy.ndarray`. Will be lazily allocated if
        *None*.
    :arg cudahandle: Address of the array on the GPU. Will be lazily
        allocated if *None*.
    :arg size: A :class:`int` denoting the size of the Vec.
    :arg bsize: A :class:`int` denoting the block size.

### createHIPWithArrays(self, cpuarray=None, hiphandle=None, size=None, bsize=None, comm=None) |
    Returns an instance of :class:`Vec`, a VECHIP with user provided
    memory spaces for CPU and GPU arrays.

    :arg cpuarray: A :class:`numpy.ndarray`. Will be lazily allocated if
        *None*.
    :arg hiphandle: Address of the array on the GPU. Will be lazily
        allocated if *None*.
    :arg size: A :class:`int` denoting the size of the Vec.
    :arg bsize: A :class:`int` denoting the block size.

### createViennaCLWithArrays(self, cpuarray=None, viennaclvechandle=None, size=None, bsize=None, comm=None) |
    Returns an instance :class:`Vec`, a VECVIENNACL with user provided memory
    spaces for CPU and GPU arrays.

    :arg cpuarray: A :class:`numpy.ndarray`. Will be lazily allocated if
        *None*.
    :arg viennaclvechandle: Address of the array on the GPU. Will be lazily
        allocated if *None*.
    :arg size: A :class:`int` denoting the size of the Vec.
    :arg size: A :class:`int` denoting the block size.

### createWithDLPack(self, dltensor, size=None, bsize=None, comm=None) |
    Returns an instance :class:`Vec`, a PETSc vector from a DLPack object
    sharing the same memory.
    This operation does not modify the storage of the original tensor and
    should be used with contiguous tensors only. If the tensor is stored in
    row-major order (e.g. PyTorch tensors), the resulting vector will look
    like an unrolled tensor using row-major order.

    :arg dltensor: An object with a __dlpack__ method or a DLPack tensor object (for backward compatibility)
    :arg size: A :class:`int` denoting the size of the Vec.
    :arg bsize: A :class:`int` denoting the block size.

### destroy(self) |
Overrides: Object.destroy

### getCLContextHandle(self) |
    Returns a Vec's CL Context as :class:`int`.

    To interface with :mod:`pyopencl` refer
    :meth:`pyopencl.Context.from_int_ptr`

### getCLMemHandle(self, mode='rw') |
    Returns a Vec's CL buffer as :class:`int`.

    To interface with :mod:`pyopencl` refer
    :meth:`pyopencl.MemoryObject.from_int_ptr`.

    :arg mode: An instance of class:`str` denoting the intended access
        usage to the CL buffer. Can be one of 'r'(read-only), 'w'
        (write-only) or 'rw' (read-write). See also
        :meth:`Vec.restoreCLMemHandle`.

### getCLQueueHandle(self) |
    Returns a Vec's CL Context as :class:`int`.

    To interface with :mod:`pyopencl` refer
    :meth:`pyopencl.Context.from_int_ptr`

### getOptionsPrefix(self) |
Overrides: Object.getOptionsPrefix

### getType(self) |
Overrides: Object.getType

### restoreCLMemHandle(self) |
    To be called after accessing a Vec's cl_mem in 'w' or 'rw' modes.
    See also :meth:`Vec.getCLMemHandle`.

### setFromOptions(self) |
Overrides: Object.setFromOptions

### setOptionsPrefix(self, prefix) |
Overrides: Object.setOptionsPrefix

### view(self, Viewer viewer=None) |
Overrides: Object.view