Public Vars

Back

double (clj)

(source)

function

(double x)
Coerce to double

Examples

mikera/core.matrix
(ns clojure.core.matrix.impl.ndarray-double
  (:refer-clojure :exclude [vector?])
  (:require [clojure.core.matrix.impl.defaults]
            [clojure.core.matrix.impl.ndarray-magic :as magic]
            [clojure.core.matrix.protocols :as mp]
            [clojure.core.matrix.implementations :as imp]
            [clojure.core.matrix.impl.mathsops :as mops]
            [clojure.walk :as w]
            [clojure.core.matrix.impl.ndarray :refer :all]
            [clojure.core.matrix.macros :refer :all]
            [clojure.core.matrix.macros-clj :refer :all]
            [clojure.core.matrix.impl.ndarray-macro :refer :all]))

(magic/spit-code :double)
hraberg/deuce
(ns deuce.emacs.process
  (:use [deuce.emacs-lisp :only (defun defvar) :as el])
  (:require [clojure.core :as c]
            [clojure.java.shell :as sh])
  (:refer-clojure :exclude []))

  :port PORT -- (mandatory) PORT is the path or name of the serial port.
  For example, this could be \"/dev/ttyS0\" on Unix.  On Windows, this
  could be \"COM1\", or \"\\\\.\\COM10\" for ports higher than COM9 (double
  the backslashes in strings).
hraberg/deuce
(ns deuce.emacs.floatfns
  (:use [deuce.emacs-lisp :only (defun defvar)])
  (:require [clojure.core :as c]
            [deuce.emacs.alloc :as alloc])
  (:refer-clojure :exclude [float]))

(defun ftruncate (arg)
  "Truncate a floating point number to an integral float value.
  Rounds the value toward zero."
  (double (long arg)))

(defun abs (arg)
  "Return the absolute value of ARG."
  (if (float? arg)
    (Math/abs (double arg))
    (Math/abs (long arg))))

(defun float (arg)
  "Return the floating point number equal to ARG."
  (double arg))

  Rounding a value equidistant between two integers may choose the
  integer closer to zero, or it may prefer an even integer, depending on
  your machine.  For example, (round 2.5) can return 3 on some
  systems, but 2 on others."
  (Math/round (/ arg (double (or divisor 1)))))

(defun ffloor (arg)
  "Return the largest integer no greater than ARG, as a float.
  (Round towards -inf.)"
  (double (long arg)))

(defun copysign (x1 x2)
  "Copy sign of X2 to value of X1, and return the result.
  Cause an error if X1 or X2 is not a float."
  (Math/copySign (double x1) (double x2)))

(defun fround (arg)
  "Return the nearest integer to ARG, as a float."
  (double (long arg)))

  The function returns the cons cell (SGNFCAND . EXP).
  If X is zero, both parts (SGNFCAND and EXP) are zero."
  (if (zero? x)
    (alloc/cons 0.0 0)
    (let [exp (inc (Math/getExponent (double x)))]
      (alloc/cons (/ x (Math/pow 2 exp)) exp))))

(defun logb (arg)
  "Returns largest integer <= the base 2 log of the magnitude of ARG.
  This is the same as the exponent of a float."
  (Math/getExponent (double arg)))
typedclojure/typedclojure
(ns ^:no-doc typed.ann.clojure
  "Type annotations for the base Clojure distribution."
  #?(:cljs (:require-macros [typed.ann-macros.clojure :as macros]))
  (:require [clojure.core :as cc]
            [typed.clojure :as t]
            #?(:clj [typed.ann-macros.clojure :as macros])
            #?(:clj typed.ann.clojure.jvm) ;; jvm annotations
            #?(:clj clojure.core.typed))
  #?(:clj
     (:import (clojure.lang PersistentHashSet PersistentList
                            APersistentMap #_IPersistentCollection
                            #_ITransientSet
                            IRef)
              (java.util Comparator Collection))))

cc/integer? (t/Pred t/AnyInteger)
cc/int? (t/Pred #?(:clj (t/U Long
                             Integer
                             Short
                             Byte)
                   :cljs (t/U t/CLJSInteger
                              goog.math.Integer
                              goog.math.Long)))
cc/pos-int? [t/Any :-> t/Bool
             :filters {:then (is #?(:clj (t/U Long
                                              Integer
                                              Short
                                              Byte)
                                    :cljs (t/U t/CLJSInteger
                                               goog.math.Integer
                                               goog.math.Long)) 0)}]
cc/neg-int? [t/Any :-> t/Bool
             :filters {:then (is #?(:clj (t/U Long
                                              Integer
                                              Short
                                              Byte)
                                    :cljs (t/U t/CLJSInteger
                                               goog.math.Integer
                                               goog.math.Long)) 0)}]
cc/nat-int? [t/Any :-> t/Bool
             :filters {:then (is #?(:clj (t/U Long
                                              Integer
                                              Short
                                              Byte)
                                    :cljs (t/U t/CLJSInteger
                                               goog.math.Integer
                                               goog.math.Long)) 0)}]
cc/number? (t/Pred t/Num)
cc/double? (t/Pred #?(:clj Double
                      :cljs t/Num))
cc/float? (t/Pred #?(:clj (t/U Double Float)
                     :cljs t/Num))
cc/ident? (t/Pred t/Ident)
cc/simple-ident? [t/Any :-> t/Bool :filters {:then (is t/Ident 0)}]
cc/qualified-ident? [t/Any :-> t/Bool :filters {:then (is t/Ident 0)}]
cc/simple-symbol? [t/Any :-> t/Bool :filters {:then (is t/Sym 0)}]
cc/qualified-symbol? [t/Any :-> t/Bool :filters {:then (is t/Sym 0)}]
cc/simple-keyword? [t/Any :-> t/Bool :filters {:then (is t/Kw 0)}]
cc/qualified-keyword? [t/Any :-> t/Bool :filters {:then (is t/Kw 0)}]
cc/var? (t/Pred t/AnyVar)

;coercions
#?@(:cljs [] :default [
cc/bigdec [(t/U t/Str t/Num) :-> BigDecimal]
cc/bigint [(t/U t/Str t/Num) :-> clojure.lang.BigInt]
cc/biginteger [(t/U t/Str t/Num) :-> java.math.BigInteger]
])
cc/boolean [t/Any :-> t/Bool]
cc/parse-boolean [t/Str :-> (t/Option t/Bool)]
cc/byte [(t/U Character t/Num) :-> Byte]
#?@(:cljs [
cc/char [(t/U t/Str t/Num) :-> t/Str]
] :default [
cc/char [(t/U Character t/Num) :-> Character]
])
cc/double [t/Num :-> #?(:cljs t/Num :default Double)]
cc/parse-double [t/Str :-> (t/Option #?(:cljs t/Num :default Double))]

;array ctors
#?@(:cljs [] :default [
cc/boolean-array (t/IFn [(t/U t/Num (t/Seqable t/Bool)) :-> (Array boolean)]
                        [t/Num (t/U t/Bool (t/Seqable t/Bool)) :-> (Array boolean)])
cc/byte-array (t/IFn [(t/U t/Num (t/Seqable Byte)) :-> (Array byte)]
                     [t/Num (t/U Byte (t/Seqable Byte)) :-> (Array byte)])
cc/char-array (t/IFn [(t/U t/Num (t/Seqable Character)) :-> (Array char)]
                     [t/Num (t/U t/Num (t/Seqable Character)) :-> (Array char)])
cc/short-array (t/IFn [(t/U t/Num (t/Seqable Short)) :-> (Array short)]
                      [t/Num (t/U Short (t/Seqable Short)) :-> (Array short)])
cc/int-array (t/IFn [(t/U t/Num (t/Seqable t/Num)) :-> (Array int)]
                    [t/Num (t/U t/Num (t/Seqable t/Num)) :-> (Array int)])
cc/double-array (t/IFn [(t/U t/Num (t/Seqable t/Num)) :-> (Array double)]
                       [t/Num (t/U t/Num (t/Seqable t/Num)) :-> (Array double)])
])

;cast to java array
;; TODO rethink input and output types. eg.,
;;      cc/booleans [(ReadyOnlyArray boolean) :-> (t/U nil (Array boolean))]
;; TODO objects??
;;      cc/objects [(ReadyOnlyArray Object) :-> (t/U nil (ReadyOnlyArray Object))]
;;                                  
;; TODO propagate to Numbers/booleans etc
;cc/booleans [t/Any :-> (t/U nil (Array boolean))]
;cc/bytes [t/Any :-> (t/U nil (Array byte))]
;cc/chars [t/Any :-> (t/U nil (Array char))]
;cc/shorts [t/Any :-> (t/U nil (Array short))]
;cc/ints [t/Any :-> (t/U nil (Array int))]
;cc/longs [t/Any :-> (t/U nil (Array long))]
;cc/floats [t/Any :-> (t/U nil (Array float))]
;cc/doubles [t/Any :-> (t/U nil (Array double))]
clojure-numerics/expresso
(ns numeric.expresso.types
  (:refer-clojure :exclude [== long double record?])
  (:use [clojure.test]
        [clojure.core.logic.protocols]
        [clojure.core.logic :exclude [is]])
  (:require 
   [clojure.set :as set]
   [clojure.core.matrix :as mat]
   [clojure.walk :as walk]))

(def matrix ::matrix)
(def number ::number)
(def integer ::integer)
(def long ::long)
(def double ::double)

(derive integer number)
(derive long number)
(derive double number)