octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

incorrect dimension in axes::properties::calc_ticks_and_lims?


From: John W. Eaton
Subject: incorrect dimension in axes::properties::calc_ticks_and_lims?
Date: Mon, 24 Jan 2011 01:19:40 -0500

I noticed that the Matrix tmp_mticks might not be dimensioned
correctly in the function axes::properties::calc_ticks_and_lims.  The
code at the end of that function is:

    int n = is_logscale ? 9 : 4;
    Matrix tmp_mticks (1, n * tmp_ticks.numel ());

    for (int i = 0; i < tmp_ticks.numel ()-1; i++)
      {
        double d = (tmp_ticks (i+1) - tmp_ticks (i)) / (n+1);
        for (int j = 0; j < n; j++)
          {
            tmp_mticks (n*i+j) = tmp_ticks (i) + d * (j+1);
          }
      }
    mticks = tmp_mticks;
  }

I see that the loop over I must go from 0 to tmp_ticks.numel()-2 since
we access tmp_ticks(i+1) in the loop, but this leaves the last N
elements of tmp_mticks uninitialized.  What is the intent here?
Should tmp_mticks be declared with

    Matrix tmp_mticks (1, n * (tmp_ticks.numel () - 1));

instead?

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]