diff --git a/inst/@sym/private/numeric_array_to_sym.m b/inst/@sym/private/numeric_array_to_sym.m
index cf1b9490..455fcafc 100644
--- a/inst/@sym/private/numeric_array_to_sym.m
+++ b/inst/@sym/private/numeric_array_to_sym.m
@@ -1,4 +1,4 @@
-%% Copyright (C) 2014, 2015, 2019 Colin B. Macdonald
+%% Copyright (C) 2014, 2015, 2019, 2023 Colin B. Macdonald
%%
%% This file is part of OctSymPy.
%%
@@ -16,9 +16,15 @@
%% License along with this software; see the file COPYING.
%% If not, see .
-function z = numeric_array_to_sym(A)
+function z = numeric_array_to_sym(A, ratflag)
%private helper for sym ctor
-% convert an array to syms, currently on 1D, 2D.
+% convert an array to syms, currently only 1D, 2D.
+
+ if nargin < 2
+ ratwarn = true;
+ else
+ ratwarn = false;
+ end
[n, m] = size(A);
@@ -33,7 +39,11 @@
% we want all sym creation to go through the ctor.
Ac{i} = cell(m,1);
for j=1:m
- Ac{i}{j} = sym(A(i,j));
+ if ratwarn
+ Ac{i}{j} = sym (A(i, j));
+ else
+ Ac{i}{j} = sym (A(i, j), ratflag);
+ end
end
end
diff --git a/inst/@sym/sym.m b/inst/@sym/sym.m
index 90a4a395..d03fec3a 100644
--- a/inst/@sym/sym.m
+++ b/inst/@sym/sym.m
@@ -1,4 +1,4 @@
-%% Copyright (C) 2014-2019, 2022 Colin B. Macdonald
+%% Copyright (C) 2014-2019, 2022-2023 Colin B. Macdonald
%% Copyright (C) 2016 Lagu
%%
%% This file is part of OctSymPy.
@@ -356,7 +356,11 @@
end
if (~isscalar (x) && isnumber) % Handle octave numeric matrix
- s = numeric_array_to_sym (x);
+ if ratwarn
+ s = numeric_array_to_sym (x);
+ else
+ s = numeric_array_to_sym (x, ratflag);
+ end
return
elseif (isa (x, 'double')) % Handle double/complex
@@ -840,6 +844,18 @@
%! x = sym(a, 'r');
%! assert (isequal (x, sym(1)/10))
+%!test
+%! % sym(double) array with 'r': no warning
+%! a = [0.1 0.2];
+%! x = sym(a, 'r');
+%! assert (isequal (x, [sym(a(1), 'r') sym(a(2), 'r')]))
+
+%!test
+%! % sym(double) array with 'f': no warning
+%! a = [0.1 0.2];
+%! x = sym(a, 'f');
+%! assert (isequal (x, [sym(a(1), 'f') sym(a(2), 'f')]))
+
%!test
%! % sym(double, 'f')
%! a = 0.1;
@@ -916,6 +932,7 @@
%!warning sym (10.33);
%!warning sym (-5.23);
%!warning sym (sqrt (1.4142135623731));
+%!warning sym ([1.2 1.3]);
%!error
%! x = sym ('x', 'positive2');