aboutsummaryrefslogtreecommitdiff
path: root/src/parent_solutions.c
blob: 4881d708ad867b7eae387aa0827e2d598118bfc4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <R.h>
#include <Rinternals.h>

SEXP SFO_solution(SEXP t, SEXP parent_0_, SEXP k_) {

  int n = length(t);

  double parent_0 = asReal(parent_0_);
  double k = asReal(k_);

  double *pt, *pout;

  SEXP out = PROTECT(allocVector(REALSXP, n));

  pt = REAL(t);
  pout = REAL(out);

  for (int i = 0; i < n; i++) {
    pout[i] = parent_0 * exp(- k * pt[i]);
  }

  UNPROTECT(1);

  return out;
}

Contact - Imprint