Matrix

class psi4.core.Matrix

Bases: object

Class for creating and manipulating matrices

Attributes Summary

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

Methods Summary

absmax((self: psi4.core.Matrix) -> float) Returns the absolute maximum value
accumulate_product((self: psi4.core.Matrix, …) Multiplies two arguments and adds the result to this matrix
add((self: psi4.core.Matrix, …) Adds a matrix to this matrix
add_and_orthogonalize_row(…) Expands the row dimension by one, and then orthogonalizes vector v against the current rows before setting the new row to the orthogonalized copy of v
apply_denominator((self: psi4.core.Matrix, …) Apply matrix of denominators to this matrix
array_interface((self: psi4.core.Matrix) -> list)
axpy((self: psi4.core.Matrix, a: float, …) Add to this matrix another matrix scaled by a
back_transform(*args, **kwargs) Overloaded function.
chain_dot(*args, **kwargs) Chains dot products together from a series of Psi4 Matrix classes.
cholesky_factorize(…) Computes the Cholesky factorization of a real symmetric positive definite matrix
clone(…) Creates exact copy of the matrix and returns it
coldim(…) Returns the columns per irrep array
cols((self: psi4.core.Matrix, h: int=0) -> int) Returns the columns in irrep h
copy((self: psi4.core.Matrix, …) Returns a copy of the matrix
copy_lower_to_upper(…) Copy the lower triangle to the upper triangle
copy_upper_to_lower(…) Copy the upper triangle to the lower triangle
diagonalize((self: psi4.core.Matrix, …) Diagonalizes this matrix, space for the eigvectors and eigvalues must be created by caller.
doublet((A: psi4.core.Matrix, …) Returns the multiplication of two matrices A and B, with options to transpose each beforehand
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
gemm((self: psi4.core.Matrix, transa: bool, …) Generalized matrix multiplication argument transa Transpose the left matrix? argument transb Transpose the right matrix? argument alpha Prefactor for the matrix multiplication argument A Left matrix argument B Right matrix argument beta Prefactor for the resulting matrix
general_invert((self: psi4.core.Matrix) -> None) Computes the inverse of any nonsingular matrix using LU factorization
get(*args, **kwargs) Overloaded function.
identity((self: psi4.core.Matrix) -> None) Sets the matrix to the identity
invert((self: psi4.core.Matrix) -> None) Computes the inverse of a real symmetric positive definite matrix
load((self: psi4.core.Matrix, …) Loads a block matrix from an ASCII file (see tests/mints3 for format)
load_mpqc((self: psi4.core.Matrix, …) Loads a matrix from an ASCII file in MPQC format
nirrep((self: psi4.core.Matrix) -> int) 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.
partial_cholesky_factorize(…) Computes the fully pivoted partial Cholesky factorization of a real symmetric positive semidefinite matrix, to numerical precision delta
power((self: psi4.core.Matrix, alpha: float, …) Takes the matrix to the alpha power with precision cutoff
print_atom_vector((self: psi4.core.Matrix, …) Print the matrix with atom labels, assuming it is an natom X 3 tensor
print_out((self: psi4.core.Matrix) -> None) Prints the matrix to the output file
pseudoinverse((self: psi4.core.Matrix, …) Computes the matrix which is the conditioned pseudoinverse of this matrix
remove_symmetry((self: psi4.core.Matrix, …) Remove symmetry from a matrix A with PetiteList::sotoao()
rms((self: psi4.core.Matrix) -> float) Returns the rms of this matrix
rotate_columns((self: psi4.core.Matrix, …) Rotates columns i and j in irrep h by angle theta
rowdim(…) Returns the rows per irrep array
rows((self: psi4.core.Matrix, h: int=0) -> int) Returns the rows in irrep h
save((self: psi4.core.Matrix, filename: str, …) Saves the matrix in ASCII format to filename, as symmetry blocks or full matrix
scale((self: psi4.core.Matrix, a: float) -> None) Scales the matrix by the floating point value a
scale_column((self: psi4.core.Matrix, …) Scales column n of irrep h by a
scale_row((self: psi4.core.Matrix, h: int, …) Scales row m of irrep h by a
schmidt((self: psi4.core.Matrix) -> None) Calls the libqt schmidt function
set(*args, **kwargs) Overloaded function.
subtract((self: psi4.core.Matrix, …) Substract a matrix from this matrix
sum_of_squares((self: psi4.core.Matrix) -> float) Returns the sum of the squares of this matrix
symmetrize_gradient((self: psi4.core.Matrix, …) Symmetrizes a gradient-like matrix (N,3) using information from a given molecule
symmetry((self: psi4.core.Matrix) -> int) Returns the overall symmetry of the matrix
to_array(matrix[, copy, dense]) Converts a Psi4 Matrix or Vector to a numpy array.
to_serial(data) Converts an object with a .nph accessor to a serialized dictionary
trace((self: psi4.core.Matrix) -> float) Returns the trace of the matrix
transform(*args, **kwargs) Overloaded function.
transpose(…) Creates a new matrix that is the transpose of this matrix
transpose_this((self: psi4.core.Matrix) -> None) Transpose the matrix in-place
triplet((A: psi4.core.Matrix, …) Returns the multiplication of three matrics A, B, and C, with options to transpose each beforehand
vector_dot((self: psi4.core.Matrix, …) Returns the vector dot product of this with rhs
zero((self: psi4.core.Matrix) -> None) Zero all elements of the matrix
zero_diagonal((self: psi4.core.Matrix) -> None) Zero the diagonal of the matrix
zero_lower((self: psi4.core.Matrix) -> None) Zero the lower triangle
zero_upper((self: psi4.core.Matrix) -> None) Zero the upper triangle

Attributes Documentation

name

The name of the Matrix. Used in printing.

np

View without only one irrep

nph

View with irreps.

shape

Shape of the Psi4 data object

Methods Documentation

absmax(self: psi4.core.Matrix) → float

Returns the absolute maximum value

accumulate_product(self: psi4.core.Matrix, arg0: psi4.core.Matrix, arg1: psi4.core.Matrix) → None

Multiplies two arguments and adds the result to this matrix

add(self: psi4.core.Matrix, arg0: psi4.core.Matrix) → None

Adds a matrix to this matrix

add_and_orthogonalize_row(self: psi4.core.Matrix, v: psi4.core.Vector) → bool

Expands the row dimension by one, and then orthogonalizes vector v against the current rows before setting the new row to the orthogonalized copy of v

apply_denominator(self: psi4.core.Matrix, Matrix: psi4.core.Matrix) → None

Apply matrix of denominators to this matrix

array_interface(self: psi4.core.Matrix) → list
axpy(self: psi4.core.Matrix, a: float, X: psi4.core.Matrix) → None

Add to this matrix another matrix scaled by a

back_transform(*args, **kwargs)

Overloaded function.

  1. back_transform(self: psi4.core.Matrix, transformer: psi4.core.Matrix) -> None

Backtransform this with transformer

  1. back_transform(self: psi4.core.Matrix, a: psi4.core.Matrix, transformer: psi4.core.Matrix) -> None

Backtransform A with transformer

chain_dot(*args, **kwargs)

Chains dot products together from a series of Psi4 Matrix classes.

By default there is no transposes, an optional vector of booleans can be passed in.

cholesky_factorize(self: psi4.core.Matrix) → None

Computes the Cholesky factorization of a real symmetric positive definite matrix

clone(self: psi4.core.Matrix) → psi4.core.Matrix

Creates exact copy of the matrix and returns it

coldim(self: psi4.core.Matrix) → psi4.core.Dimension

Returns the columns per irrep array

cols(self: psi4.core.Matrix, h: int=0) → int

Returns the columns in irrep h

copy(self: psi4.core.Matrix, arg0: psi4.core.Matrix) → None

Returns a copy of the matrix

copy_lower_to_upper(self: psi4.core.Matrix) → None

Copy the lower triangle to the upper triangle

copy_upper_to_lower(self: psi4.core.Matrix) → None

Copy the upper triangle to the lower triangle

diagonalize(self: psi4.core.Matrix, eigvectors: psi4.core.Matrix, eigvalues: psi4.core.Vector, order: psi4.core.DiagonalizeOrder=DiagonalizeOrder.Ascending) → None

Diagonalizes this matrix, space for the eigvectors and eigvalues must be created by caller. Only for symmetric matrices.

doublet(A: psi4.core.Matrix, B: psi4.core.Matrix, transA: bool=False, transB: bool=False) → psi4.core.Matrix

Returns the multiplication of two matrices A and B, with options to transpose each beforehand

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.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

1
2
>>> data = np.random.rand(20)
>>> vector = array_to_matrix(data)
1
2
3
4
>>> 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

gemm(self: psi4.core.Matrix, transa: bool, transb: bool, alpha: float, a: psi4.core.Matrix, b: psi4.core.Matrix, beta: float) → None

Generalized matrix multiplication argument transa Transpose the left matrix? argument transb Transpose the right matrix? argument alpha Prefactor for the matrix multiplication argument A Left matrix argument B Right matrix argument beta Prefactor for the resulting matrix

general_invert(self: psi4.core.Matrix) → None

Computes the inverse of any nonsingular matrix using LU factorization

get(*args, **kwargs)

Overloaded function.

  1. get(self: psi4.core.Matrix, h: int, m: int, n: int) -> float

Returns a single element of a matrix in subblock h, row m, col n

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

Returns a single element of a matrix, row m, col n

identity(self: psi4.core.Matrix) → None

Sets the matrix to the identity

invert(self: psi4.core.Matrix) → None

Computes the inverse of a real symmetric positive definite matrix

load(self: psi4.core.Matrix, filename: str) → None

Loads a block matrix from an ASCII file (see tests/mints3 for format)

load_mpqc(self: psi4.core.Matrix, filename: str) → None

Loads a matrix from an ASCII file in MPQC format

nirrep(self: psi4.core.Matrix) → 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.

partial_cholesky_factorize(self: psi4.core.Matrix, delta: float=0.0, throw_if_negative: bool=False) → psi4.core.Matrix

Computes the fully pivoted partial Cholesky factorization of a real symmetric positive semidefinite matrix, to numerical precision delta

power(self: psi4.core.Matrix, alpha: float, cutoff: float=1e-12) → psi4.core.Dimension

Takes the matrix to the alpha power with precision cutoff

print_atom_vector(self: psi4.core.Matrix, RMRoutfile: str='outfile') → None

Print the matrix with atom labels, assuming it is an natom X 3 tensor

print_out(self: psi4.core.Matrix) → None

Prints the matrix to the output file

pseudoinverse(self: psi4.core.Matrix, condition: float, nremoved: int) → psi4.core.Matrix

Computes the matrix which is the conditioned pseudoinverse of this matrix

remove_symmetry(self: psi4.core.Matrix, a: psi4.core.Matrix, transformer: psi4.core.Matrix) → None

Remove symmetry from a matrix A with PetiteList::sotoao()

rms(self: psi4.core.Matrix) → float

Returns the rms of this matrix

rotate_columns(self: psi4.core.Matrix, h: int, i: int, j: int, theta: float) → None

Rotates columns i and j in irrep h by angle theta

rowdim(self: psi4.core.Matrix) → psi4.core.Dimension

Returns the rows per irrep array

rows(self: psi4.core.Matrix, h: int=0) → int

Returns the rows in irrep h

save(self: psi4.core.Matrix, filename: str, append: bool=True, saveLowerTriangle: bool=True, saveSubBlocks: bool=False) → None

Saves the matrix in ASCII format to filename, as symmetry blocks or full matrix

scale(self: psi4.core.Matrix, a: float) → None

Scales the matrix by the floating point value a

scale_column(self: psi4.core.Matrix, h: int, n: int, a: float) → None

Scales column n of irrep h by a

scale_row(self: psi4.core.Matrix, h: int, m: int, a: float) → None

Scales row m of irrep h by a

schmidt(self: psi4.core.Matrix) → None

Calls the libqt schmidt function

set(*args, **kwargs)

Overloaded function.

  1. set(self: psi4.core.Matrix, val: float) -> None

Sets every element of a matrix to val

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

Sets a single element of a matrix to val at row m, col n

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

Sets a single element of a matrix, subblock h, row m, col n, with value val

subtract(self: psi4.core.Matrix, arg0: psi4.core.Matrix) → None

Substract a matrix from this matrix

sum_of_squares(self: psi4.core.Matrix) → float

Returns the sum of the squares of this matrix

symmetrize_gradient(self: psi4.core.Matrix, mol: psi::Molecule) → None

Symmetrizes a gradient-like matrix (N,3) using information from a given molecule

symmetry(self: psi4.core.Matrix) → int

Returns the overall symmetry of the matrix

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

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

Parameters:
  • matrix (Matrix or Vector) – Pointers to which Psi4 core class should be used in the construction.
  • copy (bool) – Copy the data if True, return a view otherwise
  • dense (bool) – Converts irreped Psi4 objects to diagonally blocked dense arrays. 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:

np.array or list of of np.array

Notes

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

Examples

1
2
3
4
5
>>> data = psi4.Matrix(3, 3)
>>> data.to_array()
[[ 0.  0.  0.]
 [ 0.  0.  0.]
 [ 0.  0.  0.]]
to_serial(data)

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

trace(self: psi4.core.Matrix) → float

Returns the trace of the matrix

transform(*args, **kwargs)

Overloaded function.

  1. transform(self: psi4.core.Matrix, transformer: psi4.core.Matrix) -> None

Transform this matrix with transformer

  1. transform(self: psi4.core.Matrix, a: psi4.core.Matrix, transformer: psi4.core.Matrix) -> None

Transform A with transformer

transpose(self: psi4.core.Matrix) → psi4.core.Matrix

Creates a new matrix that is the transpose of this matrix

transpose_this(self: psi4.core.Matrix) → None

Transpose the matrix in-place

triplet(A: psi4.core.Matrix, B: psi4.core.Matrix, C: psi4.core.Matrix, transA: bool=False, transB: bool=False, transC: bool=False) → psi4.core.Matrix

Returns the multiplication of three matrics A, B, and C, with options to transpose each beforehand

vector_dot(self: psi4.core.Matrix, rhs: psi4.core.Matrix) → float

Returns the vector dot product of this with rhs

zero(self: psi4.core.Matrix) → None

Zero all elements of the matrix

zero_diagonal(self: psi4.core.Matrix) → None

Zero the diagonal of the matrix

zero_lower(self: psi4.core.Matrix) → None

Zero the lower triangle

zero_upper(self: psi4.core.Matrix) → None

Zero the upper triangle

absmax(self: psi4.core.Matrix) → float

Returns the absolute maximum value

accumulate_product(self: psi4.core.Matrix, arg0: psi4.core.Matrix, arg1: psi4.core.Matrix) → None

Multiplies two arguments and adds the result to this matrix

add(self: psi4.core.Matrix, arg0: psi4.core.Matrix) → None

Adds a matrix to this matrix

add_and_orthogonalize_row(self: psi4.core.Matrix, v: psi4.core.Vector) → bool

Expands the row dimension by one, and then orthogonalizes vector v against the current rows before setting the new row to the orthogonalized copy of v

apply_denominator(self: psi4.core.Matrix, Matrix: psi4.core.Matrix) → None

Apply matrix of denominators to this matrix

array_interface(self: psi4.core.Matrix) → list
axpy(self: psi4.core.Matrix, a: float, X: psi4.core.Matrix) → None

Add to this matrix another matrix scaled by a

back_transform(*args, **kwargs)

Overloaded function.

  1. back_transform(self: psi4.core.Matrix, transformer: psi4.core.Matrix) -> None

Backtransform this with transformer

  1. back_transform(self: psi4.core.Matrix, a: psi4.core.Matrix, transformer: psi4.core.Matrix) -> None

Backtransform A with transformer

chain_dot(*args, **kwargs)

Chains dot products together from a series of Psi4 Matrix classes.

By default there is no transposes, an optional vector of booleans can be passed in.

cholesky_factorize(self: psi4.core.Matrix) → None

Computes the Cholesky factorization of a real symmetric positive definite matrix

clone(self: psi4.core.Matrix) → psi4.core.Matrix

Creates exact copy of the matrix and returns it

coldim(self: psi4.core.Matrix) → psi4.core.Dimension

Returns the columns per irrep array

cols(self: psi4.core.Matrix, h: int=0) → int

Returns the columns in irrep h

copy(self: psi4.core.Matrix, arg0: psi4.core.Matrix) → None

Returns a copy of the matrix

copy_lower_to_upper(self: psi4.core.Matrix) → None

Copy the lower triangle to the upper triangle

copy_upper_to_lower(self: psi4.core.Matrix) → None

Copy the upper triangle to the lower triangle

diagonalize(self: psi4.core.Matrix, eigvectors: psi4.core.Matrix, eigvalues: psi4.core.Vector, order: psi4.core.DiagonalizeOrder=DiagonalizeOrder.Ascending) → None

Diagonalizes this matrix, space for the eigvectors and eigvalues must be created by caller. Only for symmetric matrices.

doublet(A: psi4.core.Matrix, B: psi4.core.Matrix, transA: bool=False, transB: bool=False) → psi4.core.Matrix

Returns the multiplication of two matrices A and B, with options to transpose each beforehand

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.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

1
2
>>> data = np.random.rand(20)
>>> vector = array_to_matrix(data)
1
2
3
4
>>> 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

gemm(self: psi4.core.Matrix, transa: bool, transb: bool, alpha: float, a: psi4.core.Matrix, b: psi4.core.Matrix, beta: float) → None

Generalized matrix multiplication argument transa Transpose the left matrix? argument transb Transpose the right matrix? argument alpha Prefactor for the matrix multiplication argument A Left matrix argument B Right matrix argument beta Prefactor for the resulting matrix

general_invert(self: psi4.core.Matrix) → None

Computes the inverse of any nonsingular matrix using LU factorization

get(*args, **kwargs)

Overloaded function.

  1. get(self: psi4.core.Matrix, h: int, m: int, n: int) -> float

Returns a single element of a matrix in subblock h, row m, col n

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

Returns a single element of a matrix, row m, col n

identity(self: psi4.core.Matrix) → None

Sets the matrix to the identity

invert(self: psi4.core.Matrix) → None

Computes the inverse of a real symmetric positive definite matrix

load(self: psi4.core.Matrix, filename: str) → None

Loads a block matrix from an ASCII file (see tests/mints3 for format)

load_mpqc(self: psi4.core.Matrix, filename: str) → None

Loads a matrix from an ASCII file in MPQC format

name

The name of the Matrix. Used in printing.

nirrep(self: psi4.core.Matrix) → 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.

partial_cholesky_factorize(self: psi4.core.Matrix, delta: float=0.0, throw_if_negative: bool=False) → psi4.core.Matrix

Computes the fully pivoted partial Cholesky factorization of a real symmetric positive semidefinite matrix, to numerical precision delta

power(self: psi4.core.Matrix, alpha: float, cutoff: float=1e-12) → psi4.core.Dimension

Takes the matrix to the alpha power with precision cutoff

print_atom_vector(self: psi4.core.Matrix, RMRoutfile: str='outfile') → None

Print the matrix with atom labels, assuming it is an natom X 3 tensor

print_out(self: psi4.core.Matrix) → None

Prints the matrix to the output file

pseudoinverse(self: psi4.core.Matrix, condition: float, nremoved: int) → psi4.core.Matrix

Computes the matrix which is the conditioned pseudoinverse of this matrix

remove_symmetry(self: psi4.core.Matrix, a: psi4.core.Matrix, transformer: psi4.core.Matrix) → None

Remove symmetry from a matrix A with PetiteList::sotoao()

rms(self: psi4.core.Matrix) → float

Returns the rms of this matrix

rotate_columns(self: psi4.core.Matrix, h: int, i: int, j: int, theta: float) → None

Rotates columns i and j in irrep h by angle theta

rowdim(self: psi4.core.Matrix) → psi4.core.Dimension

Returns the rows per irrep array

rows(self: psi4.core.Matrix, h: int=0) → int

Returns the rows in irrep h

save(self: psi4.core.Matrix, filename: str, append: bool=True, saveLowerTriangle: bool=True, saveSubBlocks: bool=False) → None

Saves the matrix in ASCII format to filename, as symmetry blocks or full matrix

scale(self: psi4.core.Matrix, a: float) → None

Scales the matrix by the floating point value a

scale_column(self: psi4.core.Matrix, h: int, n: int, a: float) → None

Scales column n of irrep h by a

scale_row(self: psi4.core.Matrix, h: int, m: int, a: float) → None

Scales row m of irrep h by a

schmidt(self: psi4.core.Matrix) → None

Calls the libqt schmidt function

set(*args, **kwargs)

Overloaded function.

  1. set(self: psi4.core.Matrix, val: float) -> None

Sets every element of a matrix to val

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

Sets a single element of a matrix to val at row m, col n

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

Sets a single element of a matrix, subblock h, row m, col n, with value val

shape

Shape of the Psi4 data object

subtract(self: psi4.core.Matrix, arg0: psi4.core.Matrix) → None

Substract a matrix from this matrix

sum_of_squares(self: psi4.core.Matrix) → float

Returns the sum of the squares of this matrix

symmetrize_gradient(self: psi4.core.Matrix, mol: psi::Molecule) → None

Symmetrizes a gradient-like matrix (N,3) using information from a given molecule

symmetry(self: psi4.core.Matrix) → int

Returns the overall symmetry of the matrix

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

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

Parameters:
  • matrix (Matrix or Vector) – Pointers to which Psi4 core class should be used in the construction.
  • copy (bool) – Copy the data if True, return a view otherwise
  • dense (bool) – Converts irreped Psi4 objects to diagonally blocked dense arrays. 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:

np.array or list of of np.array

Notes

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

Examples

1
2
3
4
5
>>> data = psi4.Matrix(3, 3)
>>> data.to_array()
[[ 0.  0.  0.]
 [ 0.  0.  0.]
 [ 0.  0.  0.]]
to_serial(data)

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

trace(self: psi4.core.Matrix) → float

Returns the trace of the matrix

transform(*args, **kwargs)

Overloaded function.

  1. transform(self: psi4.core.Matrix, transformer: psi4.core.Matrix) -> None

Transform this matrix with transformer

  1. transform(self: psi4.core.Matrix, a: psi4.core.Matrix, transformer: psi4.core.Matrix) -> None

Transform A with transformer

transpose(self: psi4.core.Matrix) → psi4.core.Matrix

Creates a new matrix that is the transpose of this matrix

transpose_this(self: psi4.core.Matrix) → None

Transpose the matrix in-place

triplet(A: psi4.core.Matrix, B: psi4.core.Matrix, C: psi4.core.Matrix, transA: bool=False, transB: bool=False, transC: bool=False) → psi4.core.Matrix

Returns the multiplication of three matrics A, B, and C, with options to transpose each beforehand

vector_dot(self: psi4.core.Matrix, rhs: psi4.core.Matrix) → float

Returns the vector dot product of this with rhs

zero(self: psi4.core.Matrix) → None

Zero all elements of the matrix

zero_diagonal(self: psi4.core.Matrix) → None

Zero the diagonal of the matrix

zero_lower(self: psi4.core.Matrix) → None

Zero the lower triangle

zero_upper(self: psi4.core.Matrix) → None

Zero the upper triangle