annotate toolboxes/FullBNT-1.0.7/bnt/potentials/@scgpot/extension_pot.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function pot = extension_pot(oldpot, ddom_u, dsizes, ctaildom_u, csizes)
Daniel@0 2 % EXTENSION_POT Extense a stable CG potential.
Daniel@0 3 % pot = extension_pot(oldpot, ddom_u, ctaildom_u, dsizes, csizes)
Daniel@0 4 % ddom_u Added discrete nodes
Daniel@0 5 % ctaildom_u Added continuous tail nodes
Daniel@0 6 % csizes is the size of the tail nodes.
Daniel@0 7
Daniel@0 8 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Daniel@0 9 % A CG potential can be extended by adding discrete variables to its %
Daniel@0 10 % domain of continuous variables to its tail %
Daniel@0 11 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Daniel@0 12 ddom = myunion(oldpot.ddom, ddom_u);
Daniel@0 13 ctaildom = myunion(oldpot.ctaildom, ctaildom_u);
Daniel@0 14 cheaddom = oldpot.cheaddom;
Daniel@0 15 udom = myunion(ddom_u, ctaildom_u);
Daniel@0 16 domain = myunion(oldpot.domain, udom);
Daniel@0 17
Daniel@0 18 ns = zeros(1,max(domain));
Daniel@0 19 ns(ddom_u) = dsizes;
Daniel@0 20 ns(ctaildom_u) = csizes;
Daniel@0 21 ns(oldpot.ddom) = oldpot.dsizes;
Daniel@0 22 ns(oldpot.cheaddom) = oldpot.cheadsizes;
Daniel@0 23 ns(oldpot.ctaildom) = oldpot.ctailsizes;
Daniel@0 24
Daniel@0 25 dsizes = ns(ddom);
Daniel@0 26 dsize = prod(ns(ddom));
Daniel@0 27 cheadsizes = ns(cheaddom);
Daniel@0 28 cheadsize = sum(ns(cheaddom));
Daniel@0 29 ctailsizes = ns(ctaildom);
Daniel@0 30 ctailsize = sum(ns(ctaildom));
Daniel@0 31
Daniel@0 32 BZ = zeros(cheadsize, ctailsize);
Daniel@0 33 potarray = cell(1, dsize);
Daniel@0 34 mask = find_equiv_posns(oldpot.ddom, ddom);
Daniel@0 35
Daniel@0 36 tmask = find_equiv_posns(oldpot.ctaildom, ctaildom);
Daniel@0 37 tu = block(tmask, ctailsizes);
Daniel@0 38
Daniel@0 39 for i=1:dsize
Daniel@0 40 sub1 = ind2subv(dsizes, i);
Daniel@0 41 sub2 = sub1(mask);
Daniel@0 42 ind = subv2ind(oldpot.dsizes, sub2);
Daniel@0 43 if isempty(ind)
Daniel@0 44 ind = 1;
Daniel@0 45 end
Daniel@0 46 potc = struct(oldpot.scgpotc{ind});
Daniel@0 47 p = potc.p;
Daniel@0 48 B = BZ;
Daniel@0 49 if ~isempty(B)
Daniel@0 50 B(:, tu) = potc.B;
Daniel@0 51 end
Daniel@0 52 potarray{i} = scgcpot(cheadsize, ctailsize, p, potc.A, B, potc.C);
Daniel@0 53 end
Daniel@0 54
Daniel@0 55 pot = scgpot(ddom, cheaddom, ctaildom, ns,potarray);