vector_type solve(const matrix_type& A, const vector_type& y) { typedef typename matrix_type::size_type size_type; typedef typename matrix_type::value_type value_type; namespace ublas = boost::numeric::ublas; matrix_type Q(A.size1(), A.size2()), R(A.size1(), A.size2()); qr (A, Q, R); vector_type b = prod(trans(Q), y); vector_type result; if (R.size1() > R.size2()) { size_type min = (R.size1() < R.size2() ? R.size1() : R.size2()); result = ublas::solve(subrange(R, 0, min, 0, min), subrange(b, 0, min), ublas::upper_tag()); } else { result = ublas::solve(R, b, ublas::upper_tag()); } return result; }
void bi::MarginalSISHandler<B,A,S>::handleAdapterSamples( boost::mpi::communicator child, boost::mpi::status status) { typedef typename temp_host_matrix<real>::type matrix_type; static const int N = B::NP; /* add samples */ boost::optional<int> n = status.template count<real>(); if (n) { matrix_type Z(N + T, *n / (N + T)); child.recv(status.source(), status.tag(), Z.buf(), *n); for (int j = 0; j < Z.size2(); ++j) { adapter.add(subrange(column(Z,j), 0, N), subrange(column(Z,j), N, T)); } } /* send new proposal if necessary */ if (adapter.stop(t)) { adapter.adapt(t); BOOST_AUTO(q, adapter.get(t)); BOOST_AUTO(iter, node.children.begin()); for (; iter != node.children.end(); ++iter) { node.requests.push_front(iter->isend(0, MPI_TAG_ADAPTER_PROPOSAL, q)); } ///@todo Serialize q into archive just once, then send to all. This may ///be how broadcast is already implemented in Boost.MPI. } }
void trsm_impl( matrix_expression<MatA, cpu_tag> const& A, matrix_expression<MatB, cpu_tag>& B, boost::mpl::true_, column_major ) { SIZE_CHECK(A().size1() == A().size2()); SIZE_CHECK(A().size2() == B().size1()); typedef typename MatA::value_type value_type; std::size_t size1 = B().size1(); std::size_t size2 = B().size2(); for (std::size_t i = 0; i < size1; ++ i) { std::size_t n = size1-i-1; auto columnTriangular = column(A(),n); if(!Unit){ RANGE_CHECK(A()(n, n) != value_type());//matrix is singular row(B(),n) /= A()(n, n); } for (std::size_t l = 0; l < size2; ++ l) { if (B()(n, l) != value_type/*zero*/()) { auto columnMatrix = column(B(),l); noalias(subrange(columnMatrix,0,n)) -= B()(n,l) * subrange(columnTriangular,0,n); } } } }
double serial_inner_prod (const boost::numeric::ublas::vector <double> &lhs, const boost::numeric::ublas::vector <double> &rhs, int length) { #ifdef HAVE_BLAS double ret = from_blas::ddot (length, &lhs(0), 1, &rhs(0), 1); #else double ret = inner_prod (subrange (lhs, 0, length), subrange (rhs, 0, length)); #endif return ret; }
virtual vec reparametrize_func(const vec & lmk) const { vec6 ret; vec7 lmk1; vec7 lmk2; subrange(lmk1,0,3) = subrange(lmk,0,3); subrange(lmk1,3,7) = subrange(lmk,3,7); subrange(lmk2,0,3) = subrange(lmk,0,3); subrange(lmk2,3,7) = subrange(lmk,7,11); subrange(ret,0,3) = lmkAHP::ahp2euc(lmk1); subrange(ret,3,6) = lmkAHP::ahp2euc(lmk2); return ret; }
void bi::Cache::resize(const int size) { /* pre-condition */ BI_ASSERT(size >= 0); int oldSize = this->size(); valids.resize(size, true); // true is to preserve contents here dirties.resize(size, true); if (size > oldSize) { set_elements(subrange(valids, oldSize, size - oldSize), false); set_elements(subrange(dirties, oldSize, size - oldSize), false); } }
void trmv_impl( matrix_expression<TriangularA> const& A, vector_expression<V>& b, boost::mpl::true_, row_major ){ std::size_t size = A().size1(); for (std::size_t i = 0; i < size; ++ i) { if(!Unit){ b()(i) *= A()(i,i); } b()(i) += inner_prod(subrange(row(A,i),i+1,size),subrange(b,i+1,size)); } }
void subrange(unsigned char *sin, unsigned char *ein) // recursive function to divide ip range { unsigned char nets[4], nete[4]; int bitlen, nextlen; bitlen = count_bits(sin, ein); if (bitlen == 32) { sprintf(range_buf + strlen(range_buf), "%u.%u.%u.%u/32 ", sin[0], sin[1], sin[2], sin[3]); cprintf("%u.%u.%u.%u/32\n", sin[0], sin[1], sin[2], sin[3]); return; } else if (bitlen == 31) { sprintf(range_buf + strlen(range_buf), "%u.%u.%u.%u/31 ", sin[0], sin[1], sin[2], sin[3]); cprintf("%u.%u.%u.%u/31\n", sin[0], sin[1], sin[2], sin[3]); return; } nextlen = bitlen + 1; getse(sin, nets, nete, bitlen); if (sameaddr(sin, nets) && sameaddr(ein, nete)) { sprintf(range_buf + strlen(range_buf), "%u.%u.%u.%u/%d ", nets[0], nets[1], nets[2], nets[3], bitlen); cprintf("%u.%u.%u.%u/%d\n", nets[0], nets[1], nets[2], nets[3], bitlen); return; } getse(sin, nets, nete, nextlen); if (sameaddr(sin, nete)) { sprintf(range_buf + strlen(range_buf), "%u.%u.%u.%u/32 ", sin[0], sin[1], sin[2], sin[3]); cprintf("%u.%u.%u.%u/32\n", sin[0], sin[1], sin[2], sin[3]); } else if (sameaddr(sin, nets)) { sprintf(range_buf + strlen(range_buf), "%u.%u.%u.%u/%d ", nets[0], nets[1], nets[2], nets[3], nextlen); cprintf("%u.%u.%u.%u/%d\n", nets[0], nets[1], nets[2], nets[3], nextlen); } else // continue check subrange(sin, nete); getse(ein, nets, nete, nextlen); if (sameaddr(ein, nets)) { sprintf(range_buf + strlen(range_buf), "%u.%u.%u.%u/32 ", ein[0], ein[1], ein[2], ein[3]); cprintf("%u.%u.%u.%u/32\n", ein[0], ein[1], ein[2], ein[3]); } else if (sameaddr(ein, nete)) { sprintf(range_buf + strlen(range_buf), "%u.%u.%u.%u/%d ", nets[0], nets[1], nets[2], nets[3], nextlen); cprintf("%u.%u.%u.%u/%d\n", nets[0], nets[1], nets[2], nets[3], nextlen); } else // continue check subrange(nets, ein); }
void Evolver::next_generation(){ // evaluate (if needed) for(auto&& g : current_generation){ if(g.second < 0) { g.second = score(goal, g.first); } } // pick best no worse than parent auto best = current_generation[0]; for(auto&& g : current_generation){ if(g.second <= best.second){ best = g; } } // continue with the best as parent current_generation[0] = best; int count = 0; for(auto& g : subrange(current_generation, 1)){ count++; g = best; for(int j = 0; j < count; ++j){ while(!g.first.mutate_random_bit()){} } g.second = -1; } }
void trmv_impl( matrix_expression<TriangularA> const& A, vector_expression<V> &b, boost::mpl::false_, column_major ){ std::size_t size = A().size1(); for (std::size_t n = 1; n <= size; ++n) { std::size_t i = size-n; double bi = b()(i); if(!Unit){ b()(i) *= A()(i,i); } noalias(subrange(b,i+1,size))+= bi * subrange(column(A,i),i+1,size); } }
void Tokenizer::TokenizeByPreidentified(bool enclosed, const TokenRange& range) { std::vector<TokenRange> preidentified_tokens; keyword_manager.Peek(filename_, range, elements_, preidentified_tokens); size_t offset = range.offset; TokenRange subrange(range.offset, 0); while (offset < range.offset + range.size) { for (const auto& preidentified_token : preidentified_tokens) { if (offset == preidentified_token.offset) { if (subrange.size > 0) TokenizeByDelimiters(enclosed, subrange); AddToken(kIdentifier, enclosed, preidentified_token); subrange.offset = preidentified_token.offset + preidentified_token.size; offset = subrange.offset - 1; // It's going to be incremented below break; } } subrange.size = ++offset - subrange.offset; } // Either there was no preidentified token range, or we're now about to // process the tail of our current range. if (subrange.size > 0) TokenizeByDelimiters(enclosed, subrange); }
inline void bi::exp_vector(V2 x, const V3& is) { BOOST_AUTO(iter, is.begin()); BOOST_AUTO(end, is.end()); for (; iter != end; ++iter) { BOOST_AUTO(elem, subrange(x, *iter, 1)); exp_elements(elem, elem); } }
void trmv_impl( matrix_expression<TriangularA> const& A, vector_expression<V> &b, boost::mpl::false_, row_major ){ typedef typename TriangularA::value_type value_typeA; typedef typename V::value_type value_typeV; std::size_t size = A().size1(); std::size_t const blockSize = 128; std::size_t numBlocks = size/blockSize; if(numBlocks*blockSize < size) ++numBlocks; //this implementation partitions A into //a set of panels, where a Panel is a set // of columns. We start with the last panel //and compute the product of it with the part of the vector // and than just add the previous panel on top etc. //tmporary storage for subblocks of b value_typeV valueStorage[blockSize]; for(std::size_t bi = 1; bi <= numBlocks; ++bi){ std::size_t startbi = blockSize*(numBlocks-bi); std::size_t sizebi = std::min(blockSize,size-startbi); dense_vector_adaptor<value_typeA> values(valueStorage,sizebi); //store and save the values of b we are now changing noalias(values) = subrange(b,startbi,startbi+sizebi); //multiply with triangular element for (std::size_t i = 0; i != sizebi; ++i) { std::size_t posi = startbi+i; b()(posi) = 0; for(std::size_t j = 0; j < i; ++j){ b()(posi) += A()(posi,startbi+j)*values(j); } b()(posi) += values(i)*(Unit? value_typeA(1):A()(posi,posi)); } //now compute the remaining inner products for(std::size_t posi = startbi+sizebi; posi != size; ++posi){ b()(posi) += inner_prod(values,subrange(row(A,posi),startbi,startbi+sizebi)); } } }
void trmv_impl( matrix_expression<TriangularA> const& A, vector_expression<V>& b, boost::mpl::true_, column_major ){ typedef typename TriangularA::value_type value_typeA; typedef typename V::value_type value_typeV; std::size_t size = A().size1(); std::size_t const blockSize = 128; std::size_t numBlocks = size/blockSize; if(numBlocks*blockSize < size) ++numBlocks; //this implementation partitions A into //a set of panels, where a Panel is a set // of rows. We start with the first panel //and compute the product of it with the part of the vector // and than just add the next panel on top etc. //tmporary storage for subblocks of b value_typeV valueStorage[blockSize]; for(std::size_t bj = 0; bj != numBlocks; ++bj){ std::size_t startbj = blockSize*bj; std::size_t sizebj = std::min(blockSize,size-startbj); dense_vector_adaptor<value_typeA> values(valueStorage,sizebj); //store and save the values of b we are now changing noalias(values) = subrange(b,startbj,startbj+sizebj); subrange(b,startbj,startbj+sizebj).clear(); //multiply with triangular element for (std::size_t j = 0; j != sizebj; ++j) { std::size_t posj = startbj+j; for(std::size_t i = 0; i < j; ++i){ b()(startbj+i) += A()(startbj+i,posj)*values(j); } b()(posj) += values(j)*(Unit? 1.0:A()(posj,posj)); } //now compute the remaining inner products for(std::size_t posj = startbj+sizebj; posj != size; ++posj){ noalias(subrange(b,startbj,startbj+sizebj)) += b()(posj)*subrange(column(A,posj),startbj,startbj+sizebj); } } }
double serial_norm_inf (const boost::numeric::ublas::vector <double> &lhs, int length) { #ifdef HAVE_BLAS int i = from_blas::idamax (length, &lhs(0), 1); double ret = lhs(i); #else double ret = norm_inf (subrange (lhs, 0, length)); #endif return ret; }
const py_vector particle_momentum(ParticleState const &ps) { const unsigned vdim = ps.vdim(); py_vector result(vdim); result.clear(); for (particle_number pn = 0; pn < ps.particle_count; pn++) result += subrange(ps.momenta, vdim*pn, vdim*(pn+1)); return result; }
const py_vector particle_current(ParticleState const &ps, py_vector const &velocities, double length) { const unsigned vdim = ps.vdim(); py_vector result(vdim); result.clear(); for (particle_number pn = 0; pn < ps.particle_count; pn++) result += ps.charges[pn] * subrange(velocities, vdim*pn, vdim*(pn+1)); return result / length; }
void trsv_impl( matrix_expression<TriangularA> const& A, vector_expression<V> &b, boost::mpl::true_, row_major ) { SIZE_CHECK(A().size1() == A().size2()); SIZE_CHECK(A().size2() == b().size()); typedef typename TriangularA::value_type value_type; std::size_t size = A().size1(); for (std::size_t i = 0; i < size; ++ i) { std::size_t n = size-i-1; matrix_row<TriangularA const> matRow = row(A(),n); b()(n) -= inner_prod(subrange(matRow,n+1,size),subrange(b(),n+1,size)); if(!Unit){ RANGE_CHECK(A()(n, n) != value_type());//matrix is singular b()(n) /= A()(n, n); } } }
void trsv_impl( matrix_expression<MatA, cpu_tag> const& A, vector_expression<V, cpu_tag> &b, boost::mpl::false_, row_major ) { SIZE_CHECK(A().size1() == A().size2()); SIZE_CHECK(A().size2() == b().size()); typedef typename MatA::value_type value_type; std::size_t size = b().size(); for (std::size_t n = 0; n < size; ++ n) { auto matRow = row(A(),n); b()(n) -= inner_prod(subrange(matRow,0,n),subrange(b(),0,n)); if(!Unit){ RANGE_CHECK(A()(n, n) != value_type());//matrix is singular b()(n) /= A()(n, n); } } }
void trsv_impl( matrix_expression<MatA, cpu_tag> const& A, vector_expression<V, cpu_tag> &b, boost::mpl::false_, column_major ) { SIZE_CHECK(A().size1() == A().size2()); SIZE_CHECK(A().size2() == b().size()); typedef typename MatA::value_type value_type; std::size_t size = b().size(); for (std::size_t n = 0; n != size; ++ n) { if(!Unit){ RANGE_CHECK(A()(n, n) != value_type());//matrix is singular b()(n) /= A()(n, n); } if (b()(n) != value_type/*zero*/()){ auto col = column(A(),n); noalias(subrange(b(),n+1,size)) -= b()(n) * subrange(col,n+1,size); } } }
void trsv_impl( matrix_expression<TriangularA> const& A, vector_expression<V> &b, boost::mpl::true_, column_major ) { SIZE_CHECK(A().size1() == A().size2()); SIZE_CHECK(A().size2() == b().size()); typedef typename TriangularA::value_type value_type; std::size_t size = b().size(); for (std::size_t i = 0; i < size; ++ i) { std::size_t n = size-i-1; if(!Unit){ RANGE_CHECK(A()(n, n) != value_type());//matrix is singular b()(n) /= A()(n, n); } if (b()(n) != value_type/*zero*/()) { matrix_column<TriangularA const> col = column(A(),n); noalias(subrange(b(),0,n)) -= b()(n) * subrange(col,0,n); } } }
main(int argc, char* argv[]){ int k,n,i,j; std::string op=argv[1]; // command line argument val dx=1.0/K, dt=T/N, dx4=dx*dx*dx*dx, xk, tn; // discretization variables val rho=NU*dt/dx4; // rho = nu*dt/dx^4 static vec u(K-1), v(K+1); // We allocate 2 lower & 4 upper diagonal, according to the example static banded_matrix<val> U(K-1, K-1, 2, 4); vector<fortran_int_t> p(K-1); // Initialize matrix for(i=0; i<U.size1(); i++){ U(i,i)=1.0+6.0*rho; k=std::max(i-1,1); U(k,k-1)=U(k-1,k)=-4.0*rho; U(k,k+1)=U(k+1,k)=-4.0*rho; k=std::max(i-2,2); U(k,k-2)=U(k-2,k)=1.0*rho; U(k,k+2)=U(k+2,k)=1.0*rho; } // Boundary Conditions U(0,0)-=1.0*rho; U(K-2,K-2)-=1.0*rho; if(op=="matrix"){ printf("Pentadiagonal Matrix\n"); matprintf(U);} // Initial conditions for(k=0;k<=K;k++){ xk=k*dx; v(k)=f(xk); } u=subrange(v,1,K); //printf("Original Vector\n"); vecprintf(u,dx); lapack::gbtrf(U, p); // LU-decompostion for(n=0;n<=N;n++){ tn=n*dt; lapack::gbtrs(U, p, u); // Solve if(op=="plot0") plot0(u, tn, K-1, N); if(op=="plot1") plot1(u, tn, K-1, N); if(op=="plot3d" && (n-1)%NMOD==0) plot3d(u, tn, K-1, N); if(op=="approx") output(tn, 0.5, u(K/2-1), K-1, N); } return 0; }
const py_vector kinetic_energies(ParticleState const &ps, double vacuum_c) { const unsigned vdim = ps.vdim(); py_vector result(ps.particle_count); const double c_squared = vacuum_c*vacuum_c; for (particle_number pn = 0; pn < ps.particle_count; pn++) { const unsigned vpstart = vdim*pn; const unsigned vpend = vdim*(pn+1); const double m = ps.masses[pn]; double p = norm_2(subrange(ps.momenta, vpstart, vpend)); double v = vacuum_c*p/sqrt(m*m*c_squared + p*p); result[pn] = (p/v-m)*c_squared; } return result; }
char *range(char *start, char *end) { unsigned char startipc[4], endipc[4]; unsigned int startip[4], endip[4]; int retcount = 0; int i; cprintf("start=[%s] end=[%s]\n", start, end); strcpy(range_buf, ""); retcount = sscanf(start, "%u.%u.%u.%u", &startip[0], &startip[1], &startip[2], &startip[3]); retcount += sscanf(end, "%u.%u.%u.%u", &endip[0], &endip[1], &endip[2], &endip[3]); if (retcount != 8) { printf("Error ip address!\n"); } for (i = 0; i < 4; i++) { if ((startip[i] > 255) || (endip[i] > 255) || (startip[i] > endip[i])) { printf("Out of range!\n"); } startipc[i] = (unsigned char)startip[i]; endipc[i] = (unsigned char)endip[i]; } subrange(startipc, endipc); cprintf("range_buf=[%s]\n", range_buf); return (char *)&range_buf; }
const char * translate_type (pascal_type type, const void * type_ptr) { const char * ret = 0; switch (type) { case NAMED_TYPE_NODE: ret = (NT->name->s_translated_type ? NT->name->s_translated_type : NT->name->s_repr); out_s (ret); break; case BOOLEAN_TYPE: NT->name->s_repr = "C4P_boolean"; out_s ("C4P_boolean"); break; case CHARACTER_TYPE: NT->name->s_repr = "char"; out_s ("char"); break; case INTEGER_TYPE: NT->name->s_repr = "C4P_integer"; out_s ("C4P_integer"); break; case LONG_INTEGER_TYPE: NT->name->s_repr = "C4P_longinteger"; out_s ("C4P_longinteger"); break; case REAL_TYPE: NT->name->s_repr = "float"; out_s ("float"); break; case LONG_REAL_TYPE: NT->name->s_repr = "double"; out_s ("double"); break; case ARRAY_NODE: ret = translate_type (ARR->component_type, ARR->component_type_ptr); break; case POINTER_NODE: #if 1 ret = translate_type (PTR->component_type, PTR->component_type_ptr); #else ret = translate_type (PTR->component_type, PTR->component_type_ptr); #endif break; case SUBRANGE_NODE: ret = subrange (SUB->lower_bound, SUB->upper_bound); out_s (ret); break; case RECORD_NODE: out_s ("struct {\n"); ++ curly_brace_level; translate_type (FIELD_LIST_NODE, REC->field_list); -- curly_brace_level; out_s ("}"); break; case FIELD_LIST_NODE: if (FL->fixed_part != 0) { translate_type (RECORD_SECTION_NODE, FL->fixed_part); } if (FL->variant_part != 0) { translate_type (VARIANT_NODE, FL->variant_part); } break; case RECORD_SECTION_NODE: declare_var_list (RS->name, FIELD_IDENTIFIER, UINT_MAX, RS->type, RS->type_ptr); out_s (";\n"); if (RS->next != 0) { translate_type (RECORD_SECTION_NODE, RS->next); } break; case VARIANT_NODE: out_s ("union {\n"); ++ curly_brace_level; if (V->variant_field_list != 0) { translate_type (VARIANT_FIELD_LIST_NODE, V->variant_field_list); } -- curly_brace_level; out_form ("} %s;\n", V->pseudo_name->s_repr); break; case VARIANT_FIELD_LIST_NODE: if (VFL->pseudo_name != 0) { out_s ("struct {\n"); ++ curly_brace_level; } if (VFL->fixed_part != 0) { translate_type (RECORD_SECTION_NODE, VFL->fixed_part); } if (VFL->variant_part != 0) { translate_type (VARIANT_NODE, VFL->variant_part); } if (VFL->pseudo_name != 0) { -- curly_brace_level; out_form ("} %s;\n", VFL->pseudo_name->s_repr); } if (VFL->next != 0) { translate_type (VARIANT_FIELD_LIST_NODE, VFL->next); } break; case FILE_NODE: if (FIL->type == CHARACTER_TYPE || (FIL->type == NAMED_TYPE_NODE && (((named_type_node *) FIL->type_ptr)->name->s_type == CHARACTER_TYPE))) { out_s ("C4P_text"); } else { out_s ("C4P_FILE_STRUCT("); translate_type (FIL->type, FIL->type_ptr); out_s (")"); } FIL->type = flatten_type(FIL->type, FIL->type_ptr, &FIL->type_ptr); break; default: c4p_error ("internal error: translate_type: unknown node type: %u", type); } return (ret); }
boost::tiny_xml::element_ptr generate_entry(const Range& range, const std::string* pcategory, int level = 0, const boost::regex* primary_key = 0) { boost::tiny_xml::element_ptr list = add_attribute(add_attribute(::add_attribute(make_element("itemizedlist"), "mark", "none"), "spacing", "compact"), "role", "index"); for(typename boost::range_iterator<Range>::type i = boost::begin(range); i != boost::end(range);) { std::string key = (*i)->key; index_entry_set entries; bool preferred = false; std::string id; bool collapse = false; // // Create a regular expression for comparing key to other key's: // boost::regex key_regex; if(level == 0) { key_regex = make_primary_key_matcher(key); primary_key = &key_regex; } // // Begin by consolidating entries with identical keys but possibly different categories: // while((i != boost::end(range)) && ((*i)->key == key)) { if((0 == pcategory) || (pcategory->size() == 0) || (pcategory && (**i).category == *pcategory)) { entries.insert((*i)->sub_keys.begin(), (*i)->sub_keys.end()); if((*i)->preferred) preferred = true; if((*i)->id.size()) { if(id.size()) { std::cerr << "WARNING: two identical index terms have different link destinations!!" << std::endl; } id = (*i)->id; } } ++i; } // // Only actually generate content if we have anything in the entries set: // if(entries.size() || id.size()) { // // See if we can collapse any sub-entries into this one: // if(entries.size() == 1) { if((regex_match((*entries.begin())->key, *primary_key) || ((*entries.begin())->key == key)) && ((*entries.begin())->id.size()) && ((*entries.begin())->id != id)) { collapse = true; id = (*entries.begin())->id; } } // // See if this key is the same as the primary key, if it is then make it prefered: // if(level && regex_match(key, *primary_key)) { preferred = true; } boost::tiny_xml::element_ptr item = make_element("listitem"); boost::tiny_xml::element_ptr para = make_element("para"); item->elements.push_back(para); list->elements.push_back(item); if(preferred) { para->elements.push_back(make_element("emphasis")); para = para->elements.back(); } if(id.size()) { boost::tiny_xml::element_ptr link = add_attribute(make_element("link"), "linkend", id); para->elements.push_back(link); para = link; } std::string classname = (boost::format("index-entry-level-%1%") % level).str(); para->elements.push_back(add_attribute(make_element("phrase"), "role", classname)); para = para->elements.back(); para->content = key; if(!collapse && entries.size()) { std::pair<index_entry_set::const_iterator, index_entry_set::const_iterator> subrange(entries.begin(), entries.end()); item->elements.push_back(generate_entry(subrange, 0, level+1, primary_key)); } } } return list; }
void bi::Cache::setDirty(const int p, const int len, const bool dirty) { /* pre-condition */ BI_ASSERT(p >= 0 && p + len <= (int )dirties.size()); set_elements(subrange(dirties, p, len), dirty); }
bool bi::Cache::isDirty(const int p, const int len) const { BOOST_AUTO(tmp, subrange(dirties, p, len)); return std::find(tmp.begin(), tmp.end(), true) != tmp.end(); }
void bi::Cache::setValid(const int p, const int len, const bool valid) { /* pre-condition */ BI_ASSERT(p >= 0 && p + len <= (int )valids.size()); set_elements(subrange(valids, p, len), valid); }
bool bi::Cache::isValid(const int p, const int len) const { BOOST_AUTO(tmp, subrange(valids, p, len)); return std::find(tmp.begin(), tmp.end(), false) == tmp.end(); }