3.8.3. horton.matrix.cholesky – Cholesky decomposition of four-index objects

class horton.matrix.cholesky.CholeskyFourIndex(nbasis, nvec=None, array=None, array2=None)

Bases: horton.matrix.base.FourIndex

Arguments:

nbasis
The number of basis functions.

Optional arguments:

nvec
The number of (2-index) Cholesky vectors.
array
The array with Cholesky vectors, shape = (nvec, nbasis, nbasis).
array2
The second set of Cholesky vectors, if different from the first.

Either nvec or array must be given (or both).

assign(other)

Assign with the contents of another object

Arguments:

other
Another CholeskyFourIndex object.
assign_four_index_transform(ao_integrals, exp0, exp1=None, exp2=None, exp3=None, method='tensordot')

Perform four index transformation.

Arguments:

oa_integrals
A CholeskyFourIndex with integrals in atomic orbitals.
exp0
A DenseExpansion object with molecular orbitals

Optional arguments:

exp1, exp2, exp3
Can be provided to transform each index differently. See parse_four_index_transform_exps for details.
method
Either einsum or tensordot (default).
change_basis_signs(signs)

Correct for different sign conventions of the basis functions.

clear()

Reset all elements to zero.

contract_two_to_four(subscripts, two, out=None, factor=1.0, clear=True)

Contracts with a two-index object to obtain a four-index object.

Arguments:

subscripts
Any of abcd,cd->acbd, abcd,cd->acdb, abcd,cb->acdb, abcd,cb->acbd, abcd,ab->acbd, abcd,ab->acdb, abcd,ad->acbd, abcd,ad->acdb, abcd,ad->abcd, abcd,ad->abdc, abcd,bd->abcd, abcd,bd->abdc, abcd,bc->abdc, abcd,bc->abcd, abcd,ac->abcd, abcd,ac->abdc
two
An instance of DenseTwoIndex.

Optional arguments:

out, factor, clear
See DenseLinalgFactory.einsum()
contract_two_to_two(subscripts, two, out=None, factor=1.0, clear=True)

Contract self with a two-index to obtain a two-index.

Arguments:

subscripts
Any of abcd,bd->ac (direct), abcd,cb->ad (exchange)
two
The input two-index object. (DenseTwoIndex)

Optional arguments:

out, factor, clear
See DenseLinalgFactory.einsum()
copy()

Return a copy of the current four-index operator

decouple_array2()

Allocates a second Cholesky vector if not done yet

classmethod from_hdf5(grp)

Construct an instance from data previously stored in an h5py.Group.

Arguments:

grp
An h5py.Group object.
get_dense()

Return the DenseFourIndex equivalent. ONLY FOR TESTING. SUPER SLOW.

get_element(i, j, k, l)

Return a matrix element

iadd(other, factor)

This method is not supported due to the Cholesky decomposition.

iadd_exchange()

In-place addition of its own exchange contribution

is_symmetric(symmetry=2, rtol=1e-05, atol=1e-08)

Check the symmetry of the array.

Optional arguments:

symmetry
The symmetry to check. See Handling of index symmetry for more details.
rtol and atol
relative and absolute tolerance. See to np.allclose.
iscale(factor)

In-place multiplication with a scalar

Arguments:

factor
A scalar factor.
itranspose()

In-place transpose: 0,1,2,3 -> 1,0,3,2

new()

Return a new four-index object with the same nbasis

permute_basis(permutation)

Reorder the coefficients for a given permutation of basis functions.

randomize()

Fill with random normal data

reset_array2()

Deallocates the second cholesky vector and sets it to match the first.

set_element(i, j, k, l, value)

This method is not supported due to the Cholesky decomposition.

slice_to_three(subscripts, out=None, factor=1.0, clear=True)

Returns a three-index contraction of the four-index object.

Arguments:

subscripts
Any of abcc->bac, abcc->abc, abcb->abc, abbc->abc

Optional arguments:

out, factor, clear
See DenseLinalgFactory.einsum()
slice_to_two(subscripts, out=None, factor=1.0, clear=True)

Returns a two-index contraction of the four-index object.

Arguments:

subscripts
Any of aabb->ab, abab->ab, abba->ab

Optional arguments:

out, factor, clear
See DenseLinalgFactory.einsum()
sum()

Return the sum of all elements. EXPENSIVE!

symmetrize(symmetry=8)
to_hdf5(grp)

Dump this object in an h5py.Group

Arguments:

grp
An h5py.Group object.
is_decoupled
nbasis

The number of basis functions

ndim

The number of axes in the N-index object.

nvec

The number of Cholesky vectors

shape

The shape of the object

class horton.matrix.cholesky.CholeskyLinalgFactory(default_nbasis=None)

Bases: horton.matrix.dense.DenseLinalgFactory

Optional arguments:

default_nbasis
The default basis size when constructing new operators/expansions.
create_expansion(nbasis=None, nfn=None)

Create a DenseExpansion with defaults from the LinalgFactory

Optional arguments:

nbasis
The number of basis functions. When not given, the default_nbasis value of the DenseLinalgFactory instance will be used.
nfn
The number of orbitals. When not given, the default_nbasis value of the DenseLinalgFactory instance will be used.
create_four_index(nbasis=None, nvec=None, array=None, array2=None)

Create a DenseFourIndex with defaults from the LinalgFactory

Optional arguments:

nbasis
The number of basis functions. When not given, the default_nbasis value of the DenseLinalgFactory instance will be used.
create_one_index(nbasis=None)

Create a DenseOneIndex with defaults from the LinalgFactory

Optional arguments:

nbasis
The number of basis functions. When not given, the default_nbasis value of the DenseLinalgFactory instance will be used.
create_three_index(nbasis=None, nbasis1=None, nbasis2=None)

Create a DenseThreeIndex with defaults from the LinalgFactory

Optional arguments:

nbasis
The number of basis functions. When not given, the default_nbasis value of the DenseLinalgFactory instance will be used.
create_two_index(nbasis=None, nbasis1=None)

Create a DenseTwoIndex with defaults from the LinalgFactory

Optional arguments:

nbasis
The number of basis functions. When not given, the default_nbasis value of the DenseLinalgFactory instance will be used.
nbasis1
The number of basis functions for the second axis if it differes from nbasis.
einsum(subscripts, out, factor, clear, *operands)

einsum wrapper for DenseNBody objects

Arguments:

subscripts
The usual subscripts argument for the einsum function, except that the format is slightly limited. All indexes must be explicitly stated. If the output argument is a scalar, -> may not be present. In all other cases, -> must be present.
out
An output DenseNBody object. This argument is not allowed when the result is a scalar.
factor
Multiply the contraction by a scalar factor.
clear
When set to False, the output argument is not zeroed before adding the contraction.
operands
A list where each element is (i) a DenseNBody object or (ii) a two-tuple of DenseNBody object and ranges to select for slicing. The ranges must be a tuple of integers of the form (begin0, end0, begin1, end1, ...) where the number of (begin, end) pairs depends on the dimensionality of the corresponding tensor.

Returns: the out object. When the out argument is given, this is returned with in-place modifications.

from_hdf5(grp)

Construct an instance from data previously stored in an h5py.Group.

Arguments:

grp
An h5py.Group object.
set_default_nbasis(nbasis)
tensordot(a, b, axes, out=None, factor=1.0, clear=True)

tensordot wrapper for dense n-index objects.

Arguments:

a, b, axes
See documentation of numpy.tensordot

Optional arguments:

out
The output argument, an instance of one of the Dense?Index classes.
to_hdf5(grp)

Write a LinalgFactory to an HDF5 group

Argument:

grp
A h5py.Group instance to write to.