Open sdewaele opened 4 years ago
I am open to the idea of having a constant, but wouldn't that also violate type stability? You would have to special case 0
-length (I am assuming that lengths are known at runtime, not compile time). Also, would it thrown an error when the input of inverse
is not ==
that constant?
The way this library is currently written makes special-casing this kind of tricky in a type-stable way even for arrays, but I will think about it.
I am working on an algorithm where I want to define a transformation for a vector of length
p
. Importantly,p
may be zero. This transformation is part of a tuple of transformations. Therefore, the final full parameter vector has a non-zero dimension. What I have done in the past is to omit the zero-dimensional transform, but this leads to additional coding to "compensate" for the missing element. Also, I think it can result in type instability.I can define a transform for a vector of dimension zero. Also, the forward transform does work:
However, the inverse transform fails:
It would be great if this could work.
Just as a thought - I am not sure if this makes sense in the grand scheme of things - but perhaps this and other cases could be handled by having the option to define the transform for a constant? This would also have a zero-dimensional parameter space, and zero jacobian.