Tensor Network Theory Library  Beta release 1.0 A library of routines for performing TNT-based operations
Networks

## Typedefs

typedef struct tnetwork * tntNetwork

## Functions

tntNetwork tntNetworkCopy (tntNetwork tnw)

tntNetwork tntNetworkCreate (void)

void tntNetworkFree (tntNetwork *tnwp)

tntNode tntNetworkMinSite (tntNode tnA, tntNetwork *nwMV, unsigned NM, tntNode(*eig_contract)(tntNode, tntNetwork), void(*eig_prep)(tntNode, tntNetwork), tntComplex *eigval)

tntNetwork tntNetworkSplit (tntNetwork tnw, tntNode tnFirst_1, unsigned leg_start_1, tntNode tnLast_1, unsigned leg_end_1, tntNode tnFirst_2, unsigned leg_start_2, tntNode tnLast_2, unsigned leg_end_2, unsigned numSplit_1, tntNode *tnSplit_1, unsigned numSplit_2, tntNode *tnSplit_2)

void tntNetworkToNodeGroup (tntNetwork *tnwp)

## Detailed Description

This section contains functions and properties that are concerned with the entire network, where the network can, for example, represent the wave function of a system.

## Typedef Documentation

Use this type for defining an entire network. This object contains information about the start and end points of the network.

## Function Documentation

 tntNetwork tntNetworkCopy ( tntNetwork tnw )

Makes a copy of the original network, making a seperate copy of all the nodes and connections between them in the new network. This function works for any network geometry.

Returns
The copy of the network.
Parameters
 tnw Pointer to the original network
Examples:
tebd.c.
 tntNetwork tntNetworkCreate ( void )

Creates a new empty network. New nodes can be added using tntNodeInsertAtStart() or tntNodeInsertAtEnd().

Returns
The new network.
 void tntNetworkFree ( tntNetwork * tnwp )

Deletes all the nodes (and associated memory) in a network, as well as the network structure itself. After calling this function tnw will no longer refer to a valid network and should not be used again.

Returns
No return value.
Parameters
 tnwp Pointer to network to delete
Examples:
dmrg.c, and tebd.c.
 tntNode tntNetworkMinSite ( tntNode tnA, tntNetwork * nwMV, unsigned NM, tntNode(*)(tntNode, tntNetwork) eig_contract, void(*)(tntNode, tntNetwork) eig_prep, tntComplex * eigval )

This function finds smallest eigenvalue and corresponding eigenvector of a matrix $$M$$. The matrix $$M$$ can be represented by a sum of terms $$M_i$$, where each term is given by one of more nodes in the network that are connected to one another i.e. the matrix does not need to be represented by a single node or a single group of nodes. The node tnA represents a vector that is multiplied by $$M$$ by contracting tnA with the remaining nodes in the network nwMV[i] for each term using the function *eig_contract that is passed as an argument.

Returns
The function returns the node (which will have the same struture as tnA i.e. the same number and dimension of legs) which represents the eigenvector having the smallest eigenvalue of the matrix.
Parameters
 tnA The node to be minimised - unchanged by the function nwMV Array of networks representing the matrix times vector for each term in the sum for the total matrix. This is unchanged by the function NM The number of terms in the sum for the matrix eig_contract Pointer to the network function that performs the network contraction equivalent to matrix times vector. This network function should return the pointer to the contracted node that is the result of the contraction. The network that is contracted that is passed as an argument should not be freed in the network function. eig_prep Pointer to the network function that prepares the nodes for the the network contraction equivalent to matrix times vector. This function should leave the nodes unchanged apart from a preparation step using tntNodePrepContract(). eigval Pointer to the eigenvalue for this minimisation
 tntNetwork tntNetworkSplit ( tntNetwork tnw, tntNode tnFirst_1, unsigned leg_start_1, tntNode tnLast_1, unsigned leg_end_1, tntNode tnFirst_2, unsigned leg_start_2, tntNode tnLast_2, unsigned leg_end_2, unsigned numSplit_1, tntNode * tnSplit_1, unsigned numSplit_2, tntNode * tnSplit_2 )

Splits a network into two, when the nodes that need to be split, and the new first and last nodes are given as arguments. For example, taking the network below:

To split the network above vertically down the middle you would need to pass as arguments the nodes that need to be split on one side in an array i.e. [B,F] and the nodes that nodes that need to be split on the other side as another array i.e. [C,G]. Any connections between the nodes in the first array with any of the nodes in the second array and vice versa will be removed. Connections between nodes in a single array (e.g. between B and F) will not be removed.

Alternatively to split the network above horizontally you would need to pass as arguments the array [A,B,C,D] for the nodes that need to be split on one side of the network, and the array [E,F,G,H] for the nodes that need to be split on the other side of the network.

The new first and last nodes should also be specified. In the above example it would be sensible to choose A and B as the new first and last node for the first network, and C and D as the new first and last node for the second network, although the choice is up to the user.

For each of the first and last nodes, a leg pointing to the first and last node in the network should be specified. This leg should not currently be connected to anything, and should have dimension 1. If a leg is specified that does not already exist, then it will be created.

The network passed as an argument now refers to the first network. The second network is given as the return value.

All split connections will now point to NULL.

Warning
Failure to correctly identify all nodes that need to be split to seperate the network could lead to memory errors at later points.
Returns
The second network. The label for the first network is that passed as an argument and is unchanged.
Parameters
 tnw On entry: the network to split. On exit: The first network. tnFirst_1 The node that will be the first node in the first network leg_start_1 The leg of the first node that will point to the start of the first network tnLast_1 The node that will be the last node in the first network leg_end_1 The leg of the last node that will point to the end of the first network tnFirst_2 The node that will be the first node in the second network leg_start_2 The leg of the first node that will point to the start of the second network tnLast_2 The node that will be the last node in the second network leg_end_2 The leg of the second node that will point to the end of the second network numSplit_1 The number of nodes that need to be split on the side of the first network tnSplit_1 Array of length numSplit_1 listing all the nodes that need to be split on one side numSplit_2 The number of nodes that need to be split on the side of the first network tnSplit_2 Array of length numSplit_2 listing all the nodes that need to be split on the other side
 void tntNetworkToNodeGroup ( tntNetwork * tnwp )

Changes a network to a node group i.e. strips the connections of the terminating nodes to the network object, removes these singleton legs and deletes the network object. This function can be useful when joining two networks together to form a single network. If the network you are changing is not joined to another network, make sure you have a variable assigned to one of the nodes in the network before calling this function so that you can address nodes in the group once the network has been deleted.

Parameters
 tnwp Pointer to network to change to node group