Function: calcFunc-kron

calcFunc-kron is an autoloaded and byte-compiled function defined in calc-vec.el.gz.

Signature

(calcFunc-kron X Y &optional NOCHECK)

Documentation

The Kronecker product of objects X and Y.

The objects X and Y may be scalars, vectors or matrices. The type of the result depends on the types of the operands; the product of two scalars is a scalar, of one scalar and a vector is a vector, of two vectors is a vector. of one vector and a matrix is a matrix, of two matrices is a matrix.

Source Code

;; Defined in /usr/src/emacs/lisp/calc/calc-vec.el.gz
;;; Compute a Kronecker product
(defun calcFunc-kron (x y &optional nocheck)
  "The Kronecker product of objects X and Y.
The objects X and Y may be scalars, vectors or matrices.
The type of the result depends on the types of the operands;
the product of two scalars is a scalar,
of one scalar and a vector is a vector,
of two vectors is a vector.
of one vector and a matrix is a matrix,
of two matrices is a matrix."
  (unless nocheck
    (cond ((or (math-matrixp x)
               (math-matrixp y))
           (unless (math-matrixp x)
             (setq x (if (math-vectorp x)
                         (list 'vec x)
                       (list 'vec (list 'vec x)))))
           (unless (math-matrixp y)
             (setq y (if (math-vectorp y)
                         (list 'vec y)
                       (list 'vec (list 'vec y))))))
          ((or (math-vectorp x)
               (math-vectorp y))
           (unless (math-vectorp x)
             (setq x (list 'vec x)))
           (unless (math-vectorp y)
             (setq y (list 'vec y))))))
  (if (math-vectorp x)
      (let (ret)
        (dolist (v (cdr x))
          (dolist (w (cdr y))
            (setq ret (cons (calcFunc-kron v w t) ret))))
        (cons 'vec (nreverse ret)))
    (math-mul x y)))