File: overloading.cat

package info (click to toggle)
scilab 2.6-4
  • links: PTS
  • area: non-free
  • in suites: woody
  • size: 54,632 kB
  • ctags: 40,267
  • sloc: ansic: 267,851; fortran: 166,549; sh: 10,005; makefile: 4,119; tcl: 1,070; cpp: 233; csh: 143; asm: 135; perl: 130; java: 39
file content (115 lines) | stat: -rw-r--r-- 4,690 bytes parent folder | download
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
overloading         Scilab Group         Scilab keyword         overloading
NAME
   overloading - display, functions and operators overloading capabilities
  
DESCRIPTION
   In scilab, variable display, functions and operators may be defined for
  new objects using  functions (scilab coded or primitives).
  
 Display         : The display of new objects defined by tlist structure
                 may be overloaded (the default display is similar to
                 list's one). The overloading function must have no output
                 argument a single input argument. It's name is formed as
                 follow %<tlist_type>_p where %<tlist_type> stands for the
                 first entry of the tlist type component.
                 
 Operators       : Each operator which is not defined for given operands
                 type may be defined. The overloading function must have a
                 single output argument and one or two inputs according to
                 the number of operands. The function name is formed as
                 follow:
                 
                for binary operators:
                 %<first_operand_type>_<op_code>_<second_operand_type>
                 
                for unary operators: %<operand_type>_<op_code>
                 
                extraction and insertion operators which are n-nary
                 operators are described below.
                 
                <operand_type>, <first_operand_type>,
                 <second_operand_type>  are sequence of characters
                 associated with each data type as described in the
                 following table:
                 
                |string        |c           |
                |polynomial    |p           |
                |function      |m           |
                |constant      |s           |
                |list          |l           |
                |tlist         |<tlist_type>|
                |boolean       |b           |
                |sparse        |sp          |
                |boolean sparse|spb         |
                
                 
                <op_code> is a single character associated with each
                 operator as described in the following table:
                 
                | '            |t|
                | +            |a|
                | -            |s|
                | *            |m|
                | /            |r|
                | \            |l|
                | ^            |p|
                | .*           |x|
                | ./           |d|
                | .\           |q|
                | .*.          |k|
                | ./.          |y|
                | .\.          |z|
                | :            |b|
                | *.           |u|
                | /.           |v|
                | \.           |w|
                | [a,b]        |c|
                | [a;b]        |f|
                | () extraction|e|
                | () insertion |i|
                | ==           |o|
                | <>           |n|
                | |            |g|
                | &            |h|
                | .^           |j|
                | ~            |5|
                | .'           |0|
                | <            |1|
                | >            |2|
                | <=           |3|
                | >=           |4|
                
                 
                The overloading function for extraction syntax
                 b=a(i1,...,in) has the following calling sequence:
                 b=%<type_of_a>_e_(i1,...,in,a)  and the syntax
                 [x1,..,xm]=a(i1,...,in) has the following calling
                 sequence:  [x1,..,xm]=%<type_of_a>_e_(i1,...,in,a)
                 
                The overloading function associated to the insertion
                 syntax a(i1,...,in)=b  has the following calling sequence:
                  a=%<type_of_a>_i_<type_of_b>(i1,...,in,b,a). 
                 
 Functions : Some basic primitive function may also be overloaded for new data type. When
                  such a function is undefined for a particular data types the function
                 %<type_of_an_argument>_<function_name> is called. User may
                 add in this called function the definition associated with
                 the input data types.
                 
SEE ALSO
   tlist, disp, symbols
  
EXAMPLES
 //DISPLAY
 deff('[]=%tab_p(l)','disp([['' '';l(3)] [l(2);string(l(4))]])')
 tlist('tab',['a','b'],['x';'y'],rand(2,2))
 
 //OPERATOR
 deff('x=%c_a_s(a,b)','x=a+string(b)')
 's'+1
 
 //FUNCTION
 deff('x=%c_sin(a)','x=''sin(''+a+'')''')
 sin('2*x')