Re: Nasty java interop problem -- ideas?

2011-08-12 Thread Oskar Kvist
Oh yes, of course. Why didn't I think of that? For some reason,
implementing 2 interfaces never occurred to me. :P

On Aug 12, 4:48 pm, David Powell  wrote:
> > The simplest so far seems to be to use gen-interface to create a
> > subinterface of Controller with all the methods I need, or gen-class.
> > But that would require AOT compilation. Can I get away without it?
>
> Can you use definterface to create an interface with your methods on, and
> then deftype or reify to implement the methods from the Controller type, and
> from your custom interface.
>
> --
> Dave

-- 
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


Re: Nasty java interop problem -- ideas?

2011-08-12 Thread David Powell
>
>
> The simplest so far seems to be to use gen-interface to create a
> subinterface of Controller with all the methods I need, or gen-class.
> But that would require AOT compilation. Can I get away without it?
>

Can you use definterface to create an interface with your methods on, and
then deftype or reify to implement the methods from the Controller type, and
from your custom interface.

-- 
Dave

-- 
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

Nasty java interop problem -- ideas?

2011-08-12 Thread Oskar Kvist
Hi!

I have the following problem. I'm using a Java lib for making GUIs.
One lays out the GUI in XML, then uses a Controller (Listener type
thing) to do stuff. For example, in the XML one might have
onClick="doSomething()". And then reflection is used to find the
method of the controller instance.

But doSomething() is not a method of the interface Controller. The
Controller interface only declares a few very basic methods. So, I
need to pass an object to the GUI that implements Controller, but also
has additional methods.

With proxy, I learend recently, I can not define additional methods,
outside the interface.

What is the most painless way to create an object that implements a
specific interace, but also has additional methods?

The simplest so far seems to be to use gen-interface to create a
subinterface of Controller with all the methods I need, or gen-class.
But that would require AOT compilation. Can I get away without it?

-- 
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


Re: java interop problem

2010-09-14 Thread Alan
Also, if you want the behavior you describe, it's easy to get it in
the current approach, whereas if the REPL didn't consume lazy
sequences it would be very hard to get it to. Try:

(def myvar (filter even? (range))) ; prints the Var object
(nth myvar 1) ; realizes the first 10,000 items in the seq
;; evaluating just myvar causes the REPL to realize the whole seq

On Sep 14, 9:33 am, Alan  wrote:
> That would be very awkward:
>
> user=> (-> (range) (filter even?) (drop 10) (take 5))
> LazySeq
> user=> (-> (range) (filter even?) (drop 10) (take 5) first)
> 20
> user=> (-> (range) (filter even?) (drop 10) (take 5) second)
> 22
> ...
>
> On Sep 14, 5:20 am, Ranjit  wrote:
>
> > Thanks for clearing that up for me everyone. So the REPL itself acts
> > like a consumer of lazy sequences? Is there some logic behind that? I
> > guess I would have expected that the REPL would just return a
> > reference to a lazy expression rather than evaluate it.
>
> > Thanks,
>
> > -Ranjit
>
> > On Sep 13, 2:06 pm, Alan  wrote:
>
> > > Ranjit, try the following to see it in action even at the REPL:
>
> > > (def xt (make-array Float/TYPE 3 3))
>
> > > (def myloop (for [x (range 3) y (range 3)] (aset xt x y 1)))
>
> > > (aget xt 1 1) ;; xt hasn't been changed
>
> > > myloop ;; force REPL to de-lazify
>
> > > (aget xt 1 1) ;; changed now
>
> > > On Sep 13, 9:28 am, Mark Nutter  wrote:
>
> > > > Erg, gmail hiccup. Started to say if you try to use it in code that's
> > > > *not* being called from the REPL, you'll be scratching your head
> > > > trying to figure out why aset never gets called.
>
> > > > Mark
>
> > > > On Mon, Sep 13, 2010 at 12:27 PM, Mark Nutter  
> > > > wrote:
> > > > > The REPL automatically realizes the lazy sequence in the process of
> > > > > printing it out, but if you try to us
>
> > > > > On Mon, Sep 13, 2010 at 11:07 AM, Ranjit  wrote:
> > > > >> Thanks Armando for catching my stupid mistake. That fixed everything.
>
> > > > >> Meikel, I'm not sure I understand what you're saying. When I evaluate
> > > > >> this in the REPL
>
> > > > >> (for [x (range 2) y (range 2)] (aset xt x y (+ x y)))
> > > > >> (aget xt 0 0)
> > > > >> (aget xt 1 1)
>
> > > > >> I get back 0 and 2 as I expect. Isn't the call to aset consuming the
> > > > >> lazy sequence?
>
> > > > >> Thanks.
>
> > > > >> On Sep 13, 11:00 am, Meikel Brandmeyer  wrote:
> > > > >>> Hi,
>
> > > > >>> On 13 Sep., 15:07, Ranjit Chacko  wrote:
>
> > > > >>> >     (for [x (range 3) y (range 3)] (aset xt x y 1))
>
> > > > >>> Note that that this will not do what you think it does. for creates 
> > > > >>> a
> > > > >>> lazy sequence which is thrown away immediately. So the aset calls 
> > > > >>> are
> > > > >>> never done. for is a list comprehension, not a looping construct.
> > > > >>> Replace for with doseq. As a rule of thumb: side-effects => command
> > > > >>> starting in "do".
>
> > > > >>> Sincerely
> > > > >>> Meikel
>
> > > > >> --
> > > > >> 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 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


Re: java interop problem

2010-09-14 Thread Alan
That would be very awkward:

user=> (-> (range) (filter even?) (drop 10) (take 5))
LazySeq
user=> (-> (range) (filter even?) (drop 10) (take 5) first)
20
user=> (-> (range) (filter even?) (drop 10) (take 5) second)
22
...

On Sep 14, 5:20 am, Ranjit  wrote:
> Thanks for clearing that up for me everyone. So the REPL itself acts
> like a consumer of lazy sequences? Is there some logic behind that? I
> guess I would have expected that the REPL would just return a
> reference to a lazy expression rather than evaluate it.
>
> Thanks,
>
> -Ranjit
>
> On Sep 13, 2:06 pm, Alan  wrote:
>
> > Ranjit, try the following to see it in action even at the REPL:
>
> > (def xt (make-array Float/TYPE 3 3))
>
> > (def myloop (for [x (range 3) y (range 3)] (aset xt x y 1)))
>
> > (aget xt 1 1) ;; xt hasn't been changed
>
> > myloop ;; force REPL to de-lazify
>
> > (aget xt 1 1) ;; changed now
>
> > On Sep 13, 9:28 am, Mark Nutter  wrote:
>
> > > Erg, gmail hiccup. Started to say if you try to use it in code that's
> > > *not* being called from the REPL, you'll be scratching your head
> > > trying to figure out why aset never gets called.
>
> > > Mark
>
> > > On Mon, Sep 13, 2010 at 12:27 PM, Mark Nutter  
> > > wrote:
> > > > The REPL automatically realizes the lazy sequence in the process of
> > > > printing it out, but if you try to us
>
> > > > On Mon, Sep 13, 2010 at 11:07 AM, Ranjit  wrote:
> > > >> Thanks Armando for catching my stupid mistake. That fixed everything.
>
> > > >> Meikel, I'm not sure I understand what you're saying. When I evaluate
> > > >> this in the REPL
>
> > > >> (for [x (range 2) y (range 2)] (aset xt x y (+ x y)))
> > > >> (aget xt 0 0)
> > > >> (aget xt 1 1)
>
> > > >> I get back 0 and 2 as I expect. Isn't the call to aset consuming the
> > > >> lazy sequence?
>
> > > >> Thanks.
>
> > > >> On Sep 13, 11:00 am, Meikel Brandmeyer  wrote:
> > > >>> Hi,
>
> > > >>> On 13 Sep., 15:07, Ranjit Chacko  wrote:
>
> > > >>> >     (for [x (range 3) y (range 3)] (aset xt x y 1))
>
> > > >>> Note that that this will not do what you think it does. for creates a
> > > >>> lazy sequence which is thrown away immediately. So the aset calls are
> > > >>> never done. for is a list comprehension, not a looping construct.
> > > >>> Replace for with doseq. As a rule of thumb: side-effects => command
> > > >>> starting in "do".
>
> > > >>> Sincerely
> > > >>> Meikel
>
> > > >> --
> > > >> 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 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


Re: java interop problem

2010-09-14 Thread Ranjit
Thanks for clearing that up for me everyone. So the REPL itself acts
like a consumer of lazy sequences? Is there some logic behind that? I
guess I would have expected that the REPL would just return a
reference to a lazy expression rather than evaluate it.

Thanks,

-Ranjit


On Sep 13, 2:06 pm, Alan  wrote:
> Ranjit, try the following to see it in action even at the REPL:
>
> (def xt (make-array Float/TYPE 3 3))
>
> (def myloop (for [x (range 3) y (range 3)] (aset xt x y 1)))
>
> (aget xt 1 1) ;; xt hasn't been changed
>
> myloop ;; force REPL to de-lazify
>
> (aget xt 1 1) ;; changed now
>
> On Sep 13, 9:28 am, Mark Nutter  wrote:
>
> > Erg, gmail hiccup. Started to say if you try to use it in code that's
> > *not* being called from the REPL, you'll be scratching your head
> > trying to figure out why aset never gets called.
>
> > Mark
>
> > On Mon, Sep 13, 2010 at 12:27 PM, Mark Nutter  wrote:
> > > The REPL automatically realizes the lazy sequence in the process of
> > > printing it out, but if you try to us
>
> > > On Mon, Sep 13, 2010 at 11:07 AM, Ranjit  wrote:
> > >> Thanks Armando for catching my stupid mistake. That fixed everything.
>
> > >> Meikel, I'm not sure I understand what you're saying. When I evaluate
> > >> this in the REPL
>
> > >> (for [x (range 2) y (range 2)] (aset xt x y (+ x y)))
> > >> (aget xt 0 0)
> > >> (aget xt 1 1)
>
> > >> I get back 0 and 2 as I expect. Isn't the call to aset consuming the
> > >> lazy sequence?
>
> > >> Thanks.
>
> > >> On Sep 13, 11:00 am, Meikel Brandmeyer  wrote:
> > >>> Hi,
>
> > >>> On 13 Sep., 15:07, Ranjit Chacko  wrote:
>
> > >>> >     (for [x (range 3) y (range 3)] (aset xt x y 1))
>
> > >>> Note that that this will not do what you think it does. for creates a
> > >>> lazy sequence which is thrown away immediately. So the aset calls are
> > >>> never done. for is a list comprehension, not a looping construct.
> > >>> Replace for with doseq. As a rule of thumb: side-effects => command
> > >>> starting in "do".
>
> > >>> Sincerely
> > >>> Meikel
>
> > >> --
> > >> 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 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


Re: java interop problem

2010-09-13 Thread Alan
Ranjit, try the following to see it in action even at the REPL:

(def xt (make-array Float/TYPE 3 3))

(def myloop (for [x (range 3) y (range 3)] (aset xt x y 1)))

(aget xt 1 1) ;; xt hasn't been changed

myloop ;; force REPL to de-lazify

(aget xt 1 1) ;; changed now

On Sep 13, 9:28 am, Mark Nutter  wrote:
> Erg, gmail hiccup. Started to say if you try to use it in code that's
> *not* being called from the REPL, you'll be scratching your head
> trying to figure out why aset never gets called.
>
> Mark
>
> On Mon, Sep 13, 2010 at 12:27 PM, Mark Nutter  wrote:
> > The REPL automatically realizes the lazy sequence in the process of
> > printing it out, but if you try to us
>
> > On Mon, Sep 13, 2010 at 11:07 AM, Ranjit  wrote:
> >> Thanks Armando for catching my stupid mistake. That fixed everything.
>
> >> Meikel, I'm not sure I understand what you're saying. When I evaluate
> >> this in the REPL
>
> >> (for [x (range 2) y (range 2)] (aset xt x y (+ x y)))
> >> (aget xt 0 0)
> >> (aget xt 1 1)
>
> >> I get back 0 and 2 as I expect. Isn't the call to aset consuming the
> >> lazy sequence?
>
> >> Thanks.
>
> >> On Sep 13, 11:00 am, Meikel Brandmeyer  wrote:
> >>> Hi,
>
> >>> On 13 Sep., 15:07, Ranjit Chacko  wrote:
>
> >>> >     (for [x (range 3) y (range 3)] (aset xt x y 1))
>
> >>> Note that that this will not do what you think it does. for creates a
> >>> lazy sequence which is thrown away immediately. So the aset calls are
> >>> never done. for is a list comprehension, not a looping construct.
> >>> Replace for with doseq. As a rule of thumb: side-effects => command
> >>> starting in "do".
>
> >>> Sincerely
> >>> Meikel
>
> >> --
> >> 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 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


Re: java interop problem

2010-09-13 Thread Mark Nutter
Erg, gmail hiccup. Started to say if you try to use it in code that's
*not* being called from the REPL, you'll be scratching your head
trying to figure out why aset never gets called.

Mark

On Mon, Sep 13, 2010 at 12:27 PM, Mark Nutter  wrote:
> The REPL automatically realizes the lazy sequence in the process of
> printing it out, but if you try to us
>
> On Mon, Sep 13, 2010 at 11:07 AM, Ranjit  wrote:
>> Thanks Armando for catching my stupid mistake. That fixed everything.
>>
>> Meikel, I'm not sure I understand what you're saying. When I evaluate
>> this in the REPL
>>
>> (for [x (range 2) y (range 2)] (aset xt x y (+ x y)))
>> (aget xt 0 0)
>> (aget xt 1 1)
>>
>> I get back 0 and 2 as I expect. Isn't the call to aset consuming the
>> lazy sequence?
>>
>> Thanks.
>>
>> On Sep 13, 11:00 am, Meikel Brandmeyer  wrote:
>>> Hi,
>>>
>>> On 13 Sep., 15:07, Ranjit Chacko  wrote:
>>>
>>> >     (for [x (range 3) y (range 3)] (aset xt x y 1))
>>>
>>> Note that that this will not do what you think it does. for creates a
>>> lazy sequence which is thrown away immediately. So the aset calls are
>>> never done. for is a list comprehension, not a looping construct.
>>> Replace for with doseq. As a rule of thumb: side-effects => command
>>> starting in "do".
>>>
>>> Sincerely
>>> Meikel
>>
>> --
>> 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 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


Re: java interop problem

2010-09-13 Thread Mark Nutter
The REPL automatically realizes the lazy sequence in the process of
printing it out, but if you try to us

On Mon, Sep 13, 2010 at 11:07 AM, Ranjit  wrote:
> Thanks Armando for catching my stupid mistake. That fixed everything.
>
> Meikel, I'm not sure I understand what you're saying. When I evaluate
> this in the REPL
>
> (for [x (range 2) y (range 2)] (aset xt x y (+ x y)))
> (aget xt 0 0)
> (aget xt 1 1)
>
> I get back 0 and 2 as I expect. Isn't the call to aset consuming the
> lazy sequence?
>
> Thanks.
>
> On Sep 13, 11:00 am, Meikel Brandmeyer  wrote:
>> Hi,
>>
>> On 13 Sep., 15:07, Ranjit Chacko  wrote:
>>
>> >     (for [x (range 3) y (range 3)] (aset xt x y 1))
>>
>> Note that that this will not do what you think it does. for creates a
>> lazy sequence which is thrown away immediately. So the aset calls are
>> never done. for is a list comprehension, not a looping construct.
>> Replace for with doseq. As a rule of thumb: side-effects => command
>> starting in "do".
>>
>> Sincerely
>> Meikel
>
> --
> 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 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


Re: java interop problem

2010-09-13 Thread Ranjit
Thanks Armando for catching my stupid mistake. That fixed everything.

Meikel, I'm not sure I understand what you're saying. When I evaluate
this in the REPL

(for [x (range 2) y (range 2)] (aset xt x y (+ x y)))
(aget xt 0 0)
(aget xt 1 1)

I get back 0 and 2 as I expect. Isn't the call to aset consuming the
lazy sequence?

Thanks.

On Sep 13, 11:00 am, Meikel Brandmeyer  wrote:
> Hi,
>
> On 13 Sep., 15:07, Ranjit Chacko  wrote:
>
> >     (for [x (range 3) y (range 3)] (aset xt x y 1))
>
> Note that that this will not do what you think it does. for creates a
> lazy sequence which is thrown away immediately. So the aset calls are
> never done. for is a list comprehension, not a looping construct.
> Replace for with doseq. As a rule of thumb: side-effects => command
> starting in "do".
>
> Sincerely
> Meikel

-- 
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


Re: java interop problem

2010-09-13 Thread Meikel Brandmeyer
Hi,

On 13 Sep., 15:07, Ranjit Chacko  wrote:

>     (for [x (range 3) y (range 3)] (aset xt x y 1))

Note that that this will not do what you think it does. for creates a
lazy sequence which is thrown away immediately. So the aset calls are
never done. for is a list comprehension, not a looping construct.
Replace for with doseq. As a rule of thumb: side-effects => command
starting in "do".

Sincerely
Meikel

-- 
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


Re: java interop problem

2010-09-13 Thread Armando Blancas
Looks like you need a Float/TYPE instead of Double/TYPE.

On Sep 13, 6:07 am, Ranjit Chacko  wrote:
>   I'm having a problem with java interop using one of the libraries in
> the Incanter package.
>
> When I run the following code:
>
>     (use '(incanter core charts))
>     (import (edu.emory.mathcs.jtransforms.fft FloatFFT_2D))
>     (def xt (make-array Double/TYPE 3 3 ))
>     (for [x (range 3) y (range 3)] (aset xt x y 1))
>     (.realForward (FloatFFT_2D. 3 3) xt)
>
> I get this error:
>
>     java.lang.IllegalArgumentException: No matching method found:
>     realForward for class edu.emory.mathcs.jtransforms.fft.FloatFFT_2D
>
> That code is calling this 
> method:http://incanter.org/docs/parallelcolt/api/edu/emory/mathcs/jtransform...[][]%29
>
> But if I do the same thing but call this method instead which takes a 1d
> array as an argument instead it 
> works:http://incanter.org/docs/parallelcolt/api/edu/emory/mathcs/jtransform...[]%29
>
> I'm pretty new to Clojure so I'm not sure what's going on here, but I
> guess this has something to do with reflection? Is this going to be a
> general problem with passing multidimensional arrays to Java methods
> from Clojure?
>
> Thanks,
>
> -Ranjit

-- 
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


java interop problem

2010-09-13 Thread Ranjit Chacko
 I'm having a problem with java interop using one of the libraries in 
the Incanter package.


When I run the following code:

   (use '(incanter core charts))
   (import (edu.emory.mathcs.jtransforms.fft FloatFFT_2D))
   (def xt (make-array Double/TYPE 3 3 ))
   (for [x (range 3) y (range 3)] (aset xt x y 1))
   (.realForward (FloatFFT_2D. 3 3) xt)

I get this error:

   java.lang.IllegalArgumentException: No matching method found: 
   realForward for class edu.emory.mathcs.jtransforms.fft.FloatFFT_2D


That code is calling this method:
http://incanter.org/docs/parallelcolt/api/edu/emory/mathcs/jtransforms/fft/FloatFFT_2D.html#realForward%28float[][]%29

But if I do the same thing but call this method instead which takes a 1d 
array as an argument instead it works:

http://incanter.org/docs/parallelcolt/api/edu/emory/mathcs/jtransforms/fft/FloatFFT_2D.html#realForward%28float[]%29

I'm pretty new to Clojure so I'm not sure what's going on here, but I 
guess this has something to do with reflection? Is this going to be a 
general problem with passing multidimensional arrays to Java methods 
from Clojure?


Thanks,

-Ranjit

--
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