Public Vars

Back

max (clj)

(source)

function

(max x) (max x y) (max x y & more)
Returns the greatest of the nums.

Examples

originrose/cortex
(ns cortex.nn.impl
  "Implementation helpers to aid implementing neural network cortex protocols
or specific neural network layers"
  (:require [cortex.nn.layers :as layers]
            [clojure.core.matrix.macros :refer [c-for]]))


(defmacro convolution-outer-kernel
  [conv-desc & body]
  `(let [~'conv-desc ~conv-desc
         ~'output-width (long (:output-width ~'conv-desc))
         ~'output-height (long (:output-height ~'conv-desc))
         ~'num-in-channels (long (:input-channels ~'conv-desc))
         ~'num-out-channels (long (:output-channels ~'conv-desc))
         ~'input-width (long (:input-width ~'conv-desc))
         ~'input-height (long (:input-height ~'conv-desc))
         ~'input-planar-stride (* ~'input-width ~'input-height)
         ~'output-planar-stride (* ~'output-width ~'output-height)
         ~'kernel-width (long (:kernel-width ~'conv-desc))
         ~'kernel-height (long (:kernel-height ~'conv-desc))
         ~'output-channel-stride (* ~'kernel-width ~'kernel-height)
         ~'output-column-stride (* ~'output-channel-stride ~'num-in-channels)
         ~'stride-y (long (:stride-y ~'conv-desc))
         ~'stride-x (long (:stride-x ~'conv-desc))
         ~'pad-x (long (:pad-x ~'conv-desc))
         ~'pad-y (long (:pad-y ~'conv-desc))
         ~'min-x (- 0 ~'pad-x)
         ~'min-y (- 0 ~'pad-y)
         ~'max-x (+ ~'input-width ~'pad-x)
         ~'max-y (+ ~'input-height ~'pad-y)
         ~'kernel-num-elems (* ~'kernel-width ~'kernel-height)]
     (c-for
      [~'chan 0 (< ~'chan ~'num-in-channels) (inc ~'chan)]
      (let [~'chan-input-offset (* ~'chan ~'input-planar-stride)
            ~'chan-output-offset (* ~'chan ~'output-planar-stride)]
        (c-for
         [~'out-y 0 (< ~'out-y ~'output-height) (inc ~'out-y)]
         (let [~'input-rel-y (- (* ~'out-y ~'stride-y) ~'pad-y)]
           (c-for
            [~'out-x 0 (< ~'out-x ~'output-width) (inc ~'out-x)]
            (let [~'input-rel-x (- (* ~'out-x ~'stride-x) ~'pad-x)]
              ~@body))))))))


(defmacro in-bounds?
  "is value within the range of [min-val, max-val)"
  [value min-val max-val]
  `(and (>= ~value ~min-val)
        (< ~value ~max-val)))


(defmacro convolution-roll-unroll-inner-kernel
  [& body]
  `(let [~'chan-conv-offset (* ~'chan ~'output-channel-stride)
         ~'output-offset (+ (* ~'out-y ~'output-width)
                            ~'out-x)
         ;;positive values for how far out we are into the padding
         input-over-x# (max 0 (- (+ ~'input-rel-x ~'kernel-width)
                                 ~'input-width))
         input-over-y# (max 0 (- (+ ~'input-rel-y ~'kernel-height)
                                 ~'input-height))
         ;;Negative values for how far before the 0 idx we are.
         input-under-x# (min ~'input-rel-x 0)
         input-under-y# (min ~'input-rel-y 0)
         ;;Width of the kernel excluding padding
         ~'exc-pad-width (max 0 (+ (- ~'kernel-width input-over-x#)
                                   input-under-x#))
         ~'exc-pad-height (max 0 (+ (- ~'kernel-height input-over-y#)
                                    input-under-y#))
         ~'exc-pad-kernel-num-elems (* ~'exc-pad-width ~'exc-pad-height)]
     (c-for
      [~'k-y 0 (< ~'k-y ~'kernel-height) (inc ~'k-y)]
      (c-for
       [~'k-x 0 (< ~'k-x ~'kernel-width) (inc ~'k-x)]
       (let [~'input-x (+ ~'input-rel-x ~'k-x)
             ~'input-y (+ ~'input-rel-y ~'k-y)
             ~'output-conv-addr (+ (* ~'output-offset
                                      ~'output-column-stride)
                                   ~'chan-conv-offset
                                   (* ~'k-y ~'kernel-width)
                                   ~'k-x)
             ~'input-addr  (+ (* ~'input-y ~'input-width)
                              ~'input-x
                              ~'chan-input-offset)
             ~'input-valid? (and (in-bounds? ~'input-x 0 ~'input-width)
                                 (in-bounds? ~'input-y 0 ~'input-height))
             loop-valid?# (and (in-bounds? ~'input-x ~'min-x ~'max-x)
                               (in-bounds? ~'input-y ~'min-y ~'max-y))]
         (when loop-valid?#
           ~@body))))))
hraberg/deuce
(ns deuce.emacs.character
  (:use [deuce.emacs-lisp :only (defun defvar)])
  (:require [clojure.core :as c])
  (:refer-clojure :exclude []))

(declare max-char)

(defun characterp (object)
  "Return non-nil if OBJECT is a character."
  (and ((some-fn integer? char?) object) (pos? (int object)) (<= (int object) (max-char))))

(defun max-char ()
  "Return the character of the maximum code."
  ;;0x3FFFFF in Emacs.
  (int Character/MAX_VALUE))
hraberg/deuce
(ns deuce.emacs.print
  (:use [deuce.emacs-lisp :only (defun defvar)])
  (:require [clojure.core :as c]
            [clojure.string :as s]
            [deuce.emacs.buffer :as buffer]
            [deuce.emacs.data :as data]
            [deuce.emacs.editfns :as editfns]
            [deuce.emacs.fns :as fns])
  (:refer-clojure :exclude [print]))

(defvar print-circle nil
  "*Non-nil means print recursive structures using #N= and #N# syntax.
  If nil, printing proceeds recursively and may lead to
  `max-lisp-eval-depth' being exceeded or an error may occur:
  \"Apparently circular structure being printed.\"  Also see
  `print-length' and `print-level'.
  If non-nil, shared substructures anywhere in the structure are printed
  with `#N=' before the first occurrence (in the order of the print
  representation) and `#N#' in place of each subsequent occurrence,
  where N is a positive decimal integer.")
hraberg/deuce
(ns deuce.emacs.textprop
  (:use [deuce.emacs-lisp :only (defun defvar)])
  (:require [clojure.core :as c])
  (:refer-clojure :exclude []))

(defun next-char-property-change (position &optional limit)
  "Return the position of next text property or overlay change.
  This scans characters forward in the current buffer from POSITION till
  it finds a change in some text property, or the beginning or end of an
  overlay, and returns the position of that.
  If none is found up to (point-max), the function returns (point-max).

  If the optional second argument LIMIT is non-nil, don't search
  past position LIMIT; return LIMIT if nothing is found before LIMIT.
  LIMIT is a no-op if it is greater than (point-max)."
  )

  In a string, scan runs to the end of the string.
  In a buffer, it runs to (point-max), and the value cannot exceed that.
fluree/db
(ns json-ld.shacl
  (:require [fluree.db.method.ipfs.core :as ipfs]
            [fluree.db.db.json-ld :as jld-db]
            [fluree.db.json-ld.transact :as jld-tx]
            [clojure.core.async :as async]
            [fluree.db.flake :as flake]
            [fluree.db.json-ld.api :as fluree]
            [fluree.db.util.async :refer [<?? go-try channel?]]
            [fluree.db.query.range :as query-range]
            [fluree.db.constants :as const]
            [fluree.db.dbproto :as dbproto]
            [fluree.db.did :as did]
            [fluree.db.conn.proto :as conn-proto]
            [fluree.db.util.json :as json]
            [fluree.json-ld :as json-ld]
            [fluree.db.indexer.default :as indexer]
            [fluree.db.indexer.proto :as idx-proto]
            [fluree.db.util.log :as log]
            [fluree.db.index :as index]
            [criterium.core :as criterium]
            [clojure.tools.reader.edn :as edn]))

  (def ledger @(fluree/create ipfs-conn "shacl/mytest" {}))
  (def db @(fluree/stage
             ledger
             {:context              {:ex "http://example.org/ns/"}
              :id                   :ex/UserShape,
              :type                 [:sh/NodeShape],
              :sh/targetClass       :ex/User
              :sh/property          [{:sh/path     :schema/name
                                      :sh/minCount 1
                                      :sh/maxCount 1
                                      :sh/datatype :xsd/string}]
              :sh/ignoredProperties [:type]
              :sh/closed            true}))

  (def ipfs-conn @(fluree/connect-ipfs
                    {:server   nil                          ;; use default
                     ;; ledger defaults used for newly created ledgers
                     :defaults {:ipns    {:key "self"}      ;; publish to ipns by default using the provided key/profile
                                :indexer {:reindex-min-bytes 9000
                                          :reindex-max-bytes 10000000}
                                :context {:id     "@id"
                                          :type   "@type"
                                          :xsd    "http://www.w3.org/2001/XMLSchema#"
                                          :schema "http://schema.org/"
                                          :sh     "http://www.w3.org/ns/shacl#"
                                          :rdf    "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
                                          :rdfs   "http://www.w3.org/2000/01/rdf-schema#"
                                          :wiki   "https://www.wikidata.org/wiki/"
                                          :skos   "http://www.w3.org/2008/05/skos#"
                                          :f      "https://ns.flur.ee/ledger#"}
                                :did     (did/private->did-map "8ce4eca704d653dec594703c81a84c403c39f262e54ed014ed857438933a2e1c")}}))

  (def newdb2
    @(fluree/stage
       newdb
       {:id                   :ex/UserShape,
        :type                 [:sh/NodeShape],
        :sh/targetClass       :ex/User
        :sh/property          [{:sh/path     :schema/name
                                :sh/minCount 1
                                :sh/maxCount 1
                                :sh/datatype :xsd/string}
                               {:sh/path     :schema/ssn
                                :sh/datatype :xsd/string
                                :sh/maxCount 1
                                :sh/pattern  "^\\d{3}-\\d{2}-\\d{4}$"}
                               {:sh/path     :schema/email
                                :sh/minCount 1
                                :sh/maxCount 1
                                :sh/nodeKind :sh/IRI}]
        :sh/ignoredProperties [:type :schema/author]
        :sh/closed            true}))