![]() |
Blitz Support : |
From: Navneet Dalal (navneet.dalal_at_[hidden])
Date: 2003-09-12 07:33:39
Hi Julian,
>> 3. In TinyVector class (tinyvec.h and tinyvec.cc), all constructors take
>> T_numtype argument, a slightly better way may be to pass const
>> T_numtype&: for e.g. inline TinyVector(const T_numtype& initValue);
>> compare to
>> inline TinyVector(T_numtype initValue);
>>
>> The same holds for all variants of TinyVector(T_numtype ...
>> constructors.
>
> This is mostly a matter of programming style. I typically pass arguments
> by value if
> the objects are small simple types such as the built-in number types.
> That is how it
> happens to be done here in blitz. Also, tvmet constructs its Vector with
> pass-by-value.
> There is only an efficiency issue if the object is expensive to copy.
I donot agree that it is just a matter of programming style. As you agree
that there is an efficiency bottleneck if the TinyVector's are not
constructed for built-in types.
One may use it for any kind of Objects. It would be naive to assume that
TinyVector should
only be used for built in types. Since efficiency is one of the prime goal
of blitz, I am unable to comprehend why these changes should not be made.
>> 4. in file array_impl.h, isInRange should be changed to
>>
>> template<class T>
>> _bz_bool isInRange(const TinyVector<T,N_rank>& index) const
>> // Was : _bz_bool isInRange(const T_index& index) const
>>
>>
>> This will allow to check range for TinyVector values of types double.
>> T_index is typedef to TinyVector<int, rank>.
>>
> The reason why this is limited to TinyVectors of ints is that blitz
> Arrays can only
> be indexed with int arguments. Indexing an Array with floating-point
> indices is
> not defined. Thus, there is really no purpose to checking whether a
> TinyVector
> of doubles falls within the index domain of an Array (at least, none that
> I can think of).
> Of course, if you *really* need to do this, you can loop over the
> elements of your
> TinyVector and check that each value lies between base(d) and base(d)
> +length(d).
I use blitz in image processing. Frequently, I need to check if a point (of
double)
is in domain of image-space (i.e. blitz array). So here is the need.
Ofcourse, one can loop over the elements, but if one looks isInrange
function code, then this
is exactly what is written. My policy in this manner is, if one can avoid
rewriting the same code again and again, one should avoid (esp if it is
already present in the library).
And further, I donot see any problems with this change. It is a small
extension without any compromise on efficiency.
In fact, I feel that all overloaded isInRange functions should accept
template arguments.
regards
navneet