PageRenderTime 15ms CodeModel.GetById 1ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/octave/std_containers_runme.m

#
Objective C | 135 lines | 98 code | 37 blank | 0 comment | 31 complexity | 2ec054c9f03e20be45781f1152f13ae6 MD5 | raw file
  1std_containers
  2
  3
  4cube = {{{1, 2}, {3, 4}}, {{5, 6}, {7, 8}}};
  5
  6icube = std_containers.cident(cube);
  7for i=len(cube),
  8  if (cube{i} != icube{i})
  9    error("bad cident")
 10  endif
 11endfor
 12
 13
 14p = {1,2};
 15if (p != std_containers.pident(p))
 16  error("bad pident")
 17endif
 18
 19v = {1,2,3,4,5,6};
 20iv = std_containers.vident(v);
 21for i=0:len(v),
 22  if (v{i} != iv{i})
 23    error("bad vident")
 24  endif
 25endfor
 26
 27
 28iv = std_containers.videntu(v);
 29for i=0:len(v),
 30  if (v{i} != iv{i})
 31    error("bad videntu")
 32  endif
 33endfor
 34
 35
 36vu = std_containers.vector_ui(v);
 37if (vu{2} != std_containers.videntu(vu){2})
 38  error("bad videntu")
 39endif
 40  
 41
 42if (v(0:3)(1) != vu(0:3)(1))
 43  error("bad getslice")
 44endif
 45  
 46
 47m = {[1,2,3],[2,3],[3,4]};
 48im = std_containers.midenti(m);
 49
 50for i=0:len(m),
 51  for j=0:len(m(i)),
 52    if (m(i)(j) != im(i)(j))
 53      error("bad getslice")
 54    endif
 55  endfor
 56endfor
 57
 58m = {[1,0,1],[1,1],[1,1]};
 59im = std_containers.midentb(m);
 60for i=0:len(m),
 61  for j in range(0,len(m[i])):
 62    if (m(i)(j) != im(i)(j))
 63      error("bad getslice")
 64    endif
 65  endfor
 66endfor
 67
 68
 69mi = std_containers.imatrix(m);
 70mc = std_containers.cmatrix(m);
 71if (mi(0)(1) != mc(0)(1))
 72  error("bad matrix")
 73endif
 74
 75
 76map ={};
 77map{'hello'} = 1;
 78map{'hi'} = 2;
 79map{'3'} = 2;
 80
 81imap = std_containers.mapident(map);
 82for k in map,
 83  if (map(k) != imap(k))
 84    error("bad map")
 85  endif
 86endfor
 87
 88
 89mapc ={};
 90c1 = std_containers.C();
 91c2 = std_containers.C();
 92mapc(1) = swig_this(c1);
 93mapc(2) = c2;
 94
 95std_containers.mapidentc(mapc);
 96
 97
 98vi = std_containers.vector_i([2,2,3,4]);
 99
100
101v = [1,2];
102v1 = std_containers.v_inout(vi);
103vi(1), v1(1);
104
105[v1,v2] = std_containers.v_inout2(v1,v2);
106
107a1 = std_containers.A(1);
108a2 = std_containers.A(2);
109
110p1 = {1,a1};
111p2 = {2,a2};
112v = (p1,p2);
113v2= std_containers.pia_vident(v);
114
115v2(0)(1).a;
116v2(1)(1).a;
117
118v3 = std_containers.vector_piA(v2);
119
120v3(0)(1).a;
121v3(1)(1).a;
122
123s = std_containers.set_i();
124s.append(1);
125s.append(2);
126s.append(3);
127j=1;
128for i in s,
129  if (i != j)
130    error
131  endif
132  j = j + 1;
133endfor
134
135