clojure.math.numeric-tower

https://github.com/clojure/math.numeric-tower.git

git clone 'https://github.com/clojure/math.numeric-tower.git'

(ql:quickload :clojure.math.numeric-tower)
129

clojure.math.numeric-tower

Formerly clojure.contrib.math

Math functions that deal intelligently with the various types in Clojure's numeric tower, as well as math functions commonly found in Scheme implementations.

Functions included:

More documentation in docstrings.

Releases and Dependency Information

Latest stable release: 0.0.4

Leiningen dependency information:

[org.clojure/math.numeric-tower "0.0.4"]

Maven dependency information:

<dependency>
  <groupId>org.clojure</groupId>
  <artifactId>math.numeric-tower</artifactId>
  <version>0.0.4</version>
</dependency>

Example Usage

(ns example.core
  (:require [clojure.math.numeric-tower :as math]))

(defn- sqr
  "Uses the numeric tower expt to square a number"
  [x]
  (math/expt x 2))

(defn euclidean-squared-distance
  "Computes the Euclidean squared distance between two sequences"
  [a b]
  (reduce + (map (comp sqr -) a b)))

(defn euclidean-distance
  "Computes the Euclidean distance between two sequences"
  [a b]
  (math/sqrt (euclidean-squared-distance a b)))

(let [a [1 2 3 5 8 13 21]
      b [0 2 4 6 8 10 12]]
  (euclidean-distance a b))

;;=> 9.643650760992955

Refer to docstrings in the clojure.math.numeric-tower namespace for additional documentation.

API Documentation

Developer Information

Changelog

License

Distributed under the Eclipse Public License, the same as Clojure.