• incanter

# mmult

## incanter.core

• (mmult & args)
Returns the matrix resulting from the matrix multiplication of the
the given arguments. Equivalent to R's %*% operator.

Examples:

(def A (matrix [[1 2 3]
[4 5 6]
[7 8 9]]))
(mmult A (trans A))
(mmult A (trans A) A)

References:
http://en.wikipedia.org/wiki/Matrix_multiplication
http://incanter.org/docs/parallelcolt/api/cern/colt/matrix/tdouble/DoubleMatrix2D.html

### Source incanter/core.clj:661 top

```(defn mmult
" Returns the matrix resulting from the matrix multiplication of the
the given arguments. Equivalent to R's %*% operator.

Examples:

(def A (matrix [[1 2 3]
[4 5 6]
[7 8 9]]))
(mmult A (trans A))
(mmult A (trans A) A)

References:
http://en.wikipedia.org/wiki/Matrix_multiplication
http://incanter.org/docs/parallelcolt/api/cern/colt/matrix/tdouble/DoubleMatrix2D.html

"
([& args]
(reduce (fn [A B]
(let [a (if (matrix? A) A (matrix A))
b (if (matrix? B) B (matrix B))
result (Matrix. (.zMult ^Matrix a ^Matrix b nil))]
(if (and (= (.rows result) 1) (= (.columns result) 1))
(.getQuick result 0 0)
result)))
args)))```
Vars in incanter.core/mmult: = and defn fn let reduce
Used in 0 other vars