I would suggest an alternative API for this:
void makeDiagonal(double value)
void makeDiagonal(RealVector values)
Or even
void setDiagonal(int offset, double value)
void setDiagonal(int offset, RealVector values)
Where this does NOT change any other values. You would do clear,
setDiagonal to get an identity matrix.
Mostly I would also suggest that this probably an indicator of an overlooked
improvement in your code. Mostly, you should represent sparse matrices such
as the identity using a sparse structure of some kind (a diagonal matrix, a
special identity matrix or something). You may have a case where you are
starting with the identity and then transforming it such as certain kinds of
LUD implementations nominally do. Mostly, however, those algorithms are
better stated such that the identity matrix is never represented explicitly.
On Mon, Mar 2, 2009 at 4:06 AM, Jelle Herold <jelle@defekt.nl> wrote:
>
> I'm missing a couple of (basic) functions on the RealMatrix class;
> for example,
>
> void identity(); // set to identity matrix
> boolean isIdentity() // check if this is an identity matrix

Ted Dunning, CTO
DeepDyve
