File: utilities.c

package info (click to toggle)
r-cran-emoa 0.5-3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 588 kB
  • sloc: ansic: 4,033; sh: 13; makefile: 2
file content (14 lines) | stat: -rw-r--r-- 281 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <R.h>
#include "utilities.h"

double clip_to_limits(const double x, const double l, const double u) {
  if (x < l) {
    return (l);
  } else if (x > u) {
    return (u);
  } else {
    return (x);
  }
}

int flip_coin(void) { return (.5 < unif_rand() ? HEADS : TAILS); }