mlandistest / code

2 stars 0 forks source link

Two ways of creating vectors but not the same behavior [sf#4] #4

Open mlandis opened 10 years ago

mlandis commented 10 years ago

Reported by boussau on 2012-02-01 00:04 UTC If I do: uniformVector <- v(1,1) probabilityVector ~ dirichlet(uniformVector)

Everything is fine, but if I do: for (j in 1:2) { uniformVector2[j] <- 1 } probabilityVector ~ dirichlet(uniformVector2) Error: Argument mismatch for call to function 'dirichlet'. Correct usage is: Dist_dirichlet function (+Real vector "alpha")

Then there is a problem. It is weird as the vectors don't look any different to me: RevBayes > uniformVector [ 1, 1 ] RevBayes > uniformVector2 [ 1, 1 ]

I think there is a conversion problem between Vector classes. Indeed, if I try: for (j in 1:2) { uniformVector[j] <- 1 } Error: Object of type Natural vector does not allow insertion of variables.

It seems like the constructor v(1,1) creates a VectorNatural, which can be easily converted into a VectorPosReal so that dirichlet works fine, but not the loop constructor. I hope this bug is easy to correct...