Tensor Network Theory Library  Beta release 1.2.1
A library of routines for performing TNT-based operations
 All Data Structures Functions Variables Groups Pages
tntMatCreateOpArray.m
1 %======================================================================
2 %> @ingroup matscripts
3 %> Turns a matrix into a node structure representing an operator in the MPS library.
4 %> To create a single node, call the function passing a cell of length 1 containing the matrix. The node can then be loaded using tntNodesLoad().
5 %>
6 %> To create a node array, call the function passing a cell array, each entry contraining a matrix. The node can then be loaded using tntNodeArraysLoad().
7 %>
8 %> The nodes are created have two legs according to the labelling of the MPS library i.e. columns correspond to the upwards facing leg and are labelled "U", rows correspond to the downwards facing leg and are labelled "D".
9 %>
10 %> @param ops A cell array contraining matrices for the operators.
11 %>
12 %> @retval narr A structure representing a singe node or a node array.
13 %======================================================================
14 function narr = tntMatCreateOpArray(ops)
15 
16 if (isempty(ops))
17  narr = struct('tensor',{},'ids',{},'indices',{});
18 end
19 
20 for loop = 1:length(ops)
21  if (~ismatrix(ops{loop}))
22  error('all input operators must be a matrix!');
23  end
24  tensor.elems_type = 'values';
25  tensor.elems.vals = ops{loop};
26  tensor.dims = size(ops{loop});
27  tensor.qn_info.qn_dir = [0,0];
28  tensor.qn_info.qn_index = {[],[]};
29  narr(loop).tensor = tensor;
30  narr(loop).ids = 'DU';
31  narr(loop).indices = {0,1};
32 end
33 
34 end
function tntMatCreateOpArray(in ops)
void tntNodesLoad(const char *loadname, tntNode varA, tntNode varB, tntNode varC, tntNode varD, tntNode varE)
Definition: tntLoad.c:276
void tntNodeArraysLoad(const char *loadname, tntNodeArray arrA, tntNodeArray arrB, tntNodeArray arrC, tntNodeArray arrD, tntNodeArray arrE)
Definition: tntLoad.c:311