source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/lightspeed/@mutable/subsref.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

  • Property svn:executable set to *
File size: 1.6 KB
Line 
1function v = subsref(mut,index)
2
3% Written by Tom Minka
4% (c) Microsoft Corporation. All rights reserved.
5
6v = subsrefJava(mut.obj,index,mut.cl);
7
8function v = subsrefJava(jv,index,cl)
9
10if nargin < 3
11  % class(jv) is expensive, so we do it only once
12  cl = class(jv);
13end
14wantcell = 0;
15if strcmp(cl,'java.util.Hashtable')
16  % don't bother checking the type
17  %if strcmp(index(1).type,'.')
18  f = index(1).subs;
19  v = jv.get(f);
20  if isempty(v)
21    error(sprintf('Reference to non-existent field ''%s''.',f));
22  end
23elseif strcmp(cl,'java.lang.Double[][]') | strcmp(cl,'java.lang.Object[][]')
24  if length(index(1).subs) == 1
25    % convert single index to a full index
26    i = index(1).subs{1};
27    if length(i) > 1
28      error('a single array of indices is not supported');
29    end
30    s = sizeJava(jv);
31    index(1).subs = num2cell(ind2subv(s,i),1);
32  end
33  if strcmp(cl,'java.lang.Object[][]')
34    % cell array
35    if strcmp(index(1).type,'{}')
36      index(1).type = '()';
37    else
38      % type is '()' for a cell array
39      wantcell = 1;
40      % if the subscript has more than one element, the result will already
41      % be a cell array
42      for i = index(1).subs
43        if length(i{1}) > 1
44          wantcell = 0;
45          break
46        end
47      end
48    end
49  end
50  v = subsref(jv,index(1));
51elseif strcmp(cl,'java.util.Vector') | strcmp(cl,'java.util.BitSet')
52  % empty array
53  error('Index exceeds matrix dimensions.');
54else
55  % use built-in subsref
56  v = subsref(jv,index(1));
57end
58if length(index) > 1
59  % recurse on remaining subscripts
60  v = subsrefJava(v,index(2:end));
61else
62  v = fromJava(v);
63  if wantcell
64    v = {v};
65  end
66end
67
Note: See TracBrowser for help on using the repository browser.