# Vector

class `psi4.core.``Vector`

  Bases: `pybind11_builtins.pybind11_object`

  Class for creating and manipulating vectors

  Attributes Summary

  `name` | The name of the Vector.
  `np` | View without only one irrep
  `nph` | View with irreps.
  `shape` | Shape of the Psi4 data object

  Methods Summary

  `array_interface`(self) |
  `dim`(self, h) | Returns the dimensions of the vector per irrep h
  `dimpi`(self) | Returns the Dimension object
  `from_array`(arr[, name, dim1, dim2]) | Converts a numpy array or list of numpy arrays into a Psi4 Matrix (irreped if list).
  `from_list`(x) |
  `from_serial`(json_data) | Converts serialized data to the correct Psi4 data type
  `get`(*args, **kwargs) | Overloaded function.
  `get_block`(self, slice) | Get a vector block
  `nirrep`(self) | Returns the number of irreps
  `np_read`(filename[, prefix]) | Reads the data from a NumPy compress file.
  `np_write`([filename, prefix]) | Writes the irreped matrix to a NumPy zipped file.
  `print_out`(self) | Prints the vector to the output file
  `scale`(self, sc) | Scales the elements of a vector by sc
  `set`(*args, **kwargs) | Overloaded function.
  `set_block`(self, slice, block) | Set a vector block
  `to_array`([copy, dense]) | Converts a Psi4 Matrix or Vector to a numpy array.
  `to_serial`() | Converts an object with a .nph accessor to a serialized dictionary

  Attributes Documentation

  `name`

    The name of the Vector. Used in printing.

  `np`

    View without only one irrep

  `nph`

    View with irreps.

  `shape`

    Shape of the Psi4 data object

  Methods Documentation

  `array_interface`(self: psi4.core.Vector) → list
  `dim`(self: psi4.core.Vector, h: int=0) → int

    Returns the dimensions of the vector per irrep h

  `dimpi`(self: psi4.core.Vector) → psi4.core.Dimension

    Returns the Dimension object

  classmethod `from_array`(arr, name='New Matrix', dim1=None, dim2=None)

    Converts a numpy array or list of numpy arrays into a Psi4 Matrix (irreped if list).

    Parameters:

    - arr (array or list of arrays) – Numpy array or list of arrays to use as the data for a new core.Matrix
    - name (str) – Name to give the new core.Matrix
    - dim1 (list, tuple, or core.Dimension (optional)) – If a single dense numpy array is given, a dimension can be supplied to apply irreps to this array. Note that this discards all extra information given in the matrix besides the diagonal blocks determined by the passed dimension.
    - dim2 – Same as dim1 only if using a psi4.core.Dimension object.

    Returns: | matrix – Returns the given Psi4 object
    Return type: | `Matrix` or `Vector`

    Notes

    This is a generalized function to convert a NumPy array to a Psi4 object

    Examples

        >>> data = np.random.rand(20)
        >>> vector = array_to_matrix(data)

        >>> irrep_data = [np.random.rand(2, 2), np.empty(shape=(0,3)), np.random.rand(4, 4)]
        >>> matrix = array_to_matrix(irrep_data)
        >>> print matrix.rowspi().to_tuple()
        (2, 0, 4)

  classmethod `from_list`(x)
  classmethod `from_serial`(json_data)

    Converts serialized data to the correct Psi4 data type

  `get`(*args, **kwargs)

    Overloaded function.

    1. get(self: psi4.core.Vector, m: int) -> float

    Returns a single element value located at m

    2. get(self: psi4.core.Vector, h: int, m: int) -> float

    Returns a single element value located at m in irrep h

  `get_block`(self: psi4.core.Vector, slice: psi4.core.Slice) → psi4.core.Vector

    Get a vector block

  `nirrep`(self: psi4.core.Vector) → int

    Returns the number of irreps

  classmethod `np_read`(filename, prefix='')

    Reads the data from a NumPy compress file.

  `np_write`(filename=None, prefix='')

    Writes the irreped matrix to a NumPy zipped file.

    Can return the packed data for saving many matrices into the same file.

  `print_out`(self: psi4.core.Vector) → None

    Prints the vector to the output file

  `scale`(self: psi4.core.Vector, sc: float) → None

    Scales the elements of a vector by sc

  `set`(*args, **kwargs)

    Overloaded function.

    1. set(self: psi4.core.Vector, m: int, val: float) -> None

    Sets a single element value located at m

    2. set(self: psi4.core.Vector, h: int, m: int, val: float) -> None

    Sets a single element value located at m in irrep h

  `set_block`(self: psi4.core.Vector, slice: psi4.core.Slice, block: psi4.core.Vector) → None

    Set a vector block

  `to_array`(copy=True, dense=False)

    Converts a Psi4 Matrix or Vector to a numpy array. Either copies the data or simply constructs a view.

    Parameters:

    - matrix (`Matrix` or `Vector`) – Pointers to which Psi4 core class should be used in the construction.
    - copy (bool, optional) – Copy the data if True, return a view otherwise
    - dense (bool, optional) – Converts irreped Psi4 objects to diagonally blocked dense arrays if True. Returns a list of arrays otherwise.

    Returns: | array – Returns either a list of np.array’s or the base array depending on options.
    Return type: | ndarray or list of ndarray

    Notes

    This is a generalized function to convert a Psi4 object to a NumPy array

    Examples

        >>> data = psi4.Matrix(3, 3)
        >>> data.to_array()
        [[ 0.  0.  0.]
         [ 0.  0.  0.]
         [ 0.  0.  0.]]

  `to_serial`()

    Converts an object with a .nph accessor to a serialized dictionary

  `array_interface`(self: psi4.core.Vector) → list
  `dim`(self: psi4.core.Vector, h: int=0) → int

    Returns the dimensions of the vector per irrep h

  `dimpi`(self: psi4.core.Vector) → psi4.core.Dimension

    Returns the Dimension object

  classmethod `from_array`(arr, name='New Matrix', dim1=None, dim2=None)

    Converts a numpy array or list of numpy arrays into a Psi4 Matrix (irreped if list).

    Parameters:

    - arr (array or list of arrays) – Numpy array or list of arrays to use as the data for a new core.Matrix
    - name (str) – Name to give the new core.Matrix
    - dim1 (list, tuple, or core.Dimension (optional)) – If a single dense numpy array is given, a dimension can be supplied to apply irreps to this array. Note that this discards all extra information given in the matrix besides the diagonal blocks determined by the passed dimension.
    - dim2 – Same as dim1 only if using a psi4.core.Dimension object.

    Returns: | matrix – Returns the given Psi4 object
    Return type: | `Matrix` or `Vector`

    Notes

    This is a generalized function to convert a NumPy array to a Psi4 object

    Examples

        >>> data = np.random.rand(20)
        >>> vector = array_to_matrix(data)

        >>> irrep_data = [np.random.rand(2, 2), np.empty(shape=(0,3)), np.random.rand(4, 4)]
        >>> matrix = array_to_matrix(irrep_data)
        >>> print matrix.rowspi().to_tuple()
        (2, 0, 4)

  classmethod `from_list`(x)
  classmethod `from_serial`(json_data)

    Converts serialized data to the correct Psi4 data type

  `get`(*args, **kwargs)

    Overloaded function.

    1. get(self: psi4.core.Vector, m: int) -> float

    Returns a single element value located at m

    2. get(self: psi4.core.Vector, h: int, m: int) -> float

    Returns a single element value located at m in irrep h

  `get_block`(self: psi4.core.Vector, slice: psi4.core.Slice) → psi4.core.Vector

    Get a vector block

  `name`

    The name of the Vector. Used in printing.

  `nirrep`(self: psi4.core.Vector) → int

    Returns the number of irreps

  `np`

    View without only one irrep

  classmethod `np_read`(filename, prefix='')

    Reads the data from a NumPy compress file.

  `np_write`(filename=None, prefix='')

    Writes the irreped matrix to a NumPy zipped file.

    Can return the packed data for saving many matrices into the same file.

  `nph`

    View with irreps.

  `print_out`(self: psi4.core.Vector) → None

    Prints the vector to the output file

  `scale`(self: psi4.core.Vector, sc: float) → None

    Scales the elements of a vector by sc

  `set`(*args, **kwargs)

    Overloaded function.

    1. set(self: psi4.core.Vector, m: int, val: float) -> None

    Sets a single element value located at m

    2. set(self: psi4.core.Vector, h: int, m: int, val: float) -> None

    Sets a single element value located at m in irrep h

  `set_block`(self: psi4.core.Vector, slice: psi4.core.Slice, block: psi4.core.Vector) → None

    Set a vector block

  `shape`

    Shape of the Psi4 data object

  `to_array`(copy=True, dense=False)

    Converts a Psi4 Matrix or Vector to a numpy array. Either copies the data or simply constructs a view.

    Parameters:

    - matrix (`Matrix` or `Vector`) – Pointers to which Psi4 core class should be used in the construction.
    - copy (bool, optional) – Copy the data if True, return a view otherwise
    - dense (bool, optional) – Converts irreped Psi4 objects to diagonally blocked dense arrays if True. Returns a list of arrays otherwise.

    Returns: | array – Returns either a list of np.array’s or the base array depending on options.
    Return type: | ndarray or list of ndarray

    Notes

    This is a generalized function to convert a Psi4 object to a NumPy array

    Examples

        >>> data = psi4.Matrix(3, 3)
        >>> data.to_array()
        [[ 0.  0.  0.]
         [ 0.  0.  0.]
         [ 0.  0.  0.]]

  `to_serial`()

    Converts an object with a .nph accessor to a serialized dictionary