On Thu, Nov 26, 2009 at 11:49 AM, Amnon <amnon.hei...@gmail.com> wrote:

> I did, and it works like a charm. Couldn't figure out how to hint an
> array of objects (what should I put instead of the old #^objects?
> I still get it to work in 300 ms (which is not great but something I
> can live with).
>

You have to replace #^objects with #^"[Ljava.lang.Object;" (don't use a more
specialized type: it wouldn't help with aget/aset).



> Thanks for the replies,
>
> On Nov 25, 8:01 pm, David Nolen <dnolen.li...@gmail.com> wrote:
> > Read Christophe's post about multi-dim arrays. Reflection is getting in
> the
> > way here.
> >
> >
> >
> > On Wed, Nov 25, 2009 at 2:55 AM, Amnon <amnon.hei...@gmail.com> wrote:
> > > Hi Konrad,
> > > In the original post, I put in the code, it was removed by the post
> > > editor.
> > > The way I wanted it implement, I have the main in java (gui and
> > > stuff). I create a 3D array in java, it's an int array (i.e. int arr[]
> > > [][] ) and call with that array to clojure.
> >
> > > It can be done in java at least 3 orders of magnitude faster so I'm
> > > sure there is something I'm doing wrong.
> > > I'll appreciate any suggestion.
> > > Thanks,
> > > Amnon
> >
> > > I've squeezed my example into two functions:
> >
> > > (defn light [arr x y]
> > >        (+ (aget arr x y 0) (aget arr x y 1) (aget arr x y 2))
> > >        )
> >
> > > (defn grey [arr]
> > >        (dotimes [x (length arr)]
> > >                (dotimes [y (alength (aget  arr 0))]
> > >                        (let [lg (int (/ (light arr x y) 3))]
> > >                                (aset arr x y 0 lg)
> > >                                (aset arr x y 1 lg)
> > >                                (aset arr x y 2 lg)
> > >                        ))))
> >
> > > On Nov 24, 8:35 pm, Konrad Hinsen <konrad.hin...@fastmail.net> wrote:
> > > > On 24 Nov 2009, at 17:30, Amnon wrote:
> >
> > > > > I hope it's not the billion time you get the question.
> > > > > I wanted to use clojure for image processing. I have a 3
> dimensional
> > > > > array I'm passing to clojure from java.
> > > > > I then loop on the array to manipulate it.
> > > > > Even the simplest task takes about half a minutes (I expected it to
> be
> > > > > over in less than a second)
> >
> > > > Could you give some more details? For example, what is the Java class
> > > > you use for the 3D arrays? How are you accessing it from Clojure? How
> > > > do  you do the loops? How do you create the destination array, and
> how
> > > > do you fill it with the grey-scale values? I suspect that many of
> > > > these steps could be optimized, but it's hard to say without knowing
> > > > how your current code works.
> >
> > > > Konrad.
> >
> > > --
> > > 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<clojure%2bunsubscr...@googlegroups.com>
> <clojure%2bunsubscr...@googlegroups.com<clojure%252bunsubscr...@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<clojure%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>



-- 
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.cgrand.net/ (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

Reply via email to