 // MARK: Minimum
 
 public func min(x: [Float]) -> Float {
-    var result: Float = 0.0
-    vDSP_minv(x, 1, &result, vDSP_Length(x.count))
+    return min(x, range: 0..<x.count)
+}
+
+public func min(x: [Float], range: Range<Int>) -> Float {
+    let p = UnsafePointer<Float>(x) + range.startIndex
+
+    var result: Float = 0.0
+    vDSP_minv(p, 1, &result, vDSP_Length(range.count))
 
     return result
 }
 
 public func min(x: [Double]) -> Double {
-    var result: Double = 0.0
-    vDSP_minvD(x, 1, &result, vDSP_Length(x.count))
+    return min(x, range: 0..<x.count)
+}
+
+public func min(x: [Double], range: Range<Int>) -> Double {
+    let p = UnsafePointer<Double>(x) + range.startIndex
+
+    var result: Double = 0.0
+    vDSP_minvD(p, 1, &result, vDSP_Length(range.count))
 
     return result
 }

// MARK: Sum of Absolute Values

public func asum(x: [Float]) -> Float {
    return cblas_sasum(Int32(x.count), x, 1)
}

public func asum(x: [Double]) -> Double {
    return cblas_dasum(Int32(x.count), x, 1)
}

// MARK: Maximum

public func max(x: [Float]) -> Float {
    var result: Float = 0.0
    vDSP_maxv(x, 1, &result, vDSP_Length(x.count))

    return result
}

public func max(x: [Double]) -> Double {
    var result: Double = 0.0
    vDSP_maxvD(x, 1, &result, vDSP_Length(x.count))

    return result
}

// MARK: Sum

public func sum(x: [Float]) -> Float {
    return sum(x, range: 0..<x.count)
}

public func sum(x: [Float], range: Range<Int> ) -> Float {
    var result: Float = 0.0
    let p = UnsafePointer<Float>(x) + range.startIndex
    vDSP_sve(p, 1, &result, vDSP_Length(range.count))

    return result
}

public func sum(x: [Double]) -> Double {
    return sum(x, range: 0..<x.count)
}

public func sum(x: [Double], range: Range<Int>) -> Double {
    var result: Double = 0.0
    let p = UnsafePointer<Double>(x) + range.startIndex
    vDSP_sveD(p, 1, &result, vDSP_Length(range.count))

    return result
}

public func sum(x: [Complex]) -> Complex {
    return sum(x, range: 0..<x.count)
}

public func sum(x: [Complex], range: Range<Int>) -> Complex {
    let reals = UnsafePointer<Double>(x) + range.startIndex
    let imags = UnsafePointer<Double>(x) + range.startIndex + 1

    var result = Complex()
    vDSP_sveD(reals, 2, &result.real, vDSP_Length(range.count))
    vDSP_sveD(imags, 2, &result.imag, vDSP_Length(range.count))

    return result
}
