summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/unit_tests/test000_TrigonIdentity/scilabcode/mainfunction.sci55
-rw-r--r--tests/unit_tests/test001_LinearRegression/scilabcode/mainfunction.sci55
-rw-r--r--tests/unit_tests/test002_Symbols/scilabcode/mainfunction.sci20
-rw-r--r--tests/unit_tests/test038_FindI2O1Float/scilabcode/mainfunction.sci56
-rw-r--r--tests/unit_tests/test061_SumShortTest/scilabcode/mainfunction.sci21
-rw-r--r--tests/unit_tests/test600_SimpleFindDouble/scilabcode/mainfunction.sci16
-rw-r--r--tests/unit_tests/test9999_WorkingDir/scilabcode/mainfunction.sci9
7 files changed, 232 insertions, 0 deletions
diff --git a/tests/unit_tests/test000_TrigonIdentity/scilabcode/mainfunction.sci b/tests/unit_tests/test000_TrigonIdentity/scilabcode/mainfunction.sci
new file mode 100644
index 00000000..a29a1c9e
--- /dev/null
+++ b/tests/unit_tests/test000_TrigonIdentity/scilabcode/mainfunction.sci
@@ -0,0 +1,55 @@
+//SCI2C: DEFAULT_PRECISION= DOUBLE
+
+function mainfunction()
+
+// Knowing that
+// (1) P * (V^gamma) = C
+// Where
+// P = Pressure
+// V = Volume
+// gamma,C = constants depending on the particular gas used.
+// (2) log10(P) = log10(C) - gamma*log10(V)
+// (3) x = log10(V)
+// (4) y = log10(P)
+// than (2) becomes:
+// y = a + b*x;
+// Where
+// a = log10(C)
+// b = -gamma
+// Then thanks to this transformation it is possible to perform
+// a linear regression to estimate gamma and C!
+
+Volume = [54.3 61.8 72.4 88.7 118.6 194.0];
+Pressure = [61.2 49.5 37.6 28.4 19.2 10.1];
+x = log10(Volume);
+y = log10(Pressure);
+
+a = (sum(y)*sum(x.^2)-sum(x)*sum(x.*y))./(length(x)*sum(x.^2)-sum(x).*sum(x));
+b = (length(x)*sum(x.*y)-sum(x)*sum(y))./(length(x)*sum(x.^2)-sum(x).*sum(x));
+
+// Other way to compute a and b
+beq = sum((x-mean(x)).*(y-mean(y)))./sum((x-mean(x)).^2);
+aeq = mean(y)-mean(x)*beq;
+
+C = 10 .^a;
+gamma = -b;
+
+disp('C')
+disp(C)
+
+disp('gamma');
+disp(gamma);
+
+disp('a');
+disp(a)
+disp('aeq');
+disp(aeq)
+
+disp('b');
+disp(b)
+disp('beq');
+disp(beq)
+
+// plot(Volume,Pressure);
+// plot(Volume,(C ./(Volume.^gamma)),'r')
+endfunction
diff --git a/tests/unit_tests/test001_LinearRegression/scilabcode/mainfunction.sci b/tests/unit_tests/test001_LinearRegression/scilabcode/mainfunction.sci
new file mode 100644
index 00000000..a29a1c9e
--- /dev/null
+++ b/tests/unit_tests/test001_LinearRegression/scilabcode/mainfunction.sci
@@ -0,0 +1,55 @@
+//SCI2C: DEFAULT_PRECISION= DOUBLE
+
+function mainfunction()
+
+// Knowing that
+// (1) P * (V^gamma) = C
+// Where
+// P = Pressure
+// V = Volume
+// gamma,C = constants depending on the particular gas used.
+// (2) log10(P) = log10(C) - gamma*log10(V)
+// (3) x = log10(V)
+// (4) y = log10(P)
+// than (2) becomes:
+// y = a + b*x;
+// Where
+// a = log10(C)
+// b = -gamma
+// Then thanks to this transformation it is possible to perform
+// a linear regression to estimate gamma and C!
+
+Volume = [54.3 61.8 72.4 88.7 118.6 194.0];
+Pressure = [61.2 49.5 37.6 28.4 19.2 10.1];
+x = log10(Volume);
+y = log10(Pressure);
+
+a = (sum(y)*sum(x.^2)-sum(x)*sum(x.*y))./(length(x)*sum(x.^2)-sum(x).*sum(x));
+b = (length(x)*sum(x.*y)-sum(x)*sum(y))./(length(x)*sum(x.^2)-sum(x).*sum(x));
+
+// Other way to compute a and b
+beq = sum((x-mean(x)).*(y-mean(y)))./sum((x-mean(x)).^2);
+aeq = mean(y)-mean(x)*beq;
+
+C = 10 .^a;
+gamma = -b;
+
+disp('C')
+disp(C)
+
+disp('gamma');
+disp(gamma);
+
+disp('a');
+disp(a)
+disp('aeq');
+disp(aeq)
+
+disp('b');
+disp(b)
+disp('beq');
+disp(beq)
+
+// plot(Volume,Pressure);
+// plot(Volume,(C ./(Volume.^gamma)),'r')
+endfunction
diff --git a/tests/unit_tests/test002_Symbols/scilabcode/mainfunction.sci b/tests/unit_tests/test002_Symbols/scilabcode/mainfunction.sci
new file mode 100644
index 00000000..bd411ccc
--- /dev/null
+++ b/tests/unit_tests/test002_Symbols/scilabcode/mainfunction.sci
@@ -0,0 +1,20 @@
+function mainfunction()
+
+// ---------------------------------------
+// --- Initialization of the operands. ---
+// ---------------------------------------
+
+v1 = %inf;
+v2 = %nan;
+v3 = %T;
+v4 = %F;
+v5 = %pi;
+
+disp(-v1)
+disp(v1+v2)
+disp(v2)
+disp(v3)
+disp(v4)
+disp(v5)
+
+endfunction
diff --git a/tests/unit_tests/test038_FindI2O1Float/scilabcode/mainfunction.sci b/tests/unit_tests/test038_FindI2O1Float/scilabcode/mainfunction.sci
new file mode 100644
index 00000000..dae2abec
--- /dev/null
+++ b/tests/unit_tests/test038_FindI2O1Float/scilabcode/mainfunction.sci
@@ -0,0 +1,56 @@
+//SCI2C: DEFAULT_PRECISION= FLOAT
+
+function mainfunction()
+
+s1 = -5.4;
+disp('s1');
+disp(s1);
+
+s2 = 2.2;
+disp('s2');
+disp(s2);
+
+A = ((1.2:0.99:4.9)')*(-2.3:1.1:3.9)
+disp('A = ((1.2:0.99:4.9)'')*(-2.3:1.1:3.9)');
+disp(A);
+
+disp('o1 = -s1 + s2;');
+o1 = -s1 + s2;
+disp(o1);
+
+disp('o1 = -3.4 + 4.5;');
+o1 = -3.4 + 4.5;
+disp(o1);
+
+disp('o2 = -3.4 + A;');
+o2 = -3.4 + A;
+disp(o2);
+
+disp('o3 = A + (-3.4);');
+o3 = A + (-3.4);
+disp(o3);
+
+disp('o4 = A + A;');
+o4 = A + A;
+disp(o4);
+
+disp('o5 = +A;');
+o5 = +A;
+disp(o5);
+
+st0 = '#';
+disp('st0')
+disp(st0)
+
+st1 = 'ciao';
+disp('st1')
+disp(st1)
+
+st2 = 'bye';
+disp('st2')
+disp(st2)
+
+st3 = st0+st1+st2;
+disp('st3 = st0+st1+st2;')
+disp(st3)
+endfunction
diff --git a/tests/unit_tests/test061_SumShortTest/scilabcode/mainfunction.sci b/tests/unit_tests/test061_SumShortTest/scilabcode/mainfunction.sci
new file mode 100644
index 00000000..9a123b8c
--- /dev/null
+++ b/tests/unit_tests/test061_SumShortTest/scilabcode/mainfunction.sci
@@ -0,0 +1,21 @@
+//SCI2C: DEFAULT_PRECISION= DOUBLE
+
+function mainfunction()
+
+s1 = (1:4)' * (1:3);
+disp('s1');
+disp(s1);
+
+s2 = sum(s1);
+disp('s2 = sum(s1);');
+disp(s2);
+
+s3 = sum(s1,1);
+disp('s3 = sum(s1,1);');
+disp(s3);
+
+s4 = sum(s1,2);
+disp('s4 = sum(s1,2);');
+disp(s4);
+
+endfunction
diff --git a/tests/unit_tests/test600_SimpleFindDouble/scilabcode/mainfunction.sci b/tests/unit_tests/test600_SimpleFindDouble/scilabcode/mainfunction.sci
new file mode 100644
index 00000000..e32d8d3a
--- /dev/null
+++ b/tests/unit_tests/test600_SimpleFindDouble/scilabcode/mainfunction.sci
@@ -0,0 +1,16 @@
+//SCi0C: DEFAULT_PRECISION= DOUBLE
+
+function mainfunction()
+
+s1 = [1 -3.56 4 -50.20 -7 -8 9 -3 4];
+disp('s1');
+disp(s1);
+
+i0 = find(s1<0.5);
+disp('i0');
+disp(i0);
+
+disp('s1(i0)');
+disp(s1(i0));
+
+endfunction
diff --git a/tests/unit_tests/test9999_WorkingDir/scilabcode/mainfunction.sci b/tests/unit_tests/test9999_WorkingDir/scilabcode/mainfunction.sci
new file mode 100644
index 00000000..ef5d3f58
--- /dev/null
+++ b/tests/unit_tests/test9999_WorkingDir/scilabcode/mainfunction.sci
@@ -0,0 +1,9 @@
+function mainfunction()
+
+// ---------------------------------------
+// --- Initialization of the operands. ---
+// ---------------------------------------
+
+a = 2;
+disp(a)
+endfunction