1 /* rTrait.c 2010-07-26 */
3 /* Copyright 2010 Emmanuel Paradis */
5 /* This file is part of the R-package `ape'. */
6 /* See the file ../COPYING for licensing issues. */
10 void rTraitCont(int *model, int *Nedge, int *edge1, int *edge2, double *el,
11 double *sigma, double *alpha, double *theta, double *x)
13 /* The tree must be in pruningwise order */
17 case 1 : for (i = *Nedge - 1; i >= 0; i--) {
19 x[edge2[i]] = x[edge1[i]] + sqrt(el[i]) * sigma[i] * norm_rand();
23 case 2 : for (i = *Nedge - 1; i >= 0; i--) {
25 x[edge2[i]] = x[edge1[i]] - alpha[i]*el[i]*(x[edge1[i]] - theta[i]) + sqrt(el[i])*sigma[i]*norm_rand();
29 case 3 : for (i = *Nedge - 1; i >= 0; i--) {
31 x[edge2[i]] = x[edge1[i]] - (1 - exp(alpha[i]*el[i]))*(x[edge1[i]] - theta[i]) + sqrt(el[i])*sigma[i]*norm_rand();