Hi, On Fri, Aug 15, 2014 at 7:00 PM, Reid McKenzie <rmckenzi...@gmail.com> wrote:
> > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > The best way to build a complex arithmetic package is probably to work > atop `clojure.algo.generic`. I've done a pair of libraries ( > https://github.com/arrdem/imprecise, https://github.com/arrdem/meajure) > based around extending algo.generic with custom datatypes and they've both > worked out well > I'll look at these. Building complex arithmetic atop algo.generic wouldn't bring the desired unification, because for example core.matrix doesn't use algo.generic ... > Clojure in general seems pretty loath to package "traditional" numerics > facilities... note that we don't even have a built in square root operator > and the common practice is to use java.lang.Math through interop so I > wouldn't go holding your breath over adding irrational numbers to the > language core. Also clojure.contrib is abandoned and deprecated in favor of > "real" community maintained standalone libraries. The most likely place for > an irrational type is probably either a user library like both of the above > or possibly algo.generic itself. > Yeah, I meant 'as a contrib library' when I wrote clojure.contrib. Sorry for the confusion. As for the other part, let me elaborate a bit: As it is true that clojure doesn't have much numeric functions in core (like the square root example), it doesn't eschew numeric /types/ like BigInt and Rationals, and you obviously can't pass to java.lang.Math via interop already. Take rationals as example. I really like them and use them often in my clojure code because they give you exact arithmetic basically for free because they are part of the core language and you can use them anywhere (in pure clojure). They even have a convenient literal syntax (but that is not that inportant). We had a discussion a while ago on the clojure-numerics mailing list on how we could open core.matrix for arbitrary scalar types, like complex numbers or symbolic expressions. I'll link this here as it could be of interest: https://groups.google.com/forum/#!topic/numerical-clojure/Ze7lNjXJeQc/discussion I think a reason that held the discussion back was missing standard types to experiment with. I don't argue that clojure should provide complex types as part of clojure.core and can understand the reasons not to (while I think it would be the same reason as including rationals in clojure.core) but as a clojure contrib library that other clojure math libraries build ontop of (including core.matrix and algo.generic). The tricky part would then be figuring out how to nicely interop with the other clojure types without incuring too much overhead to be used in serious scientific computing (I think algo.generic uses multimethods for dispatch, which is definitly too slow in highly stressed inner loops of heavy matrix manipulations for example). greetings Maik Reid > > > On 08/15/2014 10:24 AM, Maik Schünemann wrote: > > Hi, > > is there a recommended way to do complex arithmetic in clojure ? > > I am interested to see clojure going forward for scientific computing > purposes. > > There is already considerable effort going on with core.matrix, > incanter, expresso etc. > > But something thad is oddly lacking is support for complex numbers. For > some areas, this is > > a show stopper and it is very basic stuff in other languages and > systems: > > - common-lisp, python etc all have a standard complex type as part of > the language/standard library > > - see language support here > http://en.wikipedia.org/wiki/Complex_data_type > > > > In Java, there are multiple incompatible complex number classes and I > don't want that incompatibilities > > in clojure libraries that provide complex number manipulation. > > > > In my opinion we should strive as a community for a standard complex > number datatype, that is agreed on by clojure libraries, > > and plays nicely with clojures other numeric types. > > Ideally, this would be provided as part of clojure.contrib or even > clojure itself - like rationals are! > > > > > > > > > > -- > > You received this message because you are subscribed to the Google > > Groups "Clojure" group. > > To post to this group, send email to clojure@googlegroups.com > > Note that posts from new members are moderated - please be patient with > your first post. > > To unsubscribe from this group, send email to > > clojure+unsubscr...@googlegroups.com > > For more options, visit this group at > > http://groups.google.com/group/clojure?hl=en > > --- > > You received this message because you are subscribed to the Google > Groups "Clojure" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to clojure+unsubscr...@googlegroups.com > <mailto:clojure+unsubscr...@googlegroups.com> > <clojure+unsubscr...@googlegroups.com>. > > > For more options, visit https://groups.google.com/d/optout. > > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v2 > > iQIcBAEBAgAGBQJT7jysAAoJELjHpJOzPfTlUqoP/3UGoIusWhK+/0yzYvqCHsPK > QzU7criJGsNCfP8h0H7kClwJh7gIZHJlnBDMVHh7eP6VDPlnunTv7nYbFCPMYUys > SiM0dhW94EqEKUtl0gcIUoFfhDBeAPhgoi02/Lm0w51CcarhEnstVFVnUOLJPbsB > sTJuEC1ZigBtJz8pwBzGQnBYIRDaSONSxAEoV8aDmXinKBh+mPZKDRkE2emHsxDi > kSkMmDYicmc/2chFnjdbhSvJQajqoKKZvxuHAVboKKkWqowgHbHaB3ybsoZs/GT9 > NYZEBVfEJWrgvQvgQsZNnuc2esd4f86JJp/QAyCvIzofsoNQbGBtPzbXBLkq7JYF > Me3JBwI1F9N221ZfTyRIXjRzc2P6cZdRcMAetsRgw2tSl94HVuHp2VGzaeqGlsR/ > b7tsv06o2jTlNbaH+o1lisAQcs7pTJ1SZO1FZmCBoY1/b7f3MVa//hAK5pHa/tMH > +bAVZaAtAe+K3JjCokHwN7MX1gfVUNyIxD9kj/jlnrq+Xmvg8U7EA16wH+NDEI0j > jDXUkcTYfdM/dR7NV5Jvzwgd9A7Gm+2If6xN4Kx1ZviJk+XP3tYWx3FoCLungjaz > FujqwSChdDQ3Qw9k9uJ8zUR+e+9EsOsB86CmX/BmQCifcEpp1KlTUzFaR1XR3Gbg > VS5qG9H32gMMXpXSU02M > =cssb > -----END PGP SIGNATURE----- > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.