Should probably `cdef double` both `T` and `D`.