|
From: | Michael Goffioul |
Subject: | Re: Question about Array::index with resizing |
Date: | Thu, 23 May 2013 07:21:00 -0400 |
My guess is that it's probably intentional in the sense it is the best that can be done without issuing some type of error. There is resizing, but only provided it can be done properly.On 05/22/2013 09:06 PM, Michael Goffioul wrote:
Could anybody enlighten me about the implementation of
Array<T>
Array<T>::index (const Array<idx_vector>& ia,
bool resize_ok, const T& rfv) const
I'm trying to use it in the classdef branch, assuming this function
would resize the array is the given index is out of bound. In my case,
"ia" contains only scalars, so the variable "all_scalars" ends up being
true. But then the code does:
if (all_scalars)
return Array<T> (dim_vector (1, 1), rfv);
In other words, the code always return an array with a single element
being the resize_fill_value. No resizing or array indexing actually
takes place.
Is it intentional? Unimplemented? Or am I missing something?
This hunk of code:
for (int i = 0; i < ial; i++) dvx(i) = ia(i).extent (dv (i));
if (! (dvx == dv))
verifies that the index arrays are all within proper extent. If the two vectors don't match, then something was outside of extent.
[Prev in Thread] | Current Thread | [Next in Thread] |