require and jtransforms

127 views
Skip to first unread message

Alan Forrester

unread,
Apr 30, 2014, 11:40:31 AM4/30/14
to clo...@googlegroups.com
I would like to try the JTransforms Java FFT library from Clojure:

https://sites.google.com/site/piotrwendykier/software/jtransforms

I created a new folder went to that folder in a console and typed

lein try net.sourceforge.jtransforms/jtransforms "2.4.0"

lein try retrieved some jars and poms from central, presumably
jtransforms and its dependencies and started a REPL.

Having got this far I can't seem to figure out how to require
jtransforms in the REPL. I have tried

(require '[x :as trans])

for various values of x such as
"net.sourceforge.jtransforms/jtransforms" and
"net.sourceforge.jtransforms.jtransforms", "jtransforms.jtransforms"
and the REPL keeps saying

FileNotFoundException Could not locate jtranforms__init.class or
jtransforms.clj on classpath: clojure.lang.RT.load (RT.java:443)

I think I must be misunderstanding how to download libraries and their
dependencies or how to require them when they have been downloaded.
Can anybody shed some light on this for me?

Thanks,
Alan

James Reeves

unread,
Apr 30, 2014, 12:39:37 PM4/30/14
to clo...@googlegroups.com
Java libraries are handled differently to native Clojure libraries. You can either enter the full class with packages, such as:

    (java.util.UUID/randomUUID)

Or you can use import to access the class without the package:

    (import 'java.util.UUID)
    (UUID/randomUUID)

To check you have access to the java library, try entering the following class name at the REPL:

    edu.emory.mathcs.jtransforms.fft.DoubleFFT_1D

If the library is loaded, this should return a class object, rather than erroring.

- James


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Leif

unread,
Apr 30, 2014, 12:43:27 PM4/30/14
to clo...@googlegroups.com, alanmichae...@googlemail.com
Hi, Alan.

'require' is only for clojure libs.  For Java packages, use 'import':

user=> (import '[edu.emory.mathcs.jtransforms.fft  DoubleFFT_1D])
edu.emory.mathcs.jtransforms.fft.DoubleFFT_1D
user=> (def da (double-array (range 0 10 0.01)))
#'user/da
user=> (def fft (DoubleFFT_1D. (count da)))
#'user/fft
user=> (.realForward fft da) ;; operates in-place
Reflection warning, /tmp/form-init1030205091778006036.clj:1:9 - call to realForward can't be resolved.
user=> (first da)
5004.999999999934

Also, as you may already be aware, the Maven coordinates and the Java package names are not necessarily the same or even similar.

--Leif
Reply all
Reply to author
Forward
0 new messages