commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sébastien Brisard <sebastien.bris...@m4x.org>
Subject Re: [math] Second thoughts on MATH-803 and "zip-visitor" for vectors.
Date Mon, 26 Nov 2012 12:37:12 GMT
Hi,


2012/11/26 Gilles Sadowski <gilles@harfang.homelinux.org>

> On Sun, Nov 25, 2012 at 06:00:06PM +0100, Sébastien Brisard wrote:
> > Hi,
> > in MATH-803 [1] it was decided to deprecate
> RealVector.ebeMultiply/Divide,
> > because these methods were difficult to support with sparse vectors.
> > However, in MATH-870, we decided to deprecate sparse vectors altogether.
> >
> > I'm therefore having second thoughts on MATH-803. Since the problematic
> > implementations of RealVector are removed, why not keep these quite handy
> > methods?
> >
> > BTW, these methods could be implemented with visitors, but the current
> > interface of vector visitors allows visiting only ONE vector at a time.
> So
> > visiting TWO vectors simultaneously requires uggly tweaking of this
> > interface (basically, storing a reference of one of the two vectors to be
> > visited as a class variable of the visitor itself... so much for
> > imutability).
> >
> > How about we introduce "zip-visitors" to visit simultaneously two
> vectors?
>
> I don't know the phrase "zip-visitors".
>
>
> It's probably not the best name for such a visitor. Python has a zip()
function [1] which takes a number of lists and return a single list of
tuples. You can then apply functional programming concepts to the newly
created list.

>
> How would they work?
>
That's for us to figure out. We could have something like "walk(vector1,
vector2, visitor)", where the visitor would take three arguments : an int
(the index), and two doubles (the left and right value).
Note that if we go for this, we should really think about doing the same
with the RealVector.map(), as element-by-element multiplication/division is
has more to do with mapping a bivariate function, rather than visiting two
vectors). The reason I'm implementing it at the moment with a visitor is
because I need to store locally (in the visitor) one of the two vectors,
and I need to know whic component of this local copy I need to combine to
the component of the vector on which 'visitXXX' is called. Not sure I'm
very clear.

Again, there is no time constraint on this, I just thought we could start
thinking about it.

Sébastien

[1] http://docs.python.org/2/library/functions.html#zip

> Regards,
> Gilles
>
> > This is just an idea, it can of course wait until 3.2, but if we agree
> upon
> > the idea, I can file a JIRA ticket for the record.
> >
> > Best regards,
> >
> > Sébastien
> >
> > [1] https://issues.apache.org/jira/browse/MATH-803
> > [2] https://issues.apache.org/jira/browse/MATH-870
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message