Skip to content

Commit fe6878f

Browse files
committed
Add vDSP_mmulD
1 parent 9e7271b commit fe6878f

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The package is structured as follows:
3535
- `Sources/AccelerateLinux/MatrixOps`: Contains matrix operations:
3636
- `BasicOps` - Basic matrix operations:
3737
- [x] `vDSP_mtransD` - Transpose a matrix
38-
- [ ] `vDSP_mmulD` - Matrix multiplication
38+
- [x] `vDSP_mmulD` - Matrix multiplication
3939
- `LAPACK` - LAPACK functions:
4040
- [x] `dgesv_` - Solve a system of linear equations
4141
- [x] `dgesvd_` - Singular Value Decomposition

Sources/AccelerateLinux/MatrixOps/MatrixBasicOps.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ public func vDSP_mmulD(
5353
_ __N: vDSP_Length,
5454
_ __P: vDSP_Length
5555
) {
56-
56+
var a = __A
57+
for i in 0..<__M {
58+
var b = __B
59+
for _ in 0..<__P {
60+
var c = __C.advanced(by: Int(i) * __IC * Int(__N))
61+
for _ in 0..<__N {
62+
c.pointee += a.pointee * b.pointee
63+
b = b.advanced(by: __IB)
64+
c = c.advanced(by: __IC)
65+
}
66+
a = a.advanced(by: __IA)
67+
}
68+
}
5769
}
5870
#endif // canImport(Accelerate)

0 commit comments

Comments
 (0)