File: _checkTypeAndDimensions.sci

package info (click to toggle)
scilab-plotlib 0.41-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 3,196 kB
  • sloc: xml: 3,308; makefile: 15
file content (55 lines) | stat: -rw-r--r-- 1,242 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
function [_out,_errorText]=_checkTypeAndDimensions(_arg,_i,_string,_type,_dims)
  
  _out=%t;
  _errorText=[];
   if and(type(_arg)~=_type)
    _out=%f;
    _typeString(13)="function";
    _typeString(1)="matrix";    
    _errorText=sprintf("%s : argument %d must be a ",_string,_i);
    for i=1:length(_type)
      if i>1 
        _errorText=_errorText+" or ";
      end
      _errorText=_errorText+_typeString(_type(i));
    end
    if argn(1)==2
      return
    end
    _error(_errorText);
   end
  
  if argn(2)==4
    return
  end
    _size=size(_arg);
    
    _check=%f;
    for i=1:size(_dims,1)
      if and(_dims(i,:)==-1)
        _result=%t;
      elseif or(_dims(i,:)==-1)
        _result=or(size(_arg)==_dims(i,:));
      else
        _result=and(size(_arg)==_dims(i,:));
      end
      _check=_check | _result;
    end
    
    if ~_check
       _out=%f;
      _errorText=sprintf("%s : argument %d must be a matrix of size ",_string,_i);
      for i=1:size(_dims,1)
        if i>1 
          _errorText=_errorText+" or ";
        end
        _errorText=_errorText+sprintf("%s x %s",strsubst(string(_dims(i,:)),'-1','n') );
      end
      if argn(1)==2
        return
      end
      _error(_errorText);
    end

endfunction