octave-maintainers
[Top][All Lists]
Advanced

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

Re: 3D versus 2D Indexing and the Speed Thereof


From: Luis F. Ortiz
Subject: Re: 3D versus 2D Indexing and the Speed Thereof
Date: Tue, 10 Apr 2007 18:00:33 -0400

[Sorry for the delayed reply, I took ill for a few days]
On Fri, 2007-04-06 at 13:00 -0400, John W. Eaton wrote:
On  6-Apr-2007, Luis F. Ortiz wrote:

| 1)  One of the methods patched is assign2(). It has the following
| signature:
| 
|         template <class LT, class RT>
|         int
|         assign2 (Array<LT>& lhs, const Array<RT>& rhs, const LT& rfv)
| 
| This seems to me to be an attempt to support type conversions during the
| assignment.
| But the code I wrote only works for the case where RT and LT are the
| same type.   What
| is the right way to handle this?  Can it be done at
| runtime/compiletime? 
| Is this ever instantiated with LT != RT?

Yes, see liboctave/Array-C.cc for example. 
Uggh, you are right.   This issue can not be ignored.

 If there is no general way
to get the speedup with mixed types, then maybe we could come up with
a way to handle the same type case with some kind of partial
specialization?

A specialization that looked like:

template <class T>
int
assign2 (Array<T>& lhs, const Array<T>& rhs, const T& rfv)

would do the trick, but the code would be a near duplicate in both functions. 
On the other hand, if we broke up assign2 into subfunctions that took care of the common
parts and were defined to be inline, the duplication could be kept to a minimum. 
I would suspect that index() and assign() would in fact have common code.


/ortiz/luis

reply via email to

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