Exemplo n.º 1
0
void ManagerBase::notifyDiscardFinish(const Record& res, int s, int factor)
{
    Message m(MsgType::DiscardFinish);
    auto msg = m.get<DiscardFinishMsg>();
    msg->set_score(s);
    msg->set_factor(factor);
    (*msg) << res.getBottom();
    notify(&m);
}
Exemplo n.º 2
0
/* checks if checkButton gets activated, or deactivated */
void toggle_button_callback(GtkToggleButton *check, gpointer data)
{
	if(gtk_toggle_button_get_active (check)){
		int cast = GPOINTER_TO_INT( data);
		set_factor(cast);
	} 
	else{
		int cast = GPOINTER_TO_INT( data);
		unset_factor(cast);
	}
}
MultivariateFNormalSufficient::MultivariateFNormalSufficient(
        const MatrixXd& FX, double JF, const VectorXd& FM,
        const MatrixXd& Sigma, double factor)
{
        //O(1)
        reset_flags();
        N_=FX.rows();
        M_=FX.cols();
        LOG( "MVN: direct init with N=" << N_
                << " and M=" << M_ << std::endl);
        CHECK( N_ > 0,
            "please provide at least one observation per dimension");
        CHECK( M_ > 0,
            "please provide at least one variable");
        set_factor(factor);
        set_FM(FM);
        set_FX(FX);
        set_jacobian(JF);
        set_Sigma(Sigma);
}
MultivariateFNormalSufficient::MultivariateFNormalSufficient(
        const VectorXd& Fbar, double JF, const VectorXd& FM, int Nobs,
        const MatrixXd& W, const MatrixXd& Sigma, double factor)
{
        reset_flags();
        N_=Nobs;
        M_=Fbar.rows();
        LOG( "MVN: sufficient statistics init with N=" << N_
                << " and M=" << M_ << std::endl);
        CHECK( N_ > 0,
            "please provide at least one observation per dimension");
        CHECK( M_ > 0,
            "please provide at least one variable");
        set_factor(factor);
        set_FM(FM);
        set_Fbar(Fbar);
        set_W(W);
        set_jacobian(JF);
        set_Sigma(Sigma);
}
Exemplo n.º 5
0
SEXP data_frame_from_apop_data(apop_data *in){
    if (!in) return R_NilValue;
    int numeric_rows = !!(in->vector) 
                        + (in->matrix ? in->matrix->size2 : 0)
                        + !!(in->weights);
    int text_rows = in->textsize[1];
    SEXP out, onerow;
    PROTECT(out = allocVector(VECSXP, numeric_rows + text_rows));
    int col_ct = 0;
    int firstcol = in->vector ? -1 : 0;
    int lastcol = in->matrix ? in->matrix->size2 : 0;
    for (int i= firstcol; i < lastcol; i++){
        int len = (i == -1) ? in->vector->size : in->matrix->size1;
        apop_data *factorpage = find_factor(onerow, in, i);
        if (factorpage){
            SET_VECTOR_ELT(out, col_ct++, (onerow = allocVector(INTSXP, len)));
            for (int j=0; j< len; j++) INTEGER(onerow)[j] = apop_data_get(in, j, i);
            set_factor(onerow, factorpage);
        } else {
            SET_VECTOR_ELT(out, col_ct++, (onerow = allocVector(REALSXP, len)));
            for (int j=0; j< len; j++) REAL(onerow)[j] = apop_data_get(in, j, i);
        }
    }
    for (int i= 0; i < text_rows; i++){
        int len = in->textsize[0];
        SEXP onerow;
        SET_VECTOR_ELT(out, col_ct++, (onerow =  allocVector(STRSXP, len)));
        for (int j=0; j< len; j++) 
            SET_STRING_ELT(onerow, j, mkChar(in->text[j][i])); //Do I need strdup?
    }
    if (in->weights){
        int len =  in->weights->size;
        SET_VECTOR_ELT(out, col_ct++, (onerow = allocVector(REALSXP, len)));
        for (int j=0; j< len; j++) 
            REAL(onerow)[j] = gsl_vector_get(in->weights, j);
    }
    handle_names(in, out);
    UNPROTECT(1);
    return out;
}
MultivariateFNormalSufficient::MultivariateFNormalSufficient(
        const VectorXd& Fbar, double JF, const VectorXd& FM, int Nobs,
        const MatrixXd& W, const MatrixXd& Sigma, double factor)
  : base::Object("Multivariate Normal distribution %1%")
{
        reset_flags();
        N_=Nobs;
        M_=Fbar.rows();
        IMP_LOG_TERSE( "MVN: sufficient statistics init with N=" << N_
                << " and M=" << M_ << std::endl);
        IMP_USAGE_CHECK( N_ > 0,
            "please provide at least one observation per dimension");
        IMP_USAGE_CHECK( M_ > 0,
            "please provide at least one variable");
        set_factor(factor);
        set_FM(FM);
        set_Fbar(Fbar);
        set_W(W);
        set_jacobian(JF);
        set_Sigma(Sigma);
        use_cg_=false;
}
MultivariateFNormalSufficient::MultivariateFNormalSufficient(
        const MatrixXd& FX, double JF, const VectorXd& FM,
        const MatrixXd& Sigma, double factor) :
  base::Object("Multivariate Normal distribution %1%")
{
        //O(1)
        reset_flags();
        N_=FX.rows();
        M_=FX.cols();
        IMP_LOG_TERSE( "MVN: direct init with N=" << N_
                << " and M=" << M_ << std::endl);
        IMP_USAGE_CHECK( N_ > 0,
            "please provide at least one observation per dimension");
        IMP_USAGE_CHECK( M_ > 0,
            "please provide at least one variable");
        set_factor(factor);
        set_FM(FM);
        set_FX(FX);
        set_jacobian(JF);
        set_Sigma(Sigma);
        use_cg_=false;
}