RobinHankin / spray

sparse arrays and fast multivariate polynomials
https://robinhankin.github.io/spray/
2 stars 2 forks source link

replacement method #9

Closed RobinHankin closed 4 years ago

RobinHankin commented 4 years ago

The order of terms is supposed to be implementation-specific, and cannot be relied upon. But:

 (a <- spray(diag(4),1:4))
             val
 0 0 0 1  =    4
 0 0 1 0  =    3
 1 0 0 0  =    1
 0 1 0 0  =    2
> (b <- spray(matrix(1:12,4,3),1:4))
            val
 1 5  9  =    1
 4 8 12  =    4
 3 7 11  =    3
 2 6 10  =    2
> value(a) <- value(b)
> a
             val
 0 1 0 0  =    2
 1 0 0 0  =    3
 0 0 0 1  =    1
 0 0 1 0  =    4
> 

The re-assigning of the value of a should be undefined, because the order of the terms is not defined.