update
This commit is contained in:
parent
1f1ad49427
commit
6f050a029e
2496 changed files with 37609 additions and 3031 deletions
|
|
@ -0,0 +1,7 @@
|
|||
matrixMul[m1_, m2_] := Table[Times @@ {a, b} // Tr, {a, m1}, {b, Transpose@m2}]
|
||||
matrixMul2[m1_, m2_] :=Table[Sum[Times @@ i, {i, Transpose@{a, b}}], {a, m1}, {b, Transpose@m2}]
|
||||
|
||||
a = {{1, 2}, {3, 4}, {5, 6}, {7, 8}};
|
||||
b = {{1, 2, 3}, {4, 5, 6}};
|
||||
matrixMul[a, b]
|
||||
matrixMul2[a, b]
|
||||
|
|
@ -1,4 +1,7 @@
|
|||
#lang racket
|
||||
(define (m-mult m1 m2)
|
||||
(for/list ([r m1])
|
||||
(for/list ([c (apply map list m2)])
|
||||
(apply + (map * r c)))))
|
||||
(m-mult '((1 2) (3 4)) '((5 6) (7 8)))
|
||||
;; -> '((19 22) (43 50))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
#lang racket
|
||||
(require math)
|
||||
(matrix* (matrix [[1 2]
|
||||
[3 4]])
|
||||
(matrix [[5 6]
|
||||
[7 8]]))
|
||||
(matrix* (matrix [[1 2] [3 4]]) (matrix [[5 6] [7 8]]))
|
||||
;; -> (array #[#[19 22] #[43 50]])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue