Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #25870

Re: sorting a matrix based on values in an array

From markspace <nospam@nowhere.com>
Newsgroups comp.lang.java.programmer
Subject Re: sorting a matrix based on values in an array
Date 2011-02-08 10:21 -0800
Organization A noiseless patient Spider
Message-ID <iis1ij$6pc$1@news.eternal-september.org> (permalink)
References <6e7c1410-2a14-4ddc-b2e0-0d248533bdc6@q40g2000prh.googlegroups.com>

Show all headers | View raw


On 2/8/2011 8:35 AM, harryos wrote:

> I thought of using a Hashtable<Double, double[]>   and storing the
> elements of aVector as keys, and rows of aMatrix as values.This would
> let me sort the keys and finally build a sorted matrix from the
> hashtable.But then this approach would fail if aVector contains a
> duplicate element.
> aVector = [4.4521, 3.654,  3.654, 0 ]


Assuming this would otherwise work (I didn't read your spec carefully) 
Java has an IdentityHashMap that stores by object reference (i.e., the 
actual array objects themselves) rather than value or content of the 
object.

So an identical row wouldn't matter, as long as you used a separate 
array to store the values in (almost certainly the case unless you are 
comparing each row and re-using an array if it's identical).

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

sorting a matrix based on values in an array harryos <oswald.harry@gmail.com> - 2011-02-08 08:35 -0800
  Re: sorting a matrix based on values in an array markspace <nospam@nowhere.com> - 2011-02-08 10:21 -0800

csiph-web