Documentation of 'jnumeric.PyMultiarray' Java class
PyMultiarray
jnumeric

Class PyMultiarray

  • All Implemented Interfaces:
    java.io.Serializable


    public class PyMultiarray
    extends PySequence
    The container for n-dimensional arrays. The array itself is stored as a one-dimensional array; the mathematical routines manipulating these arrays must treat it appropriately based on their shape and stride.
    See Also:
    Serialized Form
    • Field Detail

      • maxLineWidth

        public static int maxLineWidth
        Used to format arrays for str([0]) and repr([1])
      • precision

        public static int precision
        Used to format arrays for str([0]) and repr([1])
      • suppressSmall

        public static boolean suppressSmall
        Used to format arrays for str([0]) and repr([1])
      • ATYPE

        public static final PyType ATYPE
        Python class of PyMultiarray.
        See Also:
        PyObject
    • Constructor Detail

      • PyMultiarray

        public PyMultiarray(java.lang.Object data,
                            char _typecode,
                            int start,
                            int[] dimensions,
                            int[] strides)
        Create a multiarray object given values of instance variables.
        Parameters:
        data - The 1D array
        _typecode - Datatype of the array
        start - Start of the array
        dimensions - Dimensionality
        strides - Strides
      • PyMultiarray

        public PyMultiarray(PyObject seq,
                            char typecode)
        Create a multiarray object from a sequence and a type.
        Parameters:
        seq - Array-like
        typecode - Datatype of the array
      • PyMultiarray

        public PyMultiarray(PyObject seq)
        Create a multiarray object from a sequence.
        Parameters:
        seq - Array-like
    • Method Detail

      • array

        public static PyMultiarray array(PyObject seq,
                                         char typecode)
        Create a new multiarray from seq of type typecode ('\0' indicates the type should be inferred from seq).
        Parameters:
        seq - Array-like
        typecode - Datatype of the array
        Returns:
        The new multiarray
      • array

        public static PyMultiarray array(PyObject seq)
        Create a new multiarray from seq. The type is determined by examining seq.
        Parameters:
        seq - Array-like
        Returns:
        The new multiarray
      • zeros

        public static PyMultiarray zeros(int[] shape,
                                         char typecode)
        Create a new multiarray of zeros with shape shape of type typecode.
        Parameters:
        shape - A tuple or list describing the dimensionality of the array (e.g., (10,) for a 10-element vector, [2, 5] for a 2 by 5 matrix))
        typecode - Datatype of the array
        Returns:
        The new multiarray
      • zeros

        public static PyMultiarray zeros(java.lang.Object shape,
                                         char typecode)
        Create a new multiarray of zeros with shape shape of type typecode.
        Parameters:
        shape - A tuple or list describing the dimensionality of the array (e.g., (10,) for a 10-element vector, [2, 5] for a 2 by 5 matrix))
        typecode - Datatype of the array
        Returns:
        The new multiarray
      • zeros

        public static PyMultiarray zeros(PyObject shape)
        Create a new multiarray of zeros with shape shape with type inferenced from shape.
        Parameters:
        shape - A tuple or list describing the dimensionality of the array (e.g., (10,) for a 10-element vector, [2, 5] for a 2 by 5 matrix))
        Returns:
        The new multiarray
      • arrayRange

        public static PyMultiarray arrayRange(PyObject start,
                                              PyObject stop,
                                              PyObject step,
                                              char typecode)
        Create a range of numbers in [start, stop) with the given step and typecode.
        Parameters:
        start - Start of the range (included)
        stop - End of the range (not included)
        step - Stepsize between the start and stop
        typecode - Datatype of the array
        Returns:
        The new multiarray
      • indices

        public static PyMultiarray indices(PyObject o,
                                           char typecode)
        Create a set of indices for use with fromFunction.
        Parameters:
        o - The input array
        typecode - Datatype of the indices
        Returns:
        The set of indices
      • fromFunction

        public static PyMultiarray fromFunction(PyObject function,
                                                PyObject shape)
        Create an array by calling function the coordinates of each element of an array with the given shape.
        Parameters:
        function - The function to call
        shape - A tuple or list describing the dimensionality of the array (e.g., (10,) for a 10-element vector, [2, 5] for a 2 by 5 matrix))
        Returns:
        The new multiarray
      • fromString

        public static PyMultiarray fromString(java.lang.String s,
                                              char type)
        Create a 1D array from a string.
        Parameters:
        s - String from which to create the array
        type - Datatype of the array
        Returns:
        The new multiarray
        See Also:
        toString()
      • asarray

        public static PyMultiarray asarray(PyObject seq,
                                           char typecode)
        Return seq if it's a multiarray of type typecode, otherwise returns a new multiarray.
        Parameters:
        seq - Array-like
        typecode - Datatype of the new array
        Returns:
        The new multiarray
      • asarray

        public static PyMultiarray asarray(PyObject seq)
        Return seq if it's a multiarray, otherwise returns a new multiarray.
        Parameters:
        seq - Array-like
        Returns:
        The new multiarray
      • ascontiguous

        public static PyMultiarray ascontiguous(PyObject seq,
                                                char _typecode)
        Return seq if it's a contiguous multiarray, otherwise returns a new multiarray.
        Parameters:
        seq - Array-like
        _typecode - Datatype (a single character)
        Returns:
        The new multiarray
      • ascontiguous

        public static PyMultiarray ascontiguous(PyObject seq)
        Return seq if it's a contiguous multiarray of type typecode, otherwise returns a new multiarray.
        Parameters:
        seq - Array-like
        Returns:
        The new multiarray
      • typecode

        public char typecode()
        Return the typecode.
        Returns:
        The typecode
        See Also:
        _typecode
      • itemsize

        public int itemsize()
        Return the size (in bytes) of the items.
        Returns:
        The size (in bytes) of the items
      • iscontiguous

        public int iscontiguous()
        Return (1) if the array is contiguous, 0 otherwise.
        Returns:
        1 if the array is contiguous, 0 otherwise
      • astype

        public PyMultiarray astype(char type)
        Return multiarray coerced to type. Note that CNumeric does the equivalent of return array(this, type) here.
        Parameters:
        type - The output type
        Returns:
        The new multiarray
      • tostring

        public java.lang.String tostring()
        Return multiarray data represented as a string.
        Returns:
        The string representation
      • byteswapped

        public final PyMultiarray byteswapped()
        Return a multiarray with data byte swapped (little to big endian).
        Returns:
        The byte swapped multiarray
      • copy

        public final PyMultiarray copy()
        Return a copy.
        Returns:
        Multiarray copy
      • tolist

        public final PyList tolist()
        Return multiarray as a Python list.
        Returns:
        Python list with the same data as the multiarray
      • reshape

        public static PyMultiarray reshape(PyObject o,
                                           int[] shape)
        Return a reshaped multiarray (shares data with a if it is contiguous).
        Parameters:
        o - Input array
        shape - A tuple or list describing the dimensionality of the array (e.g., (10,) for a 10-element vector, [2, 5] for a 2 by 5 matrix))
        Returns:
        The reshaped multiarray
      • resize

        public static PyMultiarray resize(PyObject o,
                                          int[] shape)
        Return a new array with the specified shape. The original array can have any total size.
        Parameters:
        o - Input array
        shape - A tuple or list describing the dimensionality of the array (e.g., (10,) for a 10-element vector, [2, 5] for a 2 by 5 matrix))
        Returns:
        The resized multiarray
      • sort

        public static PyMultiarray sort(PyObject o,
                                        int axis)
        Return a new, sorted array.
        Parameters:
        o - Array to be sorted
        axis - Axis over which to sort
        Returns:
        A new, sorted array
      • argSort

        public static PyMultiarray argSort(PyObject o,
                                           int axis)
        Returns the indices that would sort an array.
        Parameters:
        o - Input array
        axis - Axis over which to sort
        Returns:
        The indices that would sort the array.
      • transpose

        public static PyMultiarray transpose(PyObject o,
                                             int[] perms)
        Return a multiarray with the axes transposed according to perms (shares data with a).
        Parameters:
        o - Input array
        perms - Axes to transpose
        Returns:
        The transposed multiarray
      • repeat

        public static PyMultiarray repeat(PyObject oA,
                                          PyObject oRepeats,
                                          int axis)
        Repeat elements of an array.
        Parameters:
        oA - Input array
        oRepeats - The number of repetitions for each element.
        axis - The axis along which to repeat values.
        Returns:
        Output array which has the same shape as a, except along the given axis.
      • take

        public static PyMultiarray take(PyObject oA,
                                        PyObject oIndices,
                                        int axis)
        Take elements from an array along an axis.
        Parameters:
        oA - The source array.
        oIndices - The indices of the values to extract.
        axis - The axis over which to select values.
        Returns:
        The returned array has the same type as oA.
      • choose

        public static PyMultiarray choose(PyObject oA,
                                          PyObject b)
        Implements choose()/clip()/where() functionality. Choose elements from object oA based on set of indices b.
        Parameters:
        oA - This array must contain integers in [0, n-1], where n is the number of choices, unless mode=wrap or mode=clip, in which cases any integers are permissible.
        b - Choice arrays. a and all of the choices must be broadcastable to the same shape.
        Returns:
        The merged result.
      • concatenate

        public static PyMultiarray concatenate(PyObject po,
                                               int axis)
        Join a sequence of arrays together.
        Parameters:
        po - sequence of array_like. The arrays must have the same shape, except in the dimension corresponding to axis (the first, by default).
        axis - The axis along which the arrays will be joined. Default: 0.
        Returns:
        The concatenated array.
      • diagonal

        public static PyMultiarray diagonal(PyObject o,
                                            int offset,
                                            int axis)
        Return the diagonal of a matrix. Actually, it returns a rank-one array containing all elements of the original, such that the difference between their indices along the specified axes is equal to the specified offset. This means it can operate on non-square matrices too.
        Parameters:
        o - Array from which the diagonals are taken.
        offset - Offset of the diagonal from the main diagonal. Can be positive or negative.
        axis - Axis from which the diagonals should be taken.
        Returns:
        A 1-D array containing the diagonal.
      • innerProduct

        public static PyObject innerProduct(PyObject oA,
                                            PyObject oB,
                                            int axisA,
                                            int axisB)
        Inner product of two arrays.
        Parameters:
        oA - First input array
        oB - Second input array
        axisA - Axis for the first array
        axisB - Axis for the second array
        Returns:
        Inner product of the two arrays.
      • searchSorted

        public static PyObject searchSorted(PyObject o,
                                            PyObject v)
        Return an array of indices of where the items would be locatated in the given array.
        Parameters:
        o - Input array, sorted in ascending order
        v - Values to insert into o
        Returns:
        Array of insertion points with the same shape as v
      • convolve

        public static PyMultiarray convolve(PyObject oA0,
                                            PyObject oB0,
                                            int mode)
        Return convolution of two vectors.
        Parameters:
        oA0 - First vector
        oB0 - Second vector
        mode - Convolution mode, as an integer. 0 = 'valid'; This returns output of length max(M, N) - min(M, N) + 1. The convolution product is only given for points where the signals overlap completely. Values outside the signal boundary have no effect. 1 = 'same'; This returns output of length max(M, N). Boundary effects are still visible. 2 = 'full'; This returns the convolution at each point of overlap, with an output shape of (N+M-1,). At the end-points of the convolution, the signals do not overlap completely, and boundary effects may be seen.
        Returns:
        Discrete, linear convolution of oA0 and oB0
      • XC_padded_length

        public static int XC_padded_length(int length)
        Compute the padded length of a vector prior to using FFT. This is a helper routine for cross_correlate()
        Parameters:
        length - Length of original vector
        Returns:
        Length of padded vector
      • XC_pad_vector

        public static PyMultiarray XC_pad_vector(PyMultiarray V,
                                                 int padl)
        Perform padding on vector, prior to using FFT. This is a helper routine for cross_correlate()
        Parameters:
        V - Input vector
        padl - Length to pad to
        Returns:
        Padded vector
      • XC_unpad_vector

        public static PyMultiarray XC_unpad_vector(PyMultiarray R,
                                                   int lenA,
                                                   int lenB,
                                                   int mode)
        Recover the result of an FFT-based correlation. This is a helper routine for cross_correlate()
        Parameters:
        R - Input vector
        lenA - Dimensions of A
        lenB - Dimensions of B
        mode - Correlation mode; see PyMulitarray.convolve
        Returns:
        Unpadded vector
      • cross_correlate

        public static PyMultiarray cross_correlate(PyObject oA0,
                                                   PyObject oB0,
                                                   int mode)
        Return cross-correlation of two vectors. Cross-correlation is performed in Fourier space, since the computational complexity is Nlog(N), compared to N^2 in real space, (N=length of vectors),
        Parameters:
        oA0 - First vector
        oB0 - Second vector
        mode - Convolution mode; see PyMultiarray.convolve
        Returns:
        Cross-correlation of the two vectors
      • shapeOf

        public static final int[] shapeOf(PyObject seq)
        Return the shape of a Python sequence.
        Parameters:
        seq - Array-like
        Returns:
        The shape of seq
      • __tojava__

        public java.lang.Object __tojava__(java.lang.Class<?> c)
        Convert this to a java object of Class c.
        Overrides:
        __tojava__ in class PySequence
        Parameters:
        c - the Class to convert this PyObject to.
      • __len__

        public int __len__()
        Return the length of the array (along the first axis).
        Overrides:
        __len__ in class PyObject
        Returns:
        the length of the object
      • __getitem__

        public PyObject __getitem__(int index)
        Override PyObject method so that get is invoked instead of __finditem__.
        Overrides:
        __getitem__ in class PyObject
        Parameters:
        index - the key to lookup in this container.
        Returns:
        the value corresponding to that key.
        See Also:
        PyObject.__finditem__(int)
      • __cmp__

        public int __cmp__(PyObject other)
        Disable comparison of Multiarrays
        Overrides:
        __cmp__ in class PyObject
        Parameters:
        other - the object to compare this with.
        Returns:
        -1 if this<o; 0 if this==o; +1 if this>o; -2 if no comparison is implemented
      • __setitem__

        public void __setitem__(PyObject indices,
                                PyObject pyValue)
        Set the subarray based on indices to PyValue.
        Overrides:
        __setitem__ in class PySequence
        Parameters:
        indices - the key whose value will be set
        pyValue - the value to set this key to
      • __findattr_ex__

        public PyObject __findattr_ex__(java.lang.String name)
        Multiarray attributes are found using __findattr__.
        Overrides:
        __findattr_ex__ in class PyObject
        Returns:
        The looked up value. May return null if the attribute is not found
      • toString

        public java.lang.String toString()
        Return a string representation of the byte array corresponding to this array
        Overrides:
        toString in class PyObject
      • __radd__

        public PyObject __radd__(PyObject po)
        Description copied from class: PyObject
        Equivalent to the standard Python __radd__ method.
        Overrides:
        __radd__ in class PyObject
        Parameters:
        po - the object to perform this binary operation with (the left-hand operand).
        Returns:
        the result of the add, or null if this operation is not defined.
      • __rsub__

        public PyObject __rsub__(PyObject po)
        Description copied from class: PyObject
        Equivalent to the standard Python __rsub__ method
        Overrides:
        __rsub__ in class PyObject
        Parameters:
        po - the object to perform this binary operation with (the left-hand operand).
        Returns:
        the result of the sub, or null if this operation is not defined.
      • __rmul__

        public PyObject __rmul__(PyObject po)
        Description copied from class: PyObject
        Equivalent to the standard Python __rmul__ method.
        Overrides:
        __rmul__ in class PyObject
        Parameters:
        po - the object to perform this binary operation with (the left-hand operand).
        Returns:
        the result of the mul, or null if this operation is not defined.
      • __rdiv__

        public PyObject __rdiv__(PyObject po)
        Description copied from class: PyObject
        Equivalent to the standard Python __rdiv__ method
        Overrides:
        __rdiv__ in class PyObject
        Parameters:
        po - the object to perform this binary operation with (the left-hand operand).
        Returns:
        the result of the div, or null if this operation is not defined.
      • __rmod__

        public PyObject __rmod__(PyObject po)
        Description copied from class: PyObject
        Equivalent to the standard Python __rmod__ method
        Overrides:
        __rmod__ in class PyObject
        Parameters:
        po - the object to perform this binary operation with (the left-hand operand).
        Returns:
        the result of the mod, or null if this operation is not defined.
      • __divmod__

        public PyObject __divmod__(PyObject po)
        Description copied from class: PyObject
        Equivalent to the standard Python __divmod__ method
        Overrides:
        __divmod__ in class PyObject
        Parameters:
        po - the object to perform this binary operation with (the right-hand operand).
        Returns:
        the result of the divmod, or null if this operation is not defined
      • __rdivmod__

        public PyObject __rdivmod__(PyObject po)
        Description copied from class: PyObject
        Equivalent to the standard Python __rdivmod__ method
        Overrides:
        __rdivmod__ in class PyObject
        Parameters:
        po - the object to perform this binary operation with (the left-hand operand).
        Returns:
        the result of the divmod, or null if this operation is not defined.
      • __add__

        public PyObject __add__(PyObject o)
        Description copied from class: PyObject
        Equivalent to the standard Python __add__ method.
        Overrides:
        __add__ in class PyObject
        Parameters:
        o - the object to perform this binary operation with (the right-hand operand).
        Returns:
        the result of the add, or null if this operation is not defined.
      • __sub__

        public PyObject __sub__(PyObject o)
        Description copied from class: PyObject
        Equivalent to the standard Python __sub__ method
        Overrides:
        __sub__ in class PyObject
        Parameters:
        o - the object to perform this binary operation with (the right-hand operand).
        Returns:
        the result of the sub, or null if this operation is not defined
      • __mul__

        public PyObject __mul__(PyObject o)
        Description copied from class: PyObject
        Equivalent to the standard Python __mul__ method.
        Overrides:
        __mul__ in class PyObject
        Parameters:
        o - the object to perform this binary operation with (the right-hand operand).
        Returns:
        the result of the mul, or null if this operation is not defined
      • __div__

        public PyObject __div__(PyObject o)
        Description copied from class: PyObject
        Equivalent to the standard Python __div__ method
        Overrides:
        __div__ in class PyObject
        Parameters:
        o - the object to perform this binary operation with (the right-hand operand).
        Returns:
        the result of the div, or null if this operation is not defined
      • __mod__

        public PyObject __mod__(PyObject o)
        Description copied from class: PyObject
        Equivalent to the standard Python __mod__ method
        Overrides:
        __mod__ in class PyObject
        Parameters:
        o - the object to perform this binary operation with (the right-hand operand).
        Returns:
        the result of the mod, or null if this operation is not defined
      • __pow__

        public PyObject __pow__(PyObject o)
        Description copied from class: PyObject
        Equivalent to the standard Python __pow__ method
        Overrides:
        __pow__ in class PyObject
        Parameters:
        o - the object to perform this binary operation with (the right-hand operand).
        Returns:
        the result of the pow, or null if this operation is not defined
      • myMax

        public static PyObject myMax(PyObject a,
                                     PyObject b)
        Parameters:
        a - First array
        b - Second array
        Returns:
        Maximum values from the two arrays
      • myMin

        public static PyObject myMin(PyObject a,
                                     PyObject b)
        Parameters:
        a - First array
        b - Second array
        Returns:
        Minimum values from the two arrays
      • __max

        public PyObject __max(PyObject o)
        Parameters:
        o - Input array
        Returns:
        Maximum value from the array
      • __min

        public PyObject __min(PyObject o)
        Parameters:
        o - Input array
        Returns:
        Minimum value from the array
      • __eq

        public PyObject __eq(PyObject o)
        Parameters:
        o - Input array
        Returns:
        Where the two arrays are equal
      • __neq

        public PyObject __neq(PyObject o)
        Parameters:
        o - Input array
        Returns:
        Where the two arrays are not equal
      • __le

        public PyObject __le(PyObject o)
        Parameters:
        o - Input array
        Returns:
        Where less than or equal
      • __lt

        public PyObject __lt(PyObject o)
        Parameters:
        o - Input array
        Returns:
        Where less than
      • __ge

        public PyObject __ge(PyObject o)
        Parameters:
        o - Input array
        Returns:
        Where greater than or equal
      • __gt

        public PyObject __gt(PyObject o)
        Parameters:
        o - Input array
        Returns:
        Where greater than
      • __land

        public PyObject __land(PyObject o)
        Parameters:
        o - Input array
        Returns:
        Logical and
      • __lor

        public PyObject __lor(PyObject o)
        Parameters:
        o - Input array
        Returns:
        Logical or
      • __lxor

        public PyObject __lxor(PyObject o)
        Parameters:
        o - Input array
        Returns:
        Logical exclusive-or
      • __and__

        public PyObject __and__(PyObject o)
        Description copied from class: PyObject
        Equivalent to the standard Python __and__ method
        Overrides:
        __and__ in class PyObject
        Parameters:
        o - the object to perform this binary operation with (the right-hand operand).
        Returns:
        the result of the and, or null if this operation is not defined
      • __or__

        public PyObject __or__(PyObject o)
        Description copied from class: PyObject
        Equivalent to the standard Python __or__ method
        Overrides:
        __or__ in class PyObject
        Parameters:
        o - the object to perform this binary operation with (the right-hand operand).
        Returns:
        the result of the or, or null if this operation is not defined
      • __xor__

        public PyObject __xor__(PyObject o)
        Description copied from class: PyObject
        Equivalent to the standard Python __xor__ method
        Overrides:
        __xor__ in class PyObject
        Parameters:
        o - the object to perform this binary operation with (the right-hand operand).
        Returns:
        the result of the xor, or null if this operation is not defined
      • __abs__

        public PyObject __abs__()
        Description copied from class: PyObject
        Equivalent to the standard Python __abs__ method.
        Overrides:
        __abs__ in class PyObject
        Returns:
        abs(this).
      • __neg__

        public PyObject __neg__()
        Description copied from class: PyObject
        Equivalent to the standard Python __neg__ method.
        Overrides:
        __neg__ in class PyObject
        Returns:
        -this.
      • __not__

        public PyObject __not__()
        Description copied from class: PyObject
        Implements boolean not
        Overrides:
        __not__ in class PyObject
        Returns:
        not this.

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.