Example #1
0
SEXP get_tau (SEXP Rpostmat,
	      SEXP Rfun,
	      SEXP Rr,
	      SEXP Rr_low,
	      SEXP Rinds,
	      SEXP Rxcol,
	      SEXP Rycol) {

  int i;
  SEXP divisor;
  SEXP rc;
  SEXP highR;
  SEXP lowR;

  PROTECT(highR=allocVector(REALSXP, 1));
  PROTECT(lowR=allocVector(REALSXP, 1));
  REAL(highR)[0] = R_PosInf;
  REAL(lowR)[0] = 0;
  PROTECT(divisor=get_pi(Rpostmat,Rfun, highR, lowR, Rinds, Rxcol, Rycol));
  PROTECT(rc=get_pi(Rpostmat, Rfun, Rr, Rr_low, Rinds, Rxcol, Rycol));
  for (i=0; i<length(Rr);i++) {
    REAL(rc)[i] = REAL(rc)[i]/REAL(divisor)[0];
  }
  UNPROTECT(4);

  return(rc);
}
Example #2
0
static void cipvs_submit_service (struct ip_vs_service_entry *se)
{
	struct ip_vs_stats_user  stats = se->stats;
	struct ip_vs_get_dests  *dests = ipvs_get_dests (se);

	char pi[DATA_MAX_NAME_LEN];

	size_t i;

	if (0 != get_pi (se, pi, sizeof (pi)))
	{
		free (dests);
		return;
	}

	cipvs_submit_connections (pi, NULL, stats.conns);
	cipvs_submit_if (pi, "if_packets", NULL, stats.inpkts, stats.outpkts);
	cipvs_submit_if (pi, "if_octets", NULL, stats.inbytes, stats.outbytes);

	for (i = 0; i < dests->num_dests; ++i)
		cipvs_submit_dest (pi, &dests->entrytable[i]);

	free (dests);
	return;
} /* cipvs_submit_service */
mydouble Codon61SequenceStationaryDistribution::likelihood(const RandomVariable* rv, const Value* val) {
	if(val==0) error("Codon61SequenceStationaryDistribution::log_likelihood(): variable not found");
	Codon61SequenceRV& x = *((Codon61SequenceRV*)val);
	
	vector< mydouble > pi(61);
	int i;
	for(i=0;i<61;i++) {
		pi[i] = get_pi()->get_double(i);
	}
	
	mydouble ret(1.0);
	for(i=0;i<x.length();i++) {
		ret *= pi[x[i]];
	}
	return ret;
}