/*///////////////////////////////////////////////////////////////*/ KScalar stats_mean_fitness_self_progeny_n (KConfig_n KN) /* ** Compute mean fitness of self progeny. To do this with the ** KN->x1,x2 type of data structures, we have to generate ** self progeny to a temporary KArray_n, then examine the ** genotypes in that array for fitness. ** ** If there were no selfed progeny produced, then we of course ** have zero mean fitness due to selfed progeny. */ { const char* thisfunction = "stats_mean_fitness_self_progeny_n"; KScalar wmean; IF_DEBUG(DEBUG_TRACE1) fprintf(stderr, "%s\n", thisfunction); if (KN->S == 0.0) { IF_DEBUG(DEBUG_TRACE1) fprintf(stderr, "%s: S==0.0, self wmean=0.0\n", thisfunction); wmean = 0.0; } else { //void* a = alloc_KArray_n(); KArray_n a; apply_self_progeny_n(KN, a, KN->x1); wmean = mean_fitness_n(KN, a); //free_KArray_n(a); } return wmean; }
/*///////////////////////////////////////////////////////////////*/ void compute_self_progeny_n (KConfig_n KN) /* ** Compute proportions of selfed genotypes produced by population. */ { const char* thisfunction = "compute_self_progeny_n"; IF_DEBUG(DEBUG_TRACE1) fprintf(stderr, "%s\n", thisfunction); if (KN->current_x != KN_CURRENT_PROGENY_TO_X1 && KN->current_x != KN_CURRENT_X2) { char buf[200]; sprintf(buf, "%s: wrong current x array = %d", thisfunction, KN->current_x); fatal(buf); } if (KN->current_x == KN_CURRENT_X2) { /* we're the first reproduction function to get ** called, so we have to zero the destination array, ** which is KN->x1 */ fill_KArray_n(KN, KN->x1, 0.0); } apply_self_progeny_n(KN, KN->x1, KN->x2); KN->current_x = KN_CURRENT_PROGENY_TO_X1; }