scala> Polynomial("(1)").##
res1: Int = -135076863
scala> Polynomial("(1)").##
res2: Int = 776699639
scala> Polynomial("(1)").##
res3: Int = 797295762
scala> Polynomial("(1)").##
res4: Int = 639834089
Both PolyDense and PolySparse use arrays internally. So the hashCode method generated for case classes is not sufficient. Also, hashCode would have to be implemented in such a way that both PolyDense and PolySparse representations of the same polynomial return the same hash code.
At the very least, hashCode needs to be implemented to be 0 to fulfill the equals/hashCode contract.
Both PolyDense and PolySparse use arrays internally. So the hashCode method generated for case classes is not sufficient. Also, hashCode would have to be implemented in such a way that both PolyDense and PolySparse representations of the same polynomial return the same hash code.
At the very least, hashCode needs to be implemented to be 0 to fulfill the equals/hashCode contract.