Generic Type Method

evaluatePolynomial(usingCoefficients:withVariables:result:)

Evaluates a double-precision polynomial using specified coefficients and independent variables.

Declaration

static func evaluatePolynomial<U, V>(usingCoefficients coefficients: [Double], withVariables variables: U, result: inout V) where U : AccelerateBuffer, V : AccelerateMutableBuffer, U.Element == Double, V.Element == Double

Parameters

coefficients

An array that contains the coefficients.

variables

An array that contains the independent variables.

result

An array that receives the result of the calculation.

Discussion

The single- and double-precision evaluatePolynomial(usingCoefficients:withVariables:result:) functions compute an evaluated polynomial using the specified coefficients and independent variables.

For example, the following code defines the independent variables as an array containing monotonically incrementing values, and a set of coefficients:

let variables: [Float] = vDSP.ramp(withInitialValue: 0,
                      increment: 0.01 ,
                      count: 1024)

let coefficients: [Float] = [-0.09625138,
                             2.1142652,
                             -15.026311,
                             35.991802,
                             -10.0]

Use evaluatePolynomial(usingCoefficients:withVariables:) to evaluate the polynomial:

let result = vDSP.evaluatePolynomial(usingCoefficients: coefficients,
                                     withVariables: variables)

The following figure shows the values returned in result:

A line graph that visualizes the evalued polynomial.

See Also

Vector-to-Vector Polynomial Evaluation

static func evaluatePolynomial<U>(usingCoefficients: [Double], withVariables: U) -> [Double]

Returns a double-precision evaluated polynomial using specified coefficients and independent variables.

static func evaluatePolynomial<U>(usingCoefficients: [Float], withVariables: U) -> [Float]

Returns a single-precision evaluated polynomial using specified coefficients and independent variables.

static func evaluatePolynomial<U, V>(usingCoefficients: [Float], withVariables: U, result: inout V)

Evaluates a single-precision polynomial using specified coefficients and independent variables.

func vDSP_vpoly(UnsafePointer<Float>, vDSP_Stride, UnsafePointer<Float>, vDSP_Stride, UnsafeMutablePointer<Float>, vDSP_Stride, vDSP_Length, vDSP_Length)

Evaluates a single-precision polynomial using specified coefficients, independent variables, and strides.

func vDSP_vpolyD(UnsafePointer<Double>, vDSP_Stride, UnsafePointer<Double>, vDSP_Stride, UnsafeMutablePointer<Double>, vDSP_Stride, vDSP_Length, vDSP_Length)

Evaluates a double-precision polynomial using specified coefficients, independent variables, and strides.