summaryrefslogtreecommitdiff
path: root/src/Scilab2C/FunctionTableManagement/Example.sce
blob: dde9e9c20a356f478b8e6241c72fbb4744fe2dcf (plain)
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
// in the following you can find some examples that help you to use the biuild in functions.

// the first operation is to find the path where the files are stored
// cd <path>   

   clear;
   clc;
   
   getf("main.sci");
   [SCI2CLib, USER2CLib] = main();
   
//
// I add the same function with two inputs
//
// Branch=FunctionStructure; 
// TreeBase=USER2CLib;
//
   getf("SearchFunctionName.sci");
   getf("AddBranch.sci");

   FunctionStructure = "fn.S.R.D.S.R.D.CINFO";
      
   clear CINFO;
   
   CINFO.CPROT = "y=SRDSRDfnSRD"; 
   CINFO.SIZE = "S";
   CINFO.TYPE = "R";
   CINFO.PREC = "D";

   [Cprototype, FlagFind] = SearchFunctionName(FunctionStructure, "SCI2CLib");
   
   if FlagFind==%F then
      [Cprototype, FlagFind] = SearchFunctionName(FunctionStructure, "USER2CLib");
      
      if FlagFind==%F then
	      USER2CLib = AddBranch( USER2CLib, FunctionStructure, CINFO );
      end
      
   end
   
   eval("USER2CLib." + FunctionStructure) 

//
// now I change one output type
//
// Branch=FunctionStructure; 
// TREE="USER2CLib";
//
   getf("SearchFunctionName.sci");
   getf("AddBranch.sci");

   FunctionStructure = "fn.S.R.D.CINFO";

   clear CINFO;      
   
   CINFO.CPROT = "y=SRDfnSRD"; 
   CINFO.SIZE = "S";
   CINFO.TYPE = "R";
   CINFO.PREC = "D";

   
   [Cprototype, FlagFind] = SearchFunctionName(FunctionStructure, "SCI2CLib");
   
   if FlagFind==%F then
      [Cprototype, FlagFind] = SearchFunctionName(FunctionStructure, "USER2CLib");
      
      if FlagFind==%F then
	      USER2CLib = AddBranch( USER2CLib, FunctionStructure, CINFO );
      end
      
   end
   
   eval("USER2CLib." + FunctionStructure) 
   
//
// I add the same function with two outputs:
//              1. the first output is S.R.D
//              2. the second output is M.R.D.
//
// Branch=FunctionStructure; 
// TREE="USER2CLib";
//
   FunctionStructure = "fn.S.R.D.CINFO(2)";
   
   clear CINFO;
   
   S(1) = "S";
   R(1) = "R";
   D(1) = "D";

   S(2) = "M";
   R(2) = "R";
   D(2) = "D";
   
   CINFO.CPROT = "y=SRDfnSRDSRD"; 
   CINFO.SIZE = S;
   CINFO.TYPE = R;
   CINFO.PREC = D;

   
   [Cprototype, FlagFind] = SearchFunctionName(FunctionStructure, "SCI2CLib");
   
   if FlagFind==%F then
      [Cprototype, FlagFind] = SearchFunctionName(FunctionStructure, "USER2CLib");
      
      if FlagFind==%F then
	      USER2CLib = AddBranch( USER2CLib, FunctionStructure, CINFO );
      end
      
   end
   
   eval("USER2CLib." + FunctionStructure)   

//
//   fn.S.R.F.CINFO
//
// where 
//
//   CINFO.
//      CPRO = "y=SRFfnSRF(x)"
//      SIZE = "S"
//      TYPE = "R"
//      PREC = "F"
   
// Branch=FunctionStructure; 
// TREE="USER2CLib";

   getf("SearchFunctionName.sci");
   getf("AddBranch.sci");
   
   FunctionStructure = "fn.S.R.F.CINFO";
      
   CINFO(1).CPROT = "y=SRFfnSRF"; 
   CINFO(1).SIZE = "S";
   CINFO(1).TYPE = "R";
   CINFO(1).PREC = "F";
   
   [Cprototype, FlagFind] = SearchFunctionName(FunctionStructure, "SCI2CLib");
   
   if FlagFind==%F then
      [Cprototype, FlagFind] = SearchFunctionName(FunctionStructure, "USER2CLib");
      
      if FlagFind==%F then
      
	      USER2CLib = AddBranch(USER2CLib, FunctionStructure, CINFO );
	      
      end
      
   end
   
   eval("USER2CLib." + FunctionStructure)