I am trying to implement a method that can accept as input either a Breeze Vector or a Breeze Matrix. Something like
private def updateExponentialMovingAverage[T](tau: Double, initTheta: T, theta: T): T = {
tau * theta + (1 - tau) * initTheta
}
However this raises an issue with overloading and I cannot find an appropriate type to restrict T. Do you have any suggestions?
Breezes uses type classes for most of these kinds of things. The easiest thing to do is to use the
VectorSpacetype class, though unfortunately for DenseMatrices the VectorSpace typeclass is gated behind another import, which I regret.