Thank you, this solves the first problem I had. I don't understand though, why 
it can infer N from Dual[N, T] but not T. Anyways, the problem remains that 
scalar multiplication should work for arbitrarily nested duals, i.e. 
    
    
    let a = dual[2, Dual[2, float]](
      dual[2, float](1.0, [0.0, 0.0]),
      [dual[2, float](0.0, [0.0, 0.0]), dual[2, float](1.0, [0.0, 0.0])]
    )
    
    
    Run

but assuming the type T in Dual[N, T] can only be inferred if provided as 
another argument, I don't know what the function signature needs to be, so this 
fails: 
    
    
    # Error: type mismatch: got <float64, Dual[2, Dual[2, system.float]]>
    echo 183.0*a
    
    
    Run

The wanted output is the following just propagating the scalar multiplication 
through. An analogy I could think of would be viewing matrices as a vector of 
vectors where one can also propagate the scalar multiplication to the vectors. 
To be more clear: 
    
    
    let want_expect = dual[2, Dual[2, float]](
      dual[2, float](183.0, [0.0, 0.0]),
      [dual[2, float](0.0, [0.0, 0.0]), dual[2, float](183.0, [0.0, 0.0])]
    )
    
    
    Run

Thanks in advance, ~whiterock

Reply via email to