struct _camel_search_words * camel_search_words_split (const guchar *in) { gint type = CAMEL_SEARCH_WORD_SIMPLE, all = 0; GString *w; struct _camel_search_words *words; GPtrArray *list = g_ptr_array_new (); guint32 c; gint inquote = 0; words = g_malloc0 (sizeof (*words)); w = g_string_new(""); do { c = camel_utf8_getc (&in); if (c == 0 || (inquote && c == '"') || (!inquote && g_unichar_isspace (c))) { output_w (w, list, type); all |= type; type = CAMEL_SEARCH_WORD_SIMPLE; inquote = 0; } else { if (c == '\\') { c = camel_utf8_getc (&in); if (c) output_c (w, c, &type); else { output_w (w, list, type); all |= type; } } else if (c == '\"') { inquote = 1; } else { output_c (w, c, &type); } } } while (c); g_string_free (w, TRUE); words->len = list->len; words->words = (struct _camel_search_word **)list->pdata; words->type = all; g_ptr_array_free (list, FALSE); return words; }
void encode(const std::vector<boost::shared_ptr<std::vector<double> > >& input, const Model& model, std::vector<boost::shared_ptr<std::vector<double> > >& output) { assert(input.size()); const size_t rows = input.size(), cols = input[0]->size(); assert(cols == (size_t)model.getModel()->high_dim()); const int lowdim = model.getModel()->low_dim(); std::vector<double> idata(rows * cols); std::vector<double> odata(rows * lowdim); for (size_t i = 0; i < input.size(); ++i) { std::copy(input[i]->begin(), input[i]->end(), idata.begin() + cols * i); } YA_WRAP_RM(double) input_w(&idata[0], rows, cols); YA_WRAP_RM(double) output_w(&odata[0], rows, lowdim); model.getModel()->forward_t(input_w, output_w); output.clear(); for (size_t i = 0; i < rows; ++i) { output.push_back(boost::make_shared<std::vector<double> >(odata.begin() + i * lowdim, odata.begin() + (i+1) * lowdim)); } }
void trainModel(std::vector<boost::shared_ptr<std::vector<double> > >& input, DimensionalityReductionMethod method, int lowdim, int neighbors, Model& model) { assert(input.size()); const size_t rows = input.size(), cols = input[0]->size(); std::vector<double> idata(rows * cols); std::vector<double> odata(rows * lowdim); for (size_t i = 0; i < input.size(); ++i) { std::copy(input[i]->begin(), input[i]->end(), idata.begin() + cols * i); } YA_WRAP_RM(double) input_w(&idata[0], rows, cols); YA_WRAP_RM(double) output_w(&odata[0], rows, lowdim); boost::shared_ptr<YADimReduce<double> > reductionMethod; switch(method) { case DimensionalityReductionMethod::PCA: reductionMethod = boost::make_shared<YAPCAReduce<double> >(); break; case DimensionalityReductionMethod::LLE: reductionMethod = boost::make_shared<YALLEReduce<double> >(); reductionMethod->neighbor_weight_mode(1); reductionMethod->neighbors(neighbors); reductionMethod->neighbor_mode(0); break; case DimensionalityReductionMethod::Isomap: reductionMethod = boost::make_shared<YAIsoReduce<double> >(); reductionMethod->neighbor_weight_mode(0); reductionMethod->neighbors(neighbors); reductionMethod->neighbor_mode(0); break; } EigenOptions eigopts; reductionMethod->verbose(2); reductionMethod->find_t(input_w, output_w, lowdim, eigopts); model.setMethod(method); model.setModel(reductionMethod); }
void ucom4_cpu_device::device_reset() { m_pc = 0; m_op = 0; m_skip = false; m_timer->adjust(attotime::never); // clear interrupt m_int_line = CLEAR_LINE; m_int_f = 0; m_inte_f = (m_family == NEC_UCOM43) ? 0 : 1; // clear i/o for (int i = NEC_UCOM4_PORTC; i <= NEC_UCOM4_PORTI; i++) output_w(i, 0xf); }