commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Sterijevski <gsterijev...@gmail.com>
Subject Re: [math] RealMatrix.set(double)
Date Tue, 23 Aug 2011 22:58:41 GMT
Why not use Ted's insight? Instead of a bunch of these "setDiagonal",
"setAll", "setFirstN", ... why not just have a set( MatrixFunction mf ). The
MatrixFunction delegate could handle whatever we want. It would keep the
objects very clean. You could even have a class factory of commonly used
MatrixFunction objects.

2011/8/22 S├ębastien Brisard <sebastien.brisard@m4x.org>

> Maybe setAllEntries? That would be consistent with setEntry?
> What about RealVector? The method set(double) should be renamed also?
> S├ębastien
>
> 2011/8/22 Ted Dunning <ted.dunning@gmail.com>:
> > On Mon, Aug 22, 2011 at 1:27 PM, Phil Steitz <phil.steitz@gmail.com>
> wrote:
> >
> >> I think it would be good to add this, but it would probably be
> >> better to give it a different name.  What name, I am not sure.
> >> Maybe setAll or fill.  Might also be useful to have versions that
> >> fill submatrics.
> >>
> >
> > Mahout allows this via overloading of an assign method.
> >  Matrix.assign(double) over-writes all cells with a constant value.
> >  Matrix.assign(Matrix) copies data into the target.  x.assign(Matrix y,
> > BinaryFunction f) does element-wise x_ij = f(x_ij, y_ij)
> >
> >
> >> Here is a little joke to lighten things up a bit.  What if we just
> >> allow people to specify negative indices to mean "everything."  So
> >> for example, setEntry(-1, -1, 0) sets all entries to 0, setEntry(1,
> >> -1, 0) sets the first row to 0.  Just kidding ;)
> >>
> >
> > Can be useful.
> >
> > I find the TCL convention more useful where -1 refers to the last element
> of
> > a vector.
> >
> > This sort of thing does tend to freak out the more mathematically
> inclined
> > and it does make it harder to catch errors in mathematical code since it
> > mutes indexing errors.
> >
>
> ---------------------------------------------------------------------
> 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