File: sci_false.sci

package info (click to toggle)
scilab 4.0-12
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 100,640 kB
  • ctags: 57,333
  • sloc: ansic: 377,889; fortran: 242,862; xml: 179,819; tcl: 42,062; sh: 10,593; ml: 9,441; makefile: 4,377; cpp: 1,354; java: 621; csh: 260; yacc: 247; perl: 130; lex: 126; asm: 72; lisp: 30
file content (182 lines) | stat: -rw-r--r-- 4,529 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
function [tree]=sci_false(tree)
// File generated from sci_PROTO3.g: PLEASE DO NOT EDIT !
// Copyright INRIA
// M2SCI function
// Conversion function for Matlab false()
// Input: tree = Matlab funcall tree
// Ouput: tree = Scilab equivalent for tree
// Emulation function: mtlb_false()
// V.C.

// Used for false and true
name_sav=tree.name

if rhs==-1 then
  if tree.name=="ones"|tree.name=="eye" then
    tree=Cste(":")
  elseif tree.name=="zeros" then
    tree=Cste(0)
  elseif tree.name=="rand" then
    // Nothing changed
  elseif tree.name=="randn" then
    tree.rhs=Rhs(1,1,"normal")
    tree.lhs(1).dims=list(1,1)
    tree.lhs(1).type=Type(Double,Real)
  elseif tree.name=="false" then
    tree=Cste(%F)
  elseif tree.name=="true" then
    tree=Cste(%T)
  end
  return
end

if rhs==0 then
  if tree.name=="ones"|tree.name=="eye" then
    tree=Cste(1)
  elseif tree.name=="zeros" then
    tree=Cste(0)
  elseif tree.name=="rand" then
    // Nothing changed
  elseif tree.name=="randn" then
    tree.rhs=Rhs(1,1,"normal")
    tree.lhs(1).dims=list(1,1)
    tree.lhs(1).type=Type(Double,Real)
  elseif tree.name=="false" then
    tree=Cste(%F)
  elseif tree.name=="true" then
    tree=Cste(%T)
  end
  return
end

// Special cases for rand and randn
if tree.name=="randn" |tree.name=="rand" then
  if tree.rhs(1).vtype==String then // State
    if rhs==1 then // Get the state
      if tree.name=="rand" then
	onescall=Funcall("ones",1,Rhs(35,1),list())
	randcall=Funcall("rand",1,Rhs("seed"),list())
	tree=Operation("*",list(onescall,randcall),tree.lhs)
	tree.out(1).dims=list(35,1)
	tree.out(1).type=Type(Double,Real)
      else
	onescall=Funcall("ones",1,Rhs(2,1),list())
	randcall=Funcall("rand",1,Rhs("seed"),list())
	tree=Operation("*",list(onescall,randcall),tree.lhs)
	tree.out(1).dims=list(2,1)
	tree.out(1).type=Type(Double,Real)
      end
    else // Set the state
      tree=Funcall("rand",1,Rhs("seed",tree.rhs(2)),tree.lhs)
      tree.lhs(1).dims=list(0,0)
      tree.lhs(1).type=Type(Unknown,Unknown)
    end
    return
  end
end

opt=list(),if tree.name=="randn" then opt=Cste("normal"),end
  
// false(n)
if rhs==1 then
  n = getrhs(tree)
  n=convert2double(n)
  if is_complex(n) then
    n=Funcall("real",1,list(n),list(Variable("",n.infer)))
  elseif ~is_real(n) then
    newn=Funcall("real",1,list(n),list(Variable("",n.infer)))
    repl_poss(newn,n,n,"is Real");
    n=newn
  end
  if is_a_scalar(n) then 
    if typeof(n)=="cste" then
      dim=n.value
    else
      dim=Unknown
    end
    
    tree=Funcall("zeros",1,Rhs(n,n,opt),tree.lhs)
    tree.lhs(1).dims=list(dim,dim)
    tree.lhs(1).type=Type(Double,Real)
  // false([n1,n2,...])
  elseif not_a_scalar(n)
    tmp=n
    if typeof(n)<>"variable" then
      tmp=gettempvar()
      insert(Equal(list(tmp),n))
    end
    newrhs=list()
    for k=1:size(n.dims)
      newrhs(k)=Operation("ext",list(tmp,Cste(k)),list())
    end
    if opt<>list() then
      newrhs($+1)=opt
    end
    tree=Funcall("zeros",1,newrhs,tree.lhs)

    // All dimensions are unknown because we can not compute them here...
    tree.lhs(1).dims=list()
    if opt<>list() then
      for k=1:size(tree.rhs)-1
	tree.lhs(1).dims(k)=Unknown
      end
    else
      for k=1:size(tree.rhs)
	tree.lhs(1).dims(k)=Unknown
      end
    end
    tree.lhs(1).type=Type(Double,Real)
  // false(n) or false([n1,n2,...]) ?
  else 
    tree.name="mtlb_false"

    tree.lhs(1).dims=list(Unknown,Unknown)
    tree.lhs(1).type=Type(Double,Real)
  end
  
// false(n1,n2,..)
else
  for k=1:size(tree.rhs)
    tree.rhs(k)=convert2double(tree.rhs(k))
    if is_complex(tree.rhs(k)) then
      tree.rhs(k)=Funcall("real",1,list(tree.rhs(k)),list()) 
    elseif ~is_real(tree.rhs(k)) then
      newn=Funcall("real",1,list(tree.rhs(k)),list())
      repl_poss(newn,tree.rhs(k),tree.rhs(k),"is Real");
      tree.rhs(k)=newn
    end
  end
  if opt<>list() then
    tree.rhs($+1)=opt
  end
  tree.name="zeros"
  // If one input is a Cste, we can infer corresponding dimension...
  tree.lhs(1).dims=list()
  for k=1:size(tree.rhs)
    if typeof(tree.rhs(k))=="cste" then
      if tree.rhs(k).value<>"normal" then
	tree.lhs(1).dims($+1)=tree.rhs(k).value
      end
    else
      tree.lhs(1).dims($+1)=Unknown
    end
  end
  tree.lhs(1).type=Type(Double,Real)
end

if or(name_sav==["false","true"]) then
  if name_sav=="false" then
    tree.name="zeros"
  else
    tree.name="ones"
  end
  tree.lhs(1).type=Type(Boolean,Real)
  tree=Operation("==",list(tree,Cste(1)),tree.lhs)
end
endfunction