1.2.3-SNAPSHOT permalink Arrow_down_16x16

combine-with

incanter.internal

  • (combine-with A B op fun)

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source incanter/internal.clj:65 top

(defmacro combine-with [A B op fun]
  `(cond
    (and (number? ~A) (number? ~B))
       (~op ~A ~B)
    (and (is-matrix ~A) (is-matrix ~B))
      (.assign ^Matrix (.copy ^Matrix ~A)
               ^Matrix ~B
               ^DoubleDoubleFunction (. DoubleFunctions ~fun))
    (and (is-matrix ~A) (number? ~B))
      (.assign ^Matrix (.copy ^Matrix ~A)
               (make-matrix ~B (.rows ~A) (.columns ~A))
               ^DoubleDoubleFunction (. DoubleFunctions ~fun))
    (and (number? ~A) (is-matrix ~B))
      (.assign ^Matrix (make-matrix ~A (.rows ~B) (.columns ~B))
               ^Matrix ~B
               ^DoubleDoubleFunction (. DoubleFunctions ~fun))
    (and (coll? ~A) (is-matrix ~B))
      (.assign ^Matrix (make-matrix ~A (.columns ~B))
               ^Matrix (make-matrix ~B)
               ^DoubleDoubleFunction (. DoubleFunctions ~fun))
    (and (is-matrix ~A) (coll? ~B))
      (.assign ^Matrix (.copy ~A)
               ^Matrix (make-matrix ~B)
               ^DoubleDoubleFunction (. DoubleFunctions ~fun))
    (and (coll? ~A) (coll? ~B) (coll? (first ~A)))
      (.assign (make-matrix ~A)
               (make-matrix ~B)
               (. DoubleFunctions ~fun))
    (and (coll? ~A) (number? ~B) (coll? (first ~A)))
      (.assign (make-matrix ~A)
               (make-matrix ~B)
               (. DoubleFunctions ~fun))
               ;;(. DoubleFunctions (~fun ~B)))
    (and (number? ~A) (coll? ~B) (coll? (first ~B)))
      (.assign (make-matrix ~A (.rows ~B) (.columns ~B))
               (make-matrix ~B)
               (. DoubleFunctions ~fun))
    (and (coll? ~A) (coll? ~B))
      (map ~op ~A ~B)
    (and (number? ~A) (coll? ~B))
      (map ~op (replicate (count ~B) ~A)  ~B)
    (and (coll? ~A) (number? ~B))
      (map ~op ~A (replicate (count ~A) ~B))
  ))
Vars in incanter.internal/combine-with: defmacro and apply coll? concat cond count first hash-map list map number? replicate seq with-meta
Used in 0 other vars

Comments top

No comments for combine-with. Log in to add a comment.