comparison test/diag-perm.tst @ 20603:f61c67865d9f

Don't return A for inv (A) when A is a singular Diagonal matrix (bug #46103). * dDiagMatrix.cc (inverse), fDiagMatrix.cc (inverse): return octave_Inf for the inverse of a diagonal element whose value is 0. * test/diag-perm.tst: Add tests for new behavior.
author Rik <rik@octave.org>
date Wed, 07 Oct 2015 07:41:44 -0700
parents 4197fc428c7d
children
comparison
equal deleted inserted replaced
20598:ea6a1c00763a 20603:f61c67865d9f
261 %! D = D * I () + D; 261 %! D = D * I () + D;
262 %! assert (full (D + A), D + full (A)); 262 %! assert (full (D + A), D + full (A));
263 %! A = A * I () + A; 263 %! A = A * I () + A;
264 %! A(6, 4) = nan (); 264 %! A(6, 4) = nan ();
265 %! assert (full (D - A), D - full (A)); 265 %! assert (full (D - A), D - full (A));
266
267 ## inverse preserves diagonal structure even for singular matrices (bug #46103)
268 %!test
269 %! x = diag (1:3);
270 %! assert (inv (x), diag ([1 1/2 1/3]));
271 %! x = diag (0:2);
272 %! assert (inv (x), diag ([Inf 1 1/2]));