# source:projects/ckbs/trunk/example/blkbidiag_mul_ok.m@632

Last change on this file since 632 was 632, checked in by aleksand, 22 months ago

Added a bunch of examples and utilities

File size: 2.0 KB
Line
1% -------------------------------------------------------------------
2% ckbs: Constrained Kalman-Bucy Smoother Program: Copyright (C) 2006-11
4%          Gianluigi Pillonetto: giapi at dei dot unipd dot it
5%          Aleksandr Aravkin:    saravkin at eos dot ubc dot ca
7% -------------------------------------------------------------------
8% \$begin blkbidiag_mul_ok.m\$\$ \$newlinech %\$\$
9% \$spell
10%       ckbs
11%       Bdiag
12%       Boffdiag
13%       blk
14%       blkdiag
15%       blkbidiag
16%       mul
17%       bidiag
18%       ak
19%       Hdia
20%       Hlow
21%       Hcheck
22%       speye
23% \$\$
24%
25% \$section blkbidiag_mul Example and Test\$\$
26%
27% \$index ckbs_blkbidiag_mul, example and test\$\$
28% \$index blkbidiag_mul, example and test\$\$
29% \$index example, blkbidiag_mul\$\$
30% \$index test, blkbidiag_mul\$\$
31%
33% \$newlinech \$\$ \$codep
34function [ok] = blkbidiag_mul_ok()
35    ok = true;
36    % -------------------------------------------------------------
37    % You can change these parameters
38    m    = 2;
39    n    = 3;
40    N    = 4;
41    p   = 3;
42    % -------------------------------------------------------------
43    % Define the problem
44    rand('seed', 123);
45    v     = rand(n * N, 3);
46
47    rand('seed', 123);
48    a = rand(n, n, N);
49    r = rand(n * N, m);
50    Hdia  = rand(n, n, N);
51    Hlow  = rand(n, n, N);
52    Hcheck = zeros(n*N);
53
54    blk_n = 1 : n;
55    for k = 1 : N
56        Hcheck(blk_n, blk_n) = Hdia(:,:, k);
57        blk_n           = blk_n + n;
58    end
59    blk_n = 1:n;
60    for k = 2:N;
61        blk_minus       = blk_n;
62        blk_n           = blk_n + n;
63        Hcheck(blk_n, blk_minus) = Hlow(:,:, k);
64       end
65    % -------------------------------------
66
67    H = ckbs_blkbidiag_mul(Hdia, Hlow, eye(n*N));
68
69    % -------------------------------------
70    check = H - Hcheck;
71    ok    = ok & ( max(max(abs(check))) < 1e-10 );
72    return
73end
74% \$\$ \$newlinech %\$\$
75% \$end
Note: See TracBrowser for help on using the repository browser.