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
tntMatCreateProdMps.m
1 %======================================================================
2 %> @ingroup matscripts
3 %> Creates a structure that represents a product MPS network, that can then be loaded uses tntNetworksLoad().
4 %> Note that the created wave function may not be normalised.
5 %>
6 %> @param cfg A cell, each entry containing a vector representing the state on each site
7 %> @param qnums The quantum numbers for the physical leg, or an empty array if there is no global symmetry
8 %>
9 %> @retval wf A structure representing the product MPS
10 %======================================================================
11 
12 function wf = tntMatCreateProdMps(cfg,qnums)
13 
14 
15 L = length(cfg);
16 if (0 == L)
17  wf.nodes = struct('tensor',{},'ids',{},'indices',{});
18 else
19  d = length(cfg{1});
20  qcurr = zeros(size(qnums,1),1);
21 end
22 
23 for loop = 1:L
24  if (~isempty(qnums))
25  ind = find(cfg{loop},1);
26  tensor.elems_type = 'blocks';
27  tensor.elems.qn_tot = qcurr+qnums(:,ind);
28  tensor.elems.vals{1} = 1;
29  tensor.elems.rowlegs = [0,1];
30  tensor.elems.collegs = 2;
31  tensor.elems.indmapr = [-ones(1,d);zeros(1,d)];
32  tensor.elems.indmapr(1,ind) = 0;
33  tensor.elems.indmapc = [0;0];
34  tensor.qn_info.qn_dir = [1,1,-1];
35  tensor.qn_info.qn_index = {qcurr,qnums,qcurr+qnums(:,ind)};
36  qcurr = qcurr+qnums(:,ind);
37  else
38  tensor.elems_type = 'values';
39  tensor.elems.vals = cfg{loop}/sqrt(cfg{loop}'*cfg{loop});
40  tensor.qn_info.qn_dir = [0,0,0];
41  tensor.qn_info.qn_index = {[],[],[]};
42  end
43  tensor.dims = [1,d,1];
44 
45  wf.nodes(loop).tensor = tensor;
46  wf.nodes(loop).ids = 'LRD';
47  wf.nodes(loop).indices = {0,2,1};
48 end
49 
50 wf.start = 0;
51 wf.start_leg = 'L';
52 wf.end = L-1;
53 wf.end_leg = 'R';
54 
55 wf.connections = cell(L,L);
56 
57 for loop=2:L
58  wf.connections{loop-1,loop} = 'RL';
59 end
60 
61 end
void tntNetworksLoad(const char *loadname, tntNetwork varA, tntNetwork varB, tntNetwork varC, tntNetwork varD, tntNetwork varE)
Definition: tntLoad.c:381
function tntMatCreateProdMps(in cfg, in qnums)