source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/lightspeed/@mutable/subsasgn.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.5 KB
Line 
1function mut = subsasgn(mut,index,v)
2
3% Written by Tom Minka
4% (c) Microsoft Corporation. All rights reserved.
5
6subsasgnJava(mut.obj,index,v,mut.cl);
7
8function subsasgnJava(jv,index,v,cl)
9
10if nargin < 4
11  % class(jv) is expensive, so we do it only once
12  cl = class(jv);
13end
14if strcmp(cl,'java.util.Hashtable')
15  % don't bother checking the type
16  %if strcmp(index(1).type,'.')
17  f = index(1).subs;
18  if length(index) > 1
19    jv = jv.get(f);
20    if isempty(jv)
21      error(sprintf('Reference to non-existent field ''%s''.',f));
22    end
23    % recurse on remaining subscripts
24    subsasgnJava(jv,index(2:end),v);
25  else
26    if ~jv.containsKey(f)
27      % add a new field
28      jv.get('_fields').addElement(f);
29    end
30    jv.put(f,toJava(v));
31  end
32  return
33elseif strcmp(cl,'java.lang.Double[][]') | strcmp(cl,'java.lang.Object[][]')
34  if length(index(1).subs) == 1
35    % convert single index to a full index
36    i = index(1).subs{1};
37    if length(i) > 1
38      error('a single array of indices is not supported');
39    end
40    s = sizeJava(jv);
41    index(1).subs = num2cell(ind2subv(s,i),1);
42  end
43  if strcmp(cl,'java.lang.Object[][]')
44    % cell array
45    if strcmp(index(1).type,'{}')
46      index(1).type = '()';
47    end
48  end
49  % fall through
50elseif strcmp(cl,'java.util.Vector') | strcmp(cl,'java.util.BitSet')
51  % empty array
52  error('Index exceeds matrix dimensions.');
53end
54% use built-in subsasgn
55subsasgn(jv,index,toJava(v));
Note: See TracBrowser for help on using the repository browser.