Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/bnt/inference/static/@gibbs_sampling_inf_engine/private/compute_strides.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 strides = compute_strides(bnet) | |
2 % COMPUTE_STRIDES For each CPT and each variable in that CPT, | |
3 % returns the stride of that variable. So in future, we can | |
4 % quickly extract a slice of the CPT. | |
5 % | |
6 % The return value is a 2d array, where strides(i,j) contains the | |
7 % stride of the jth variable in the ith CPT. Cell arrays would | |
8 % have saved space but they are slower. | |
9 % | |
10 | |
11 num_cpts = size(bnet.CPD, 2); | |
12 max_cpt_dim = 1 + max(sum(bnet.dag)); | |
13 strides = zeros(num_cpts, max_cpt_dim); | |
14 | |
15 for i = 1:num_cpts | |
16 c = CPT(bnet, i); | |
17 siz = size(CPT(bnet, i)); | |
18 | |
19 % Deal with the special case of a 1-d array separately | |
20 if siz(2) == 1 | |
21 dim = 1; | |
22 else | |
23 dim = size(siz, 2); | |
24 end | |
25 | |
26 strides(i, 1:dim ) = [1 cumprod(siz(1:dim-1))]; | |
27 end |