Please, use instanceof (though I hate it) in abeyance of doing this with a better way.
The better way is to separate dispatch from implementation. This is an N x M problem: some pairs of classes want special implementations of some method. To do this cleanly requires a separate dispatcher that stores (type A, type B, functor) and finds a special combination when one exists. In other words, vector1.times(vector2) is doomed to endless hacking, while Vector.times(vector1,vector2) is future-proof. On Sun, Jan 23, 2011 at 1:00 PM, Ted Dunning <[email protected]> wrote: > The isDense approach is slightly more future-proof since there might be more > ways of being dense than just DenseVector. For instance, some math packages > have special code for symmetric dense matrices that only store half the > data, but are still best considered dense matrices. Other matrices like > Toeplitz or Hilbert matrices or the random matrices that we use for random > projection all have a relatively small amount of data that defines them, but > every element is defined so they are best considered dense. > > I wouldn't expect that we will need these special forms any time soon, but > the term right-er probably applies. > > On Sun, Jan 23, 2011 at 2:56 AM, Sean Owen (JIRA) <[email protected]> wrote: > >> I think the right-er design would be an isDense() flag or something that >> affects behavior within one method. However for now I was just committing >> the patch. >> > -- Lance Norskog [email protected]
