Skip to content

Commit 21bce7b

Browse files
committed
Add vDSP_vdpsp
1 parent ff8f078 commit 21bce7b

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,4 @@ The package is structured as follows:
7777
- `Statistical` - Statistical operations:
7878
- [x] `vDSP.mean` - Mean of a vector
7979
- `Transforms`:
80-
- [ ] `vDSP_vdpsp` - Convert a double vector to a single precision vector
80+
- [x] `vDSP_vdpsp` - Convert a double vector to a single precision vector
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#if canImport(Accelerate)
2+
@_exported import Accelerate
3+
#else
4+
5+
/// Converts a double-precision vector to a single-precision vector.
6+
/// - Parameters:
7+
/// - __A: The input vector.
8+
/// - __IA: The distance between the elements in the input vector.
9+
/// - __C: The output vector.
10+
/// - __IC: The distance between the elements in the output vector.
11+
/// - __N: The number of elements that the function processes.
12+
public func vDSP_vdpsp(
13+
_ __A: UnsafePointer<Double>,
14+
_ __IA: vDSP_Stride,
15+
_ __C: UnsafeMutablePointer<Float>,
16+
_ __IC: vDSP_Stride,
17+
_ __N: vDSP_Length
18+
) {
19+
var i = 0
20+
while i < __N {
21+
__C[i * __IC] = Float(__A[i * __IA])
22+
i += 1
23+
}
24+
}
25+
#endif

0 commit comments

Comments
 (0)