Mercurial > hg > ltpda
comparison src/ltpda_ssmsim/test_ltpda_ssmsim.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 clear all; | |
2 compile | |
3 | |
4 Nsamples = 10; | |
5 Nstates = 10; | |
6 Nstatesout = 1; | |
7 Ninputs = 2; | |
8 Noutputs = 2; | |
9 | |
10 | |
11 Nruns = 100; | |
12 | |
13 | |
14 %% | |
15 [yx,xx,lxx,y,x,lx] = validate_mex(Nsamples, Nstates, Nstatesout, Ninputs, Noutputs); | |
16 | |
17 sum(sum(yx-y)) | |
18 % sum(sum(xx-x)) | |
19 sum(sum(lxx-lx)) | |
20 | |
21 return | |
22 | |
23 %% | |
24 | |
25 [tmex,yx,xx] = do_a_run(Nruns, Nsamples, Nstates, Nstatesout, Ninputs, Noutputs); | |
26 [tmat,y,x] = do_a_run_mat(Nruns, Nsamples, Nstates, Nstatesout, Ninputs, Noutputs); | |
27 | |
28 tmex | |
29 tmat | |
30 tmat/tmex | |
31 | |
32 | |
33 return | |
34 | |
35 %% Run-time Vs Nstates | |
36 | |
37 Nsamples = 1000; | |
38 Nstatesout = 1; | |
39 Ninputs = 2; | |
40 Noutputs = 10; | |
41 Nruns = 10; | |
42 Nstates = 5:20:250; | |
43 tmex = zeros(length(Nstates),1); | |
44 tmat = zeros(length(Nstates),1); | |
45 for jj=1:length(Nstates) | |
46 | |
47 disp('-----------------') | |
48 Ns = Nstates(jj) | |
49 [tmex(jj),y,x] = do_a_run(Nruns, Nsamples, Ns, Nstatesout, Ninputs, Noutputs); | |
50 [tmat(jj),y,x] = do_a_run_mat(Nruns, Nsamples, Ns, Nstatesout, Ninputs, Noutputs); | |
51 tmex(jj) | |
52 tmat(jj) | |
53 drawnow | |
54 end | |
55 | |
56 %% | |
57 figure | |
58 plot(Nstates, tmex, 'r-', Nstates, tmat, 'b-'); | |
59 legend('mex', 'matlab'); | |
60 ylabel('Run-time [s]'); | |
61 xlabel('Nstates') | |
62 s = sprintf('Nsamples=%d, Ninputs=%d, Noutputs=%d', Nsamples, Ninputs, Noutputs); | |
63 title(s) | |
64 | |
65 | |
66 %% Run-time Vs Inputs | |
67 | |
68 Nsamples = 10000; | |
69 Nstatesout = 1; | |
70 Ninputs = 1:2:100; | |
71 Noutputs = 10; | |
72 Nruns = 10; | |
73 Nstates = 10; | |
74 tmex = zeros(length(Ninputs),1); | |
75 tmat = zeros(length(Ninputs),1); | |
76 for jj=1:length(Ninputs) | |
77 | |
78 disp('-----------------') | |
79 Ni = Ninputs(jj) | |
80 [tmex(jj),y,x] = do_a_run(Nruns, Nsamples, Nstates, Nstatesout, Ni, Noutputs); | |
81 [tmat(jj),y,x] = do_a_run_mat(Nruns, Nsamples, Nstates, Nstatesout, Ni, Noutputs); | |
82 tmex(jj) | |
83 tmat(jj) | |
84 drawnow | |
85 end | |
86 | |
87 %% | |
88 figure | |
89 plot(Ninputs, tmex, 'r-', Ninputs, tmat, 'b-'); | |
90 legend('mex', 'matlab'); | |
91 ylabel('Run-time [s]'); | |
92 xlabel('Ninputs') | |
93 s = sprintf('Nsamples=%d, Nstates=%d, Noutputs=%d', Nsamples, Nstates, Noutputs); | |
94 title(s) | |
95 | |
96 | |
97 %% Run-time Vs Outputs | |
98 | |
99 Nsamples = 1000; | |
100 Nstatesout = 1; | |
101 Ninputs = 2; | |
102 Noutputs = 1:2:100; | |
103 Nruns = 10; | |
104 Nstates = 10; | |
105 tmex = zeros(length(Noutputs),1); | |
106 tmat = zeros(length(Noutputs),1); | |
107 for jj=1:length(Noutputs) | |
108 | |
109 disp('-----------------') | |
110 No = Noutputs(jj) | |
111 [tmex(jj),y,x] = do_a_run(Nruns, Nsamples, Nstates, Nstatesout, Ninputs, No); | |
112 [tmat(jj),y,x] = do_a_run_mat(Nruns, Nsamples, Nstates, Nstatesout, Ninputs, No); | |
113 tmex(jj) | |
114 tmat(jj) | |
115 drawnow | |
116 end | |
117 | |
118 %% | |
119 figure | |
120 plot(Noutputs, tmex, 'r-', Noutputs, tmat, 'b-'); | |
121 legend('mex', 'matlab'); | |
122 ylabel('Run-time [s]'); | |
123 xlabel('Noutputs') | |
124 s = sprintf('Nsamples=%d, Nstates=%d, Ninputs=%d', Nsamples, Nstates, Ninputs); | |
125 title(s) |