--- "Mark R. Diggory" <[EMAIL PROTECTED]> wrote: > Al Chou wrote: > > My personal preference would originally have been to use 1-based indexing > > (actually, I really prefer Fortran's ability to let the user define the > lower > > bound index value in each array dimension if they so choose, even though > that > > facility is not that often used), but that was based on my assumption that > > commons-math is a library for enabling people who know some math to more > easily > > do math in Java. However, the few use cases we've heard about seem to be > split > > between that kind of user and Java programmers who have some need for math > > capabilities. The former class of user would more likely want/expect > 1-based > > indexing, the latter would expect 0-based indexing. Quoting from our own > home > > page: > > > > "Guiding principles: > > > > 1. Real-world application use cases will determine development priority. > > ... > > 4. In situations where multiple standard algorithms exist, a Strategy > pattern > > will be used to support multiple implementations." > > > > Unfortunately, nowhere in our charter do I know of a statement that would > help > > us decide the priority between the two classes of users I described above > (I > > would be happy if someone pointed out some passage of our charter that I > don't > > know about that would resolve this decision). > > > > I think ideally we would provide facilities to handle both 0- and 1-based > > indexing (and even arbitrary lower-bound-based indexing, given that I'm > > pipe-dreaming here). > > > > The _Numerical Recipes_ solution to this problem is to stick to 1-based > > indexing throughout, as all algorithms are described in standard > mathematical > > notation where the first index in each dimension is 1 (probably also > because it > > made for easier [possibly at least partially automated] translation from > the > > original 1-based Fortran source code into other languages). For 0-based > > languages (viz., C and presumably C++) they provided array data types that > > automatically translated between the mathematical 1-based notation and the > > underlying 0-based array data structure, at the expense of having one extra > > element in each dimension of each array, I believe. Perhaps we could do > > something similar and even provide a user setting that would choose between > > 0-based and 1-based behavior -- probably a global setting, to prevent the > kind > > of confusion that would result from mixing the two representations > > unintentionally. > > > > > > Al > > > > At first this sounds like a concession to both sides of the issue, But, > my fear is that this will introduce more complexity and confuse the > user. I would say one or the other, not both. I think theres too much > ridiculous partisanship when it comes to subjects like "whats the best > language". Its amazing what people with fixate on and defend as > important (myself included). Thats why I suggest indexing in that of the > implementation language. If I were working with Fortran, I'd argue to > use 1 <= x < n. > > I'm sure it doesn't matter very much either way... > > -Mark
I think switching back and forth between 1-based mathematical notation and 0-based programming language notation would be horrible. My preference would be to stay in mathematical notation throughout my mathematical code. I wonder if it would work to return (when asked) larger-by-one double arrays that only contain actual data in elements (1,1) through (n,n). I guess there's a problem of what to put in the zeroth elements, given that these are double arrays (not object arrays), so that the values put in those elements would have to be valid double values. One could mistakenly access and use the zeroth elements without necessarily recognizing that their very existence should be ignored. In any case, I feel that whatever we choose to do should feel as natural as possible for the majority of users. I don't know who makes up the majority of this library's users, but I suspect it's Java programmers who just need a bit of math in their code. If so, that _may_ mean 0-based indexing is what's going to seem more natural to the majority of commons-math users (I do worry about such users getting confused when they read 1-based mathematical explanations of what our routines do, assuming they are not familiar with the mathematics and are having to reconcile a new concept in an unfamiliar notation with what they're familiar with as the programming language's natural notation). Al --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
