* [Bug #14648](http://bugzilla.scilab.org/show_bug.cgi?id=14648) fixed - `isinf` returned `%F` for complex numbers with both real and imag infinite parts.
* [Bug #14662](http://bugzilla.scilab.org/show_bug.cgi?id=14662) fixed - Matrix of strings concatenation with single quote led to a parser error.
* [Bug #14681](http://bugzilla.scilab.org/show_bug.cgi?id=14681) fixed - Short-circuited AND operation was not possible with double matrices in if and while clauses
+* [Bug #14649](http://bugzilla.scilab.org/show_bug.cgi?id=14649) fixed - isnan(complex(%inf, %inf)) returned %F while the phase is NaN.
### In 6.0.0 beta-2 and earlier:
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) INRIA
// Copyright (C) DIGITEO - 2011 - Allan CORNET
+// Copyright (C) 2016 - Samuel GOUGEON
//
// Copyright (C) 2012 - 2016 - Scilab Enterprises
//
function r = isnan(x)
rhs = argn(2);
if rhs <> 1 then
- error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"),"isnan", 1));
+ msg = gettext("%s: Wrong number of input argument(s): %d expected.\n")
+ error(msprintf(msg, "isnan", 1));
end
if x == [] then
r = [];
else
- r =~ (x == x);
+ if or(type(x)==[1 5]) // for dense and sparse decimal encodings
+ if isreal(x)
+ r = (x ~= x);
+ else
+ rp = real(x)
+ ip = imag(x)
+ r = (x~=x | (abs(real(x))==%inf & abs(imag(x))==%inf) )
+ end
+ else
+ r = ~(x == x);
+ // the case of polynomials will be better managed apart,
+ // after merging this first fix for complex numbers
+ end
end
endfunction
--- /dev/null
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2016 - Samuel GOUGEON
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 14649 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=14649
+//
+// <-- Short Description -->
+// isnan(complex(%inf, %inf)) returned %F
+C = complex([-%inf -%inf %inf %inf], [-%inf %inf -%inf %inf]);
+res = [%t %t %t %t];
+assert_checkequal(isnan(C), res);
+assert_checkequal(isnan(sparse(C)), sparse(res));
--- /dev/null
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2016 - Samuel GOUGEON
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 14649 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=14649
+//
+// <-- Short Description -->
+// isnan(complex(%inf, %inf)) returned %F
+
+C = complex([-%inf -%inf %inf %inf], [-%inf %inf -%inf %inf]);
+res = [%t %t %t %t];
+assert_checkequal(isnan(C), res);
+assert_checkequal(isnan(sparse(C)), sparse(res));
--- /dev/null
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2016 - Samuel GOUGEON
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// unit tests for isnan() function
+// ===============================
+assert_checkequal(isnan([]), []);
+// With decimal real numbers
+// -------------------------
+assert_checktrue(isnan(%nan));
+M = [%pi %inf -1 %nan 3 -%nan -%inf];
+R = [%f %f %f %t %f %t %f];
+assert_checkequal(isnan(M), R);
+assert_checkequal(isnan(M'),R');
+M = sparse(M);
+R = sparse(R);
+assert_checkequal(isnan(M), R);
+assert_checkequal(isnan(M'),R');
+M = [%pi %inf -1 %nan
+ 3 -%nan 0 -%inf];
+R = [%f %f %f %t ; %f %t %f %f];
+assert_checkequal(isnan(M),R);
+M = sparse(M);
+R = sparse(R);
+assert_checkequal(isnan(M), R);
+clear M R
+M(:,:,1) = [%pi %inf ; -1 %nan];
+M(:,:,2) = [ 3 -%nan ; 0 -%inf];
+R(:,:,1) = [%f %f ; %f %t ];
+R(:,:,2) = [%f %t ; %f %f ];
+assert_checkequal(isnan(M),R);
+// no sparse hypermatrix
+// With complex numbers
+// --------------------
+G = [ -%inf -10 0 %nan 10 %inf];
+[R,I] = meshgrid(G,G);
+C = complex(R,I);
+res = [
+ 1. 0. 0. 1. 0. 1.
+ 0. 0. 0. 1. 0. 0.
+ 0. 0. 0. 1. 0. 0.
+ 1. 1. 1. 1. 1. 1.
+ 0. 0. 0. 1. 0. 0.
+ 1. 0. 0. 1. 0. 1.
+ ]==1;
+assert_checkequal(isnan(C), res);
+C = sparse(C);
+res = sparse(res);
+assert_checkequal(isnan(C), res);
--- /dev/null
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2016 - Samuel GOUGEON
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// unit tests for isnan() function
+// ===============================
+
+assert_checkequal(isnan([]), []);
+
+// With decimal real numbers
+// -------------------------
+assert_checktrue(isnan(%nan));
+
+M = [%pi %inf -1 %nan 3 -%nan -%inf];
+R = [%f %f %f %t %f %t %f];
+assert_checkequal(isnan(M), R);
+assert_checkequal(isnan(M'),R');
+M = sparse(M);
+R = sparse(R);
+assert_checkequal(isnan(M), R);
+assert_checkequal(isnan(M'),R');
+
+M = [%pi %inf -1 %nan
+ 3 -%nan 0 -%inf];
+R = [%f %f %f %t ; %f %t %f %f];
+assert_checkequal(isnan(M),R);
+M = sparse(M);
+R = sparse(R);
+assert_checkequal(isnan(M), R);
+
+clear M R
+M(:,:,1) = [%pi %inf ; -1 %nan];
+M(:,:,2) = [ 3 -%nan ; 0 -%inf];
+R(:,:,1) = [%f %f ; %f %t ];
+R(:,:,2) = [%f %t ; %f %f ];
+assert_checkequal(isnan(M),R);
+// no sparse hypermatrix
+
+// With complex numbers
+// --------------------
+G = [ -%inf -10 0 %nan 10 %inf];
+[R,I] = meshgrid(G,G);
+C = complex(R,I);
+res = [
+ 1. 0. 0. 1. 0. 1.
+ 0. 0. 0. 1. 0. 0.
+ 0. 0. 0. 1. 0. 0.
+ 1. 1. 1. 1. 1. 1.
+ 0. 0. 0. 1. 0. 0.
+ 1. 0. 0. 1. 0. 1.
+ ]==1;
+assert_checkequal(isnan(C), res);
+
+C = sparse(C);
+res = sparse(res);
+assert_checkequal(isnan(C), res);
+