changeset 23293:ed3d5186ffcf

maint: merge stable to default.
author Rik <rik@octave.org>
date Thu, 16 Mar 2017 09:27:28 -0700
parents 7a06a1a5a12b (current diff) 6cbf5c2d4d55 (diff)
children d5f490eebb47
files libinterp/corefcn/eig.cc scripts/plot/appearance/datetick.m scripts/time/datenum.m
diffstat 3 files changed, 22 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/eig.cc	Thu Mar 16 09:02:21 2017 -0700
+++ b/libinterp/corefcn/eig.cc	Thu Mar 16 09:27:28 2017 -0700
@@ -45,8 +45,9 @@
 @deftypefnx {} {[@dots{}] =} eig (@var{A}, @var{balanceOption})
 @deftypefnx {} {[@dots{}] =} eig (@var{A}, @var{B}, @var{algorithm})
 @deftypefnx {} {[@dots{}] =} eig (@dots{}, @var{eigvalOption})
-Compute the right eigenvalues(V) and optionally the eigenvectors(lambda) and
-the left eigenvalues(W) of a matrix or a pair of matrices.
+Compute the eigenvalues (@var{lambda}) and optionally the right eigenvectors
+(@var{V}) and the left eigenvectors (@var{W}) of a matrix or a pair of
+matrices.
 
 The flag @var{balanceOption} can be one of:
 
--- a/scripts/plot/appearance/datetick.m	Thu Mar 16 09:02:21 2017 -0700
+++ b/scripts/plot/appearance/datetick.m	Thu Mar 16 09:27:28 2017 -0700
@@ -219,15 +219,19 @@
         minmonth = ifelse (minmonth == 0, 1, minmonth);
         maxmonth = sep * ceil (maxmonth / sep);
         rangemonth = (minmonth:sep:maxmonth)';
+        tickdays = round (1 + 28*mod (rangemonth, 1));
         ticks = datenum ([repmat(minyear, size(rangemonth)), ...
-                          rangemonth, ...
-                          ones(size (rangemonth))]);
+                          floor(rangemonth), ...
+                          tickdays]);
       else
         sep = __calc_tick_sep__ (minyear, maxyear);
         minyear = sep * floor (minyear / sep);
         maxyear = sep * ceil (maxyear / sep);
         rangeyear = (minyear:sep:maxyear)';
-        ticks = datenum ([rangeyear, ones(rows(rangeyear),2)]);
+        tickmonth = round (1 + 12*mod (rangeyear, 1));
+        ticks = datenum ([floor(rangeyear), ... 
+                          tickmonth, ...
+                          ones(rows (rangeyear), 1)]);
       endif
     endif
   endif
--- a/scripts/time/datenum.m	Thu Mar 16 09:02:21 2017 -0700
+++ b/scripts/time/datenum.m	Thu Mar 16 09:27:28 2017 -0700
@@ -159,6 +159,13 @@
   ## Lookup number of days since start of the current year.
   day += monthstart(mod (month-1,12) + 1) + 60;
 
+  ## Treat fractional years, by converting the fraction to days
+  if (any (year != fix (year)))
+    fracyear = year - floor (year);
+    year = floor (year);
+    day += fracyear .* (365 + is_leap_year (year+1));
+  endif
+  
   ## Add number of days to the start of the current year.  Correct
   ## for leap year every 4 years except centuries not divisible by 400.
   day += 365*year + floor (year/4) - floor (year/100) + floor (year/400);
@@ -196,10 +203,15 @@
 %! n = n';
 %! assert (datenum (t(1,:), t(2,:), t(3,:), t(4,:), t(5,:), t(6,:)), n, 2*eps);
 
+## Test fractional years including leap years
+%!assert (fix (datenum ([2001.999 1 1; 2001.999 2 1])), [731216; 731247])
+%!assert (fix (datenum ([2004.999 1 1; 2004.999 2 1])), [732312; 732343])
+
 ## Test fractional months including leap months
 %!assert (fix (datenum ([2001 1.999 1; 2001 2.999 1])), [730882; 730910])
 %!assert (fix (datenum ([2004 1.999 1; 2004 2.999 1])), [731977; 732006])
 
+
 ## Test mixed vectors and scalars
 %!assert (datenum ([2008;2009],1,1), [datenum(2008,1,1);datenum(2009,1,1)])
 %!assert (datenum (2008, [1;2], 1), [datenum(2008,1,1);datenum(2008,2,1)])