~ubuntu-branches/ubuntu/hoary/scilab/hoary

« back to all changes in this revision

Viewing changes to macros/m2sci/sci_files/sci_PROTO2.g

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2005-01-09 22:58:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050109225821-473xr8vhgugxxx5j
Tags: 3.0-12
changed configure.in to build scilab's own malloc.o, closes: #255869

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function [tree]=sci_MFUN(tree)
 
2
// Prototype for cumsum and cumprod
 
3
// Copyright INRIA
 
4
// M2SCI function
 
5
// Conversion function for Matlab MFUN()
 
6
// Input: tree = Matlab funcall tree
 
7
// Ouput: tree = Scilab equivalent for tree
 
8
// Emulation function: mtlb_MFUN()
 
9
// V.C.
 
10
 
 
11
// B = MFUN(A)
 
12
if rhs==1 then
 
13
  A = getrhs(tree)
 
14
 
 
15
  // Because %b_SFUN and %C_SFUN are not defined
 
16
  A = convert2double(A)
 
17
  tree.rhs=Rhs(A)
 
18
  
 
19
  dim=first_non_singleton(A)
 
20
 
 
21
  tree.lhs(1).dims=A.dims
 
22
  
 
23
  if dim>0 then
 
24
    tree.rhs=Rhs(A,dim)
 
25
  elseif dim==-1 then
 
26
    tree.rhs=Rhs(A,Funcall("firstnonsingleton",1,list(A),list()))
 
27
  end
 
28
  if is_real(A) then
 
29
    tree.lhs(1).type=Type(Double,Real)
 
30
  else
 
31
    tree.lhs(1).type=Type(Double,Unknown)
 
32
  end    
 
33
// B = MFUN(A,dim)
 
34
else
 
35
  [A,dim] = getrhs(tree)
 
36
  
 
37
  // Because %b_SFUN and %C_SFUN are not defined
 
38
  A=convert2double(A)
 
39
  dim=convert2double(dim)
 
40
  tree.rhs=Rhs(A,dim)
 
41
  
 
42
  if typeof(dim)=="cste" then
 
43
    if dim.value>size(A.dims) then
 
44
      if typeof(A)=="funcall" then
 
45
        tree.lhs(1).infer=A.infer
 
46
        A.lhs=tree.lhs
 
47
      elseif typeof(A)=="operation" then
 
48
        tree.lhs(1).infer=A.infer
 
49
        A.out=tree.lhs
 
50
      end
 
51
      tree=A;
 
52
      set_infos("Scilab SFUN() does not work when dim input argument is greater than number of dims of first rhs...",1)
 
53
      return
 
54
    end
 
55
  end
 
56
  
 
57
  tree.name="mtlb_MFUN"
 
58
  tree.lhs(1).dims=A.dims
 
59
  
 
60
  if is_real(A) then
 
61
    tree.lhs(1).type=Type(Double,Real)
 
62
  else
 
63
    tree.lhs(1).type=Type(Double,Unknown)
 
64
  end
 
65
end
 
66
endfunction