Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/bnt/potentials/@scgpot/extension_pot.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 function pot = extension_pot(oldpot, ddom_u, dsizes, ctaildom_u, csizes) | |
2 % EXTENSION_POT Extense a stable CG potential. | |
3 % pot = extension_pot(oldpot, ddom_u, ctaildom_u, dsizes, csizes) | |
4 % ddom_u Added discrete nodes | |
5 % ctaildom_u Added continuous tail nodes | |
6 % csizes is the size of the tail nodes. | |
7 | |
8 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
9 % A CG potential can be extended by adding discrete variables to its % | |
10 % domain of continuous variables to its tail % | |
11 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
12 ddom = myunion(oldpot.ddom, ddom_u); | |
13 ctaildom = myunion(oldpot.ctaildom, ctaildom_u); | |
14 cheaddom = oldpot.cheaddom; | |
15 udom = myunion(ddom_u, ctaildom_u); | |
16 domain = myunion(oldpot.domain, udom); | |
17 | |
18 ns = zeros(1,max(domain)); | |
19 ns(ddom_u) = dsizes; | |
20 ns(ctaildom_u) = csizes; | |
21 ns(oldpot.ddom) = oldpot.dsizes; | |
22 ns(oldpot.cheaddom) = oldpot.cheadsizes; | |
23 ns(oldpot.ctaildom) = oldpot.ctailsizes; | |
24 | |
25 dsizes = ns(ddom); | |
26 dsize = prod(ns(ddom)); | |
27 cheadsizes = ns(cheaddom); | |
28 cheadsize = sum(ns(cheaddom)); | |
29 ctailsizes = ns(ctaildom); | |
30 ctailsize = sum(ns(ctaildom)); | |
31 | |
32 BZ = zeros(cheadsize, ctailsize); | |
33 potarray = cell(1, dsize); | |
34 mask = find_equiv_posns(oldpot.ddom, ddom); | |
35 | |
36 tmask = find_equiv_posns(oldpot.ctaildom, ctaildom); | |
37 tu = block(tmask, ctailsizes); | |
38 | |
39 for i=1:dsize | |
40 sub1 = ind2subv(dsizes, i); | |
41 sub2 = sub1(mask); | |
42 ind = subv2ind(oldpot.dsizes, sub2); | |
43 if isempty(ind) | |
44 ind = 1; | |
45 end | |
46 potc = struct(oldpot.scgpotc{ind}); | |
47 p = potc.p; | |
48 B = BZ; | |
49 if ~isempty(B) | |
50 B(:, tu) = potc.B; | |
51 end | |
52 potarray{i} = scgcpot(cheadsize, ctailsize, p, potc.A, B, potc.C); | |
53 end | |
54 | |
55 pot = scgpot(ddom, cheaddom, ctaildom, ns,potarray); |