void binbuff::set_symbol_size(int w) { if (w <= 0) { throw sci_exception("binbuff::set_symbol_size - bad size", w ); } symbol_size = w; y0.set_length(w); y0=to_bvec(to_ivec(zeros(symbol_size))); }
ivec GreedyMaxMinDesign::subsample(mat X, int n) { if (n <= 0) cerr << "Invalid sample size in GreedyMaxMinDesign::subsample(...)" << endl; int imax; ivec isample(n); // Indices of points in sample ivec iremain; // Indices of remaining points vec D; // Vector of min distances to sample iremain = to_ivec(linspace(0,X.rows()-1,X.rows())); // Start with location of maximum Z max(X.get_col(X.cols()-1), imax); isample(0) = imax; iremain.del(imax); // Add points having maximum minimum distance to sample // until subsample size is reached for (int i=1; i<n; i++) { vec xnew = X.get_row(isample(i-1)); // Last point added vec Dnew = dist(X.get_rows(iremain), xnew); // Distances to xnew // Update minimum distances to sample if (D.length() == 0) D = Dnew; else D = min(D,Dnew); // Find point with max min distance max(D,imax); // Add it to sample isample(i) = iremain(imax); // And delete it from remainder iremain.del(imax); D.del(imax); } return isample; }
//! set parameter void sci_bert::set(int param, var* p_v) { ivec iv; int i; var_vec *p_var_vec; var_ivec *p_var_ivec; p_var_vec = NULL; p_var_ivec = NULL; // p_v might be either var_vec, var_ivec or var_bvec p_var_vec = dynamic_cast<var_vec *> (p_v); if (p_var_vec == NULL) { p_var_ivec = dynamic_cast<var_ivec *> (p_v); if (p_var_ivec == NULL) { throw sci_exception ("sci_bert::set - p_v - bad cast"); } } switch (param) { case SCI_SIZE: // size or correlators lsrx,lsry case SCI_LENGTH: if (p_var_vec) { i = (int)(p_var_vec->v[0]); } else if (p_var_ivec) { i = p_var_ivec->v[0]; } else { throw sci_exception ("sci_bert::set - SCI_LENGTH - v - bad cast"); } set_length(i); break; case SCI_SYMBOL_SIZE: if (p_var_vec) { i = (int)(p_var_vec->v[0]); } else if (p_var_ivec) { i = p_var_ivec->v[0]; } else { throw sci_exception ("sci_bert::set - SCI_SYMBOL_SIZE - v - bad cast"); } set_symbol_size(i); break; case SCI_PRBS: if (p_var_vec) { i = (int)(p_var_vec->v[0]); } else if (p_var_ivec) { i = p_var_ivec->v[0]; } else { throw sci_exception ("sci_bert::set - SCI_PRBS - v - bad cast"); } set_prbs(i); break; case SCI_THRESHOLD: if (p_var_vec) { iv = to_ivec(p_var_vec->v); } else if (p_var_ivec) { iv = p_var_ivec->v; } else { throw sci_exception ("sci_bert::set - SCI_THRESHOLD - v - bad cast"); } set_threshold( iv ); break; case SCI_FSM: if (p_var_vec) { i = (int)p_var_vec->v[0]; } else if (p_var_ivec) { i = p_var_ivec->v[0]; } else { throw sci_exception ("sci_bert::set - SCI_FSM - v - bad cast"); } set_fsm((bert_state)i); break; case SCI_ADR: if (p_var_vec) { i = (int)p_var_vec->v[0]; } else if (p_var_ivec) { i = p_var_ivec->v[0]; } else { throw sci_exception ("sci_bert::set - SCI_ADR - v - bad cast"); } set_adr((bert_adr)i); break; case SCI_OUTPUT: if (p_var_vec) { i = (int)p_var_vec->v[0]; } else if (p_var_ivec) { i = p_var_ivec->v[0]; } else { throw sci_exception ("sci_bert::set - SCI_OUTPUT - v - bad cast"); } set_output((bert_state)i); break; default: throw sci_exception ("sci_bert::set - unknown param", param); } return; };