Return-Path: Delivered-To: apmail-commons-dev-archive@www.apache.org Received: (qmail 38542 invoked from network); 21 May 2009 10:14:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 21 May 2009 10:14:11 -0000 Received: (qmail 20727 invoked by uid 500); 21 May 2009 10:14:24 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 20570 invoked by uid 500); 21 May 2009 10:14:23 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 20560 invoked by uid 99); 21 May 2009 10:14:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 May 2009 10:14:23 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 May 2009 10:14:12 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1M75Hb-0004il-Vj for dev@commons.apache.org; Thu, 21 May 2009 03:13:51 -0700 Message-ID: <23650705.post@talk.nabble.com> Date: Thu, 21 May 2009 03:13:51 -0700 (PDT) From: Sam Halliday To: dev@commons.apache.org Subject: Re: [math] Re: commons-math, matrix-toolkits-java and consolidation In-Reply-To: <00f201c9d9b7$076b39c0$f17ae560@oemcomputer> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: sam.halliday@gmail.com References: <23537813.post@talk.nabble.com> <4A0C6C54.9070008@free.fr> <4A0E157E.1020201@gmail.com> <4A0E22B2.9030102@gmail.com> <4A0E7B48.3030905@free.fr> <23574535.post@talk.nabble.com> <4A0EDF32.7010703@free.fr> <23575419.post@talk.nabble.com> <4A0EEC7C.3010507@free.fr> <23575674.post@talk.nabble.com> <23575831.post@talk.nabble.com> <4A0EF740.4000705@free.fr> <00ba01c9d678$e2af7920$b29633ad@oemcomputer> <23595640.post@talk.nabble.com> <000701c9d82f$f67d7750$f17ae560@oemcomputer> <23611886.post@talk.nabble.com> <4A144671.5020406@gmail.com> <00f201c9d9b7$076b39c0$f17ae560@oemcomputer> X-Virus-Checked: Checked by ClamAV on apache.org Bill, I've had a look at some of the recent changes... some comments, including some new thoughts:- - changing the return type to be actual classes was only supposed to be for copy() for 2.0. Doing this on multiply, add, etc is a big mistake... there is no guarantee that is the best thing to do and it is likely this will change in the future. This stands for all implementations. Great thought needs to go into each method, not just by reading the current implementation. - I *strongly* urge you to remove Serializable from everything! Please, we did this in MTJ and it turned out to be a major pain. A more appropriate approach is to define a class for reading/writing Matrix Market files. This can be a new feature in 2.1. If you're going to leave it, at least document that the Serializable form is not guaranteed to remain compatible across versions. - I discourage the use of the classes named *Impl. They will get very confusing when other implementations are added later! Instead, I recommend the names ArrayRealVector, Array2DRowRealMatrix (to indicate a 2D array backed implementation using row ordering). This allows a column-based or 1D implementation in the future without names getting very confusing. These implementations are hidden from users who just use the MatrixUtils help - -1 for inclusion of methods in the sparse interfaces and shape type enum. This needs more thought and discussion before inclusion. I am happy enough for marker interfaces to be included (as long as it is documented that these interfaces are subject to update in the next release), but strongly against including methods in them. - could you please describe the hashing algorithm that OpenMap is using? I have previously written a GNU Trove based sparse matrix implementation which was a map from the primitive "long" to "double". It looks analagous. I broke the row/column index into a long for the key using binary operations, but the hashcode was tricky as it had to be an integer (not long). A naive implementation can lead to collisions for typical or symmetric matrices. It looks like the current implementation is using an int -> double backing map! Wouldn't it make more sense to use a long? The following code might be useful to you (don't forget the L marker and casts or the compiler will silently cast to an int), there are two options for a hashcode calculator... I've not stress tested the second one but it might be more appropriate as it gives more weight to lower bits. Remember that FF is 256, or a full byte... so a full 64 bit long is 8 bytes or 16 hex characters in Java bitwise. int hash1(long val) { int first = Integer.reverse(key2row(val)); int second = key2col(val); return first + second; } int hash2(long val) { int first = key2row(val) & 0x0000FFFF; int second = key2col(val) << 16; return first + second; } long key(int row, int column) { return (((long) row) << 32) + (long) column; } int key2col(long key) { return (int) (key & 0x00000000FFFFFFFFL); } int key2row(long key) { return (int) (key >>> 32); } Bill Barker wrote: > > I have a slight preference for leaving the markers empty until 3.0, but I > can remove them as well. But I can wait to see what the community > consensus > is before making changes. > -- View this message in context: http://www.nabble.com/commons-math%2C-matrix-toolkits-java-and-consolidation-tp23537813p23650705.html Sent from the Commons - Dev mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org