1
function [tree]=sci_diag(tree)
4
// Conversion function for Matlab diag()
5
// Input: tree = Matlab funcall tree
6
// Ouput: tree = Scilab equivalent for tree
7
// Emulation function: mtlb_diag()
13
// In Scilab k must be a real or complex matrix
17
// Compute dims to for inference
18
if typeof(k)=="cste" then
19
if A.dims(1)==1 then // diag of a row vector
22
elseif A.dims(2)==1 then // diag of a column vector
33
tree.lhs(1).dims=list(m,n)
35
if or(A.vtype==[String,Unknown]) then
37
tree.lhs(1).type=A.type
39
if A.vtype==Boolean then
40
tree.rhs=Rhs(Funcall("bool2s",1,list(A),list()),k)
41
tree.lhs(1).type=Type(Boolean,Real)
43
tree.lhs(1).type=A.type
50
// Compute dims to for inference
51
if A.dims(1)==1 then // diag of a row vector
54
elseif A.dims(2)==1 then // diag of a column vector
57
elseif not_a_vector(A) then
68
tree.lhs(1).dims=list(m,n)
70
if or(A.vtype==[String,Unknown]) then
72
tree.lhs(1).type=A.type
74
if A.vtype==Boolean then
75
tree.rhs=Rhs(Funcall("bool2s",1,list(A),list()))
76
tree.lhs(1).type=Type(Boolean,Real)
78
tree.lhs(1).type=A.type