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

« back to all changes in this revision

Viewing changes to macros/m2sci/percent/%m2sci.sci

  • 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]=%m2sci(tree)
 
2
// Copyright INRIA
 
3
// M2SCI function
 
4
// Conversion function for Matlab multiplication
 
5
// Input: tree = Matlab operation tree
 
6
// Output: tree = Scilab equivalent for tree
 
7
// V.C.
 
8
 
 
9
// Overloading functions in $SCI/macros/mtlb/:
 
10
// - %b_m_s.sci
 
11
// - %s_m_b.sci
 
12
 
 
13
[A,B]=getoperands(tree)
 
14
 
 
15
// Multiplication does not work with Strings in Scilab
 
16
if or(A.vtype==[String,Unknown]) then
 
17
  A=convert2double(A)
 
18
end
 
19
if or(B.vtype==[String,Unknown]) then
 
20
  B=convert2double(B)
 
21
end
 
22
 
 
23
// %b_m_b is not defined in Scilab
 
24
if A.vtype==Boolean & B.vtype==Boolean then
 
25
  B=convert2double(B)
 
26
end
 
27
tree.operands=list(A,B)
 
28
 
 
29
if is_complex(A) & is_complex(B) then
 
30
  prop=Unknown
 
31
elseif A.property==Complex | B.property==Complex then
 
32
  if not_empty(A) & not_empty(B) then
 
33
    prop=Complex
 
34
  elseif is_empty(A) | is_empty(B) then
 
35
    prop=Real
 
36
  else
 
37
    prop=Unknown
 
38
  end
 
39
elseif is_real(A) & is_real(B) then
 
40
  prop=Real
 
41
else
 
42
  prop=Unknown
 
43
end
 
44
 
 
45
tree.out(1).type=Type(Double,prop)
 
46
 
 
47
if is_a_scalar(A) then
 
48
  tree.out(1).dims=B.dims
 
49
elseif is_a_scalar(B) then
 
50
  tree.out(1).dims=A.dims
 
51
elseif not_empty(A) & not_empty(B) then
 
52
  tree.out(1).dims=list(A.dims(1),B.dims(2))
 
53
elseif is_empty(A) | is_empty(B) then
 
54
  tree.out(1).dims=list(0,0)
 
55
elseif not_empty(A) | not_empty(B) then
 
56
  tree.out(1).dims=list(A.dims(1),B.dims(2))
 
57
else
 
58
   tree.out(1).dims=list(Unknown,Unknown)
 
59
end
 
60
endfunction