1.2.3-SNAPSHOT Arrow_down_16x16

kronecker

incanter.core

  • (kronecker & args)
Returns the Kronecker product of the given arguments.

Examples:

(def x (matrix (range 6) 2))
(def y (matrix (range 4) 2))
(kronecker 4 x)
(kronecker x 4)
(kronecker x y)


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/core.clj:689 top

(defn kronecker
" Returns the Kronecker product of the given arguments.

  Examples:

    (def x (matrix (range 6) 2))
    (def y (matrix (range 4) 2))
    (kronecker 4 x)
    (kronecker x 4)
    (kronecker x y)


"
  ([& args]
    (reduce (fn [A B]
              (let [a (cond
                        (matrix? A) A
                        (number? A) (matrix [A])
                        :else (matrix A))
                    b (cond
                        (matrix? B) B
                        (number? B) (matrix [B])
                        :else (matrix B))
                    rows (* (nrow a) (nrow b))
                    cols (* (ncol a) (ncol b))]
                (apply bind-rows (for [i (range (nrow a))]
                             (apply bind-columns (for [j (range (ncol a))]
                                             (mult (sel a i j) b)))))))
            args)))
Vars in incanter.core/kronecker: apply defn fn for let reduce
Used in 0 other vars

Comments top

No comments for kronecker. Log in to add a comment.