* [#15451](https://bugzilla.scilab.org/15451): The code was not adapted to use `lucene 4.10` in Debian.
* [#15514](https://bugzilla.scilab.org/15514): The `set` documentation page needed to be overhauled.
* [#15517](https://bugzilla.scilab.org/15517): `factorial` could be actually used up to only n=170.
+* [#15260](https://bugzilla.scilab.org/15260): `sci2exp` was no longer able to convert non-scalar structures.
* [#15522](https://bugzilla.scilab.org/15522): `unique` was not able to consider all Nan values as the same value. A `uniqueNan` option now allows it.
* [#15523](https://bugzilla.scilab.org/15523): `%ODEOPTIONS(1)=2` didn't work with solvers 'rk' and 'rkf'
* [#15534](https://bugzilla.scilab.org/15534): Booleans and encoded integers could not be concatenated together.
* [#16104](https://bugzilla.scilab.org/16104): `assert_checkequal` did not support properly or at all Nan and void in lists, Nan in sparse, implicit lists, macros, libraries, built-in functions, graphical handles. For input arrays or lists of matching typeof and sizes, the failure message did not display neither the index nor the values of the first mismatching elements.
* [#16111](https://bugzilla.scilab.org/16111): `isglobal` was not supporting non-scalar array of strings as input.
* [#16118](https://bugzilla.scilab.org/16118): `%s <> (1+%s)` returned %F.
+* [#16124](https://bugzilla.scilab.org/16124): `sci2exp({})` result could not be executed.
* [#16129](https://bugzilla.scilab.org/16129): `uiDumpTree()` interpreted "\n" "\r" "\t" sequences in contents as special ones.
* [#16135](https://bugzilla.scilab.org/16135): base2dec did not detect invalid numbers.
* [#16137](https://bugzilla.scilab.org/16137): After running `playsnd` on Windows for a long sound, it was not possible to stop it.
case 15 then
t = list2exp(a, lmax);
case 16 then
- t = tlist2exp(a, lmax);
+ if typeof(a)=="rational"
+ t = rlist2exp(a, lmax);
+ else
+ t = tlist2exp(a, lmax);
+ end
case 17 then // cells, struct, mlists
- if typeof(a)=="st" & length(a)==1
- t = scalarstruct2exp(a, lmax);
+ if typeof(a)=="st"
+ t = struct2exp(a, lmax);
else
t = mlist2exp(a, lmax);
end
end
endfunction
+function t = list2exp(l, lmax)
+ t = glist2exp("list", l, lmax)
+endfunction
+function t = mlist2exp(l, lmax)
+ t = glist2exp("mlist", l, lmax)
+endfunction
+function t = tlist2exp(l, lmax)
+ t = glist2exp("tlist", l, lmax)
+endfunction
+function t = rlist2exp(l, lmax)
+ t = sci2expAdd("rlist(", sci2exp(l.num, lmax))
+ t($) = t($)+","
+ t = sci2expAdd(t, sci2exp(l.den, lmax))
+ t($) = t($)+")"
+endfunction
+
+function r = sci2expAdd(head,t,lmax)
+ h = head($)
+ if ~lmax | length(h+t(1))<=lmax then
+ head($) = h + t(1)
+ r = [head ; t(2:$)]
+ else
+ r = [head + "."+"." ; t]
+ end
+endfunction
+
function t = glist2exp(listType, l, lmax)
[lhs,rhs] = argn(0)
if rhs<3 then lmax = 0, end
dots = "."+".";
isCell = typeof(l)=="ce";
if isCell then
+ if length(l)==0
+ t = "{}"
+ return
+ end
s = size(l);
s = strcat(msprintf("%d\n",s(:)),","); // Literal list of sizes
t = "makecell(";
for k = 1:L
sep = ",", if k==1 then sep = "", end
clear lk
- if listType ~= "mlist"
+ if isCell | listType ~= "mlist"
lk = l(k)
else
try
catch
end
end
-
- if ~isdef("lk","local")
- t1 = ""
+ if ~isdef("lk","local") | type(lk)==0
+ t1 = "" // undefined element as in list(2,,5)
else
t1 = sci2exp(lk, lmax)
end
- if size(t1,"*")==1&(lmax==0|max(length(t1))+length(t($))<lmax) then
+ if size(t1,"*")==1 & (lmax==0|max(length(t1))+length(t($))<lmax) then
t($) = t($)+sep+t1
else
t($) = t($)+sep+dots
t($) = t($)+")"
endfunction
-function t = list2exp(l, lmax)
- t = glist2exp("list", l, lmax)
-endfunction
-function t = tlist2exp(l, lmax)
- t = glist2exp("tlist", l, lmax)
-endfunction
-function t = mlist2exp(l, lmax)
- t = glist2exp("mlist", l, lmax)
-endfunction
-
-function t = scalarstruct2exp(l, lmax)
+function t = struct2exp(l, lmax)
if argn(2)<2 then lmax = 0, end
dots = "."+".";
+ stSize = size(l);
+ stIsScalar = isscalar(l);
t = "struct(";
+ if ~stIsScalar & (stSize(1)>1 | length(stSize)>2)
+ t = "matrix(" + t;
+ end
fields = fieldnames(l);
n = size(fields,"*");
for i = 1:n
- if ~lmax | lmax>(12+length(fields(i)))
+ if ~lmax | lmax>(length(t($))+length(fields(i))+3)
t($) = t($) + """"+fields(i)+""",";
else
- t($) = t($) + " " + dots;
+ t($) = t($) + "" + dots;
t = [t; """"+fields(i)+""","];
end
clear lk
lk = l(fields(i));
- if ~isdef("lk","local")
+ if ~isdef("lk","local") | type(lk)==0
t1 = "";
else
t1 = sci2exp(lk, lmax)
+ if ~stIsScalar // "list(..)" => "{..}"
+ if size(t1,1)==1
+ t1 = "{" + part(t1,6:$-1) + "}"
+ else
+ t1 = ["{" + part(t1(1),6:$)
+ t1(2:$-1)
+ part(t1($),1:$-1) + "}"
+ ]
+ end
+ end
end
if i<n then
tmp = ", ";
if size(t1,"*")==1&(lmax==0|max(length(t1))+length(t($))<lmax) then
t($) = t($) + t1 + tmp;
else
- t($) = t($) + " ..";
+ t($) = t($) + "..";
t = [t; t1 + tmp]
end
end
t($) = t($)+")"
+ if ~stIsScalar & (stSize(1)>1 | length(stSize)>2) // matrix(.., sizes)
+ t($) = t($) + ",[" + strcat(msprintf("%d\n",stSize(:))," ") + "])"
+ end
endfunction
function t=log2exp(a,lmax)
// =============================================================================
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) 2017 - Samuel GOUGEON
+// Copyright (C) 2017, 2019 - Samuel GOUGEON
//
// This file is distributed under the same license as the Scilab package.
// =============================================================================
rc = evstr(tc);
assert_checkequal(rc,c);
-// Scalar structure:
+// Structures:
+// ----------
+// Scalar:
s = struct("r",1.234-5.6*%i,"b",%f,"t","Hello","i",int8([123 -76]),"l",list(4,,%i));
ss = sci2exp(s);
ssref = "struct(""r"",1.234-%i*5.6, ""b"",%f, ""t"",""Hello"", ""i"",int8([123,-76]), ""l"",list(4,,%i))";
assert_checkequal(ss, ssref);
assert_checkequal(evstr(ss), s);
-
-// Array of structures
-// =======================================================================
-// There is no longer any way to generate nand initialize from scratch any
-// non-scalar array of structures.
-// =======================================================================
-// This part shall be rewritten when struct(dims,field1,listOfValues1, ..)
-// will have been implemented (= bug http://bugzilla.scilab.org/15264 fixed)
-clear s
-s.r = 1.2345;
-s(1,2).r = %i;
-s(2,2).r = 1-%i;
-s(2,1).r = 2.345;
-s.t = "A";
-s(1,2).t = "C";
-s(2,2).t = "D";
-s(2,1).t = "B";
-tmpref = mlist(["st","dims","r","t"],int32([2,2]),list(1.2345,2.345,%i,1-%i),list("A","B","C","D"));
-ssref = "mlist([""st"",""dims"",""r"",""t""],int32([2,2]),list(1.2345,2.345,%i,1-%i),list(""A"",""B"",""C"",""D""))";
+// Array:
+s = struct("à", {3.1415,%t,"abc";%z,1-1/%s,%i}, "é",{2.7183,3,"test"; %z^2,list(,7),-%i});
+ssref = "matrix(struct(""à"",{3.1415,%z,%t,rlist(-1+%s,%s),""abc"",%i}, ""é"",{2.7183,%z^2,3,list(,7),""test"",-%i}),[2 3])";
assert_checkequal(sci2exp(s), ssref);
-assert_checkequal(evstr(sci2exp(s)), tmpref);
+assert_checkequal(evstr(ssref), s);
--- /dev/null
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2019 - Samuel GOUGEON
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+// <-- NO CHECK REF -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/16124
+//
+// <-- Short Description -->
+// sci2exp({}) result could not be executed
+
+assert_checkequal(sci2exp({}), "{}");