[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: incorrect dimension in axes::properties::calc_ticks_and_lims?
From: |
Ben Abbott |
Subject: |
Re: incorrect dimension in axes::properties::calc_ticks_and_lims? |
Date: |
Mon, 24 Jan 2011 20:06:25 -0500 |
On Jan 24, 2011, at 6:51 PM, logari81 wrote:
> On Mon, 2011-01-24 at 01:19 -0500, John W. Eaton wrote:
>> 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
>
> that was my mistake, I haven't tried your suggestion yet but I think you
> are right, it should be:
>
> Matrix tmp_mticks (1, n * (tmp_ticks.numel () - 1));
>
> BR
>
> Kostas
Kostas,
Will you be submitting a changeset for this?
Ben