(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))
))
Used in 0 other vars
Comments top
No comments for combine-with. Log in to add a comment.