@@ -18,7 +18,9 @@ public extension Array where Element == Float {
1818 " \( offset) == 0 || ( \( offset) >= 0 && \( offset) < \( count) ) " )
1919 assert ( n >= 0 && n <= count - offset, " \( n) >= 0 && \( n) <= \( count) - \( offset) " )
2020 assert ( incX >= 1 , " \( incX) >= 1 " )
21- cblas_sscal ( n, alpha, & self + offset, incX)
21+ withUnsafeMutableBufferPointer {
22+ cblas_sscal ( n, alpha, $0. baseAddress! + offset, incX)
23+ }
2224 }
2325
2426 /// Modifies a vector in place, setting each element to a given value.
@@ -40,7 +42,9 @@ public extension Array where Element == Float {
4042 " \( offset) == 0 || ( \( offset) >= 0 && \( offset) < \( count) ) " )
4143 assert ( n >= 0 && n / incX <= count - offset, " \( n) >= 0 && \( n) / \( incX) <= \( count) - \( offset) " )
4244 assert ( incX >= 1 , " \( incX) >= 1 " )
43- catlas_sset ( n, alpha, & self + offset, incX)
45+ withUnsafeMutableBufferPointer {
46+ catlas_sset ( n, alpha, $0. baseAddress! + offset, incX)
47+ }
4448 }
4549
4650 /// Computes the sum of two vectors, scaling each one separately (single-precision).
@@ -75,7 +79,11 @@ public extension Array where Element == Float {
7579 assert ( n >= 0 && n / incY <= y. count - offsetY, " \( n) >= 0 && \( n) / \( incY) <= \( y. count) - \( offsetY) " )
7680 assert ( incX >= 1 , " \( incX) >= 1 " )
7781 assert ( incY >= 1 , " \( incY) >= 1 " )
78- catlas_saxpby ( n, alpha, & self + offsetX, incX, beta, & y + offsetY, incY)
82+ withUnsafeMutableBufferPointer { X in
83+ y. withUnsafeMutableBufferPointer { Y in
84+ catlas_saxpby ( n, alpha, X . baseAddress! + offsetX, incX, beta, Y . baseAddress! + offsetY, incY)
85+ }
86+ }
7987 }
8088
8189}
@@ -98,7 +106,9 @@ public extension Array where Element == Double {
98106 " \( offset) == 0 || ( \( offset) >= 0 && \( offset) < \( count) ) " )
99107 assert ( n >= 0 && n <= count - offset, " \( n) >= 0 && \( n) <= \( count) - \( offset) " )
100108 assert ( incX >= 1 , " \( incX) >= 1 " )
101- cblas_dscal ( n, alpha, & self + offset, incX)
109+ withUnsafeMutableBufferPointer {
110+ cblas_dscal ( n, alpha, $0. baseAddress! + offset, incX)
111+ }
102112 }
103113
104114 /// Modifies a vector in place, setting each element to a given value.
@@ -121,7 +131,9 @@ public extension Array where Element == Double {
121131 assert ( n >= 0 && n <= count - offset,
122132 " \( n) >= 0 && \( n) <= \( count) - \( offset) " )
123133 assert ( incX >= 1 , " \( incX) >= 1 " )
124- catlas_dset ( n, alpha, & self + offset, incX)
134+ withUnsafeMutableBufferPointer {
135+ catlas_dset ( n, alpha, $0. baseAddress! + offset, incX)
136+ }
125137 }
126138
127139 /// Computes the sum of two vectors, scaling each one separately (single-precision).
@@ -156,6 +168,10 @@ public extension Array where Element == Double {
156168 assert ( n >= 0 && n / incY <= y. count - offsetY, " \( n) >= 0 && \( n) / \( incY) <= \( y. count) - \( offsetY) " )
157169 assert ( incX >= 1 , " \( incX) >= 1 " )
158170 assert ( incY >= 1 , " \( incY) >= 1 " )
159- catlas_daxpby ( n, alpha, & self + offsetX, incX, beta, & y + offsetY, incY)
171+ withUnsafeMutableBufferPointer { X in
172+ y. withUnsafeMutableBufferPointer { Y in
173+ catlas_daxpby ( n, alpha, X . baseAddress! + offsetX, incX, beta, Y . baseAddress! + offsetY, incY)
174+ }
175+ }
160176 }
161177}
0 commit comments