void mpfx_manager::set_core(mpfx & n, mpq_manager<SYNCH> & m, mpq const & v) { if (m.is_int(v)) { set_core(n, m, v.numerator()); } else { allocate_if_needed(n); _scoped_numeral<mpz_manager<SYNCH> > tmp(m); n.m_sign = is_neg(n); m.mul2k(v.numerator(), 8 * sizeof(unsigned) * m_frac_part_sz, tmp); m.abs(tmp); if ((n.m_sign == 1) != m_to_plus_inf && !m.divides(v.denominator(), tmp)) { m.div(tmp, v.denominator(), tmp); m.inc(tmp); } else { m.div(tmp, v.denominator(), tmp); } m_tmp_digits.reset(); m.decompose(tmp, m_tmp_digits); unsigned sz = m_tmp_digits.size(); if (sz > m_total_sz) throw overflow_exception(); unsigned * w = words(n); ::copy(sz, m_tmp_digits.c_ptr(), m_total_sz, w); } SASSERT(check(n)); }
/* * fod_fillslot() * Fill pset slot from a port */ static int fod_fillslot(struct pset *ps, struct perpage *pp, uint idx) { uint pg; ASSERT_DEBUG(!(pp->pp_flags & (PP_V|PP_BAD)), "fod_fillslot: valid"); pg = alloc_page(); set_core(pg, ps, idx); if (pageio(pg, ps->p_data, ptob(idx+ps->p_off), NBPG, FS_ABSREAD)) { free_page(pg); return(1); } /* * Fill in the new page's value, leave one reference for * our caller, and another for our cache atl */ pp->pp_flags |= PP_V; pp->pp_refs = 2; pp->pp_flags &= ~(PP_M|PP_R); pp->pp_pfn = pg; /* * Add the cache reference */ add_atl(pp, ps, idx, ATL_CACHE); return(0); }
hid_t set_up_rnw() { // Set up driver to use ram instead of on-disk files. hid_t fapl; fapl = set_core(); create_file(fapl, FILE_NAME_RNW); hid_t file_id; file_id = open_file(fapl, FILE_NAME_RNW); size_t dim0, dim1; for (dim0 = DIM0_START; dim0 <= DIM0_LIM; dim0 *= 2) { for (dim1 = DIM1_START; dim1 <= DIM1_LIM; dim1 *= 2) { // get name of dataset char name[25]; sprintf(name, "dataset_%dx%d", dim0, dim1); // puts string into buffer create_dataset(file_id, dim0, dim1, name); /* Initialise with values */ hid_t dataset_id; dataset_id = open_dataset(file_id, name); double matrix[dim0][dim1]; int i, j; // fill matrix with some elements for (i = 0; i < dim0; i++) { for (j = 0; j < dim1; j++) { matrix[i][j] = i * dim1 + j; } } write_matrix(dataset_id, matrix); close_dataset(dataset_id); } } /* Done initializing values */ close_file(file_id); return fapl; }
void mpfx_manager::set(mpfx & n, synch_mpq_manager & m, mpq const & v) { set_core(n, m, v); }
void mpfx_manager::set(mpfx & n, unsynch_mpz_manager & m, mpz const & v) { set_core(n, m, v); }
SceneGraph::Iterator& SceneGraph::Iterator:: operator << (Core* core) { set_core(core); return *this; }