AnyDerivative

@frozen
public struct AnyDerivative : Differentiable & AdditiveArithmetic

A type-erased derivative value.

The AnyDerivative type forwards its operations to an arbitrary underlying base derivative value conforming to Differentiable and AdditiveArithmetic, hiding the specifics of the underlying value.

  • The underlying base value.

    Declaration

    public var base: Any { get }
  • Creates a type-erased derivative from the given derivative.

    Declaration

    @differentiable
    public init<T>(_ base: T) where T : Differentiable, T == T.TangentVector
  • Declaration

    public typealias TangentVector = AnyDerivative
  • Declaration

    public static func == (lhs: AnyDerivative, rhs: AnyDerivative) -> Bool
  • Declaration

    public static func != (lhs: AnyDerivative, rhs: AnyDerivative) -> Bool
  • Declaration

    public static var zero: AnyDerivative { get }
  • Declaration

    public static func + (
      lhs: AnyDerivative, rhs: AnyDerivative
    ) -> AnyDerivative
  • Declaration

    public static func - (
      lhs: AnyDerivative, rhs: AnyDerivative
    ) -> AnyDerivative
  • Declaration

    public mutating mutating func move(along direction: TangentVector)