One thing that deeply bothers me looking at the swift implementation:
public protocol VectorNumeric {
associatedtype ScalarElement
associatedtype Dimensionality
init(_ scalar: ScalarElement)
init(dimensionality: Dimensionality, repeating repeatedValue: ScalarElement)
func + (lhs: Self, rhs: Self) -> Self
func - (lhs: Self, rhs: Self) -> Self
func * (lhs: Self, rhs: Self) -> Self
}
If you want to obtain the gradient of a function with respect to some vector type, it must implement this interface.
I assume the last three are overloaded operators. But elementwise multiplication of two vectors (func *) is not an operation that is recognized in the mathematical formalism of linear algebra. Most vector types in my application deliberately do not implement this operation, or they call it something like mul_diag (for multiplication by a diagonal matrix). In my entire 44kloc codebase, I only call this function once.
I would hope a rust implementation would not require me to compromise the mathematical integrity of my types in such a manner.