Re: complex number library

2015-06-02 Thread Christopher Small
You sir, rock. On Tue, Jun 2, 2015 at 10:41 AM, Mike Anderson mike.r.anderson...@gmail.com wrote: OK, here's a basic version that I think has most of the key elements in place. A lot more protocols still need implementing, but it should be a reasonable basis to build upon:

Re: complex number library

2015-06-02 Thread Mike Anderson
I agree that complex would be a better name. It would be also be nice if it the 1-arg version could be idempotent (i.e. returns an existing complex number unchanged). The downside is that this would mean a slight performance hit because it would prevent the use of primitive arguments. Maybe we

Re: complex number library

2015-06-02 Thread Christopher Graham
How about changing the name of the complex-number function to, ideally, complex? complex-number seems irritating to (have to) read. Further, calling this function is a form of type coercion. (float ...), (int ...), etc., are idiomatic Clojure, whereas (float-number ...), (int-number ...),

Re: complex number library

2015-06-02 Thread Christopher Small
That sounds pretty solid imo. On Tue, Jun 2, 2015 at 5:53 PM, Mike Anderson mike.r.anderson...@gmail.com wrote: I agree that complex would be a better name. It would be also be nice if it the 1-arg version could be idempotent (i.e. returns an existing complex number unchanged). The downside

Re: complex number library

2015-06-02 Thread Mike Anderson
I think the right strategy is to make a separate complex array implementation library (core.matrix.complex?). In terms of dependencies, it would only need to depend depend upon core.matrix and complex. The array representation could simply be a deftype which uses two underlying arrays for the

Re: complex number library

2015-06-02 Thread Christopher Small
The array representation could simply be a deftype which uses two underlying arrays for the real and complex parts of the array respectively. Oh man; that is flipping brilliant. And simple... The implementation should be fairly straightforward, but if anyone wants I can create a repo and bang

Re: complex number library

2015-06-02 Thread Mike Anderson
OK, here's a basic version that I think has most of the key elements in place. A lot more protocols still need implementing, but it should be a reasonable basis to build upon: https://github.com/mikera/core.matrix.complex On Tuesday, 2 June 2015 16:35:25 UTC+1, Christopher Small wrote:

Re: complex number library

2015-06-01 Thread Alan Forrester
On 1 June 2015 at 00:42, Daniel doubleagen...@gmail.com wrote: Criterium should probably be just a Dev dependency. Okay. Fixed. Thanks, Alan -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: complex number library

2015-06-01 Thread Christopher Small
Are these operations (*, +, etc) interoperable with core.matrix operations? That may end up being pretty key for a lot of numerical users. Chris On Sunday, May 31, 2015 at 3:55:46 PM UTC-7, Alan Forrester wrote: https://clojars.org/complex https://github.com/alanforr/complex Complex is

complex number library

2015-05-31 Thread Alan Forrester
https://clojars.org/complex https://github.com/alanforr/complex Complex is a Clojure library for doing complex number calculations that wraps the Java commons-math3 Complex library. complex A Clojure library for doing calculations with complex numbers. Wraps the Java commons-math3 Complex

complex number library

2015-05-31 Thread Daniel
Criterium should probably be just a Dev dependency. -- 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.

Re: complex number library

2010-12-16 Thread Laurent PETIT
2010/12/16 Sunil S Nandihalli sunil.nandiha...@gmail.com double-dispatch in clojure .. thats neat... Thanks Stuart. Really, that's double-dispatch with protocols, 'cause double-triple-whatever-dispatch on anything you know 'bout the function arguments is solved since the introduction of

Re: complex number library

2010-12-16 Thread Sunil S Nandihalli
my bad .. thats what I meant..:) On Thu, Dec 16, 2010 at 2:10 PM, Laurent PETIT laurent.pe...@gmail.comwrote: 2010/12/16 Sunil S Nandihalli sunil.nandiha...@gmail.com double-dispatch in clojure .. thats neat... Thanks Stuart. Really, that's double-dispatch with protocols, 'cause

Re: complex number library

2010-12-15 Thread Konrad Hinsen
On 14 Dec, 2010, at 19:47 , Stuart Sierra wrote: On Dec 14, 2:31 am, Konrad Hinsen konrad.hin...@fastmail.net wrote: That's actually what clojure.contrib.complex-numbers already uses! And it's based on multimethods, not protocols, because of all those binary operations. It is possible,

Re: complex number library

2010-12-15 Thread Sunil S Nandihalli
double-dispatch in clojure .. thats neat... Thanks Stuart. Sunil. On Wed, Dec 15, 2010 at 12:17 AM, Stuart Sierra the.stuart.sie...@gmail.com wrote: On Dec 14, 2:31 am, Konrad Hinsen konrad.hin...@fastmail.net wrote: That's actually what clojure.contrib.complex-numbers already uses! And

Re: complex number library

2010-12-14 Thread Stuart Sierra
On Dec 14, 2:31 am, Konrad Hinsen konrad.hin...@fastmail.net wrote: That's actually what clojure.contrib.complex-numbers already uses! And   it's based on multimethods, not protocols, because of all those binary   operations. It is possible, though not trivial, to do 2-argument dispatch with

complex number library

2010-12-13 Thread Sunil S Nandihalli
Hello everybody, I found two libraries for complex numbers...One in apache.common.math and the other in clojure-contrib but which clearly states that it is quiet incomplete ... can anybody make a suggestion for a good alternative.. Thanks, Sunil. -- You received this message because you are

Re: complex number library

2010-12-13 Thread Sunil S Nandihalli
I really miss having complex numbers as native types... :( On Tue, Dec 14, 2010 at 3:11 AM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hello everybody, I found two libraries for complex numbers...One in apache.common.math and the other in clojure-contrib but which clearly states

Re: complex number library

2010-12-13 Thread Sunil S Nandihalli
Hello Everybody, I see that Konrad-Hinsen's complex-library in the contrib is a very good fit.. But I am afraid about the performance since the basic operations are being dispatched using multi-methods... Does anybody have any say on this? Sunil. On Tue, Dec 14, 2010 at 3:20 AM, Sunil S

Re: complex number library

2010-12-13 Thread David Nolen
On Mon, Dec 13, 2010 at 8:13 PM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hello Everybody, I see that Konrad-Hinsen's complex-library in the contrib is a very good fit.. But I am afraid about the performance since the basic operations are being dispatched using multi-methods...

Re: complex number library

2010-12-13 Thread Sunil S Nandihalli
Thanks David .. but is there a protocol that contains +,*,/,- operations? If there is one I can simply add those operations... Sunil. On Tue, Dec 14, 2010 at 7:07 AM, David Nolen dnolen.li...@gmail.com wrote: On Mon, Dec 13, 2010 at 8:13 PM, Sunil S Nandihalli sunil.nandiha...@gmail.com

Re: complex number library

2010-12-13 Thread Robert McIntyre
It's not a protocol, but you may want to take a look at clojure.contrib.generic.arithmetic for inspiration. I wish you luck in your complex number implementation! I've done my own using clojure.contrib.generic and can post if it anyone's interested. thanks, --Robert McIntyre On Mon, Dec 13,

Re: complex number library

2010-12-13 Thread Sunil S Nandihalli
Robert would love to see your implementation.. The reason I am going for protocols .. is performance... Sunil. On Tue, Dec 14, 2010 at 8:52 AM, Robert McIntyre r...@mit.edu wrote: It's not a protocol, but you may want to take a look at clojure.contrib.generic.arithmetic for inspiration. I

Re: complex number library

2010-12-13 Thread Robert McIntyre
here it is: (defrecord imaginary [real complex]) (defmethod + [imaginary Number] [i r] (imaginary. (+ (:real i) r) (:complex i))) (defmethod + [Number imaginary] [r i] (+ i r)) (defmethod + [imaginary imaginary] [i1 i2] (imaginary. (+ (:real i1) (:real i2))

Re: complex number library

2010-12-13 Thread Konrad Hinsen
On 13 Dec 2010, at 22:41, Sunil S Nandihalli wrote: I found two libraries for complex numbers...One in apache.common.math and the other in clojure-contrib but which clearly states that it is quiet incomplete ... can anybody make a suggestion for a good alternative.. The one in

Re: complex number library

2010-12-13 Thread Konrad Hinsen
On 14 Dec 2010, at 04:22, Robert McIntyre wrote: It's not a protocol, but you may want to take a look at clojure.contrib.generic.arithmetic for inspiration. I wish you luck in your complex number implementation! I've done my own using clojure.contrib.generic and can post if it anyone's