Range* DOMSelection::getRangeAt(int index, ExceptionState& exceptionState) { if (!isAvailable()) return nullptr; if (index < 0 || index >= rangeCount()) { exceptionState.throwDOMException( IndexSizeError, String::number(index) + " is not a valid index."); return nullptr; } // If you're hitting this, you've added broken multi-range selection support DCHECK_EQ(rangeCount(), 1); Position anchor = anchorPosition(visibleSelection()); if (!anchor.anchorNode()->isInShadowTree()) return frame()->selection().firstRange(); Node* node = shadowAdjustedNode(anchor); if (!node) // crbug.com/595100 return nullptr; if (!visibleSelection().isBaseFirst()) return Range::create(*anchor.document(), focusNode(), focusOffset(), node, anchorOffset()); return Range::create(*anchor.document(), node, anchorOffset(), focusNode(), focusOffset()); }
void dimEst(matrix x, unint s){ unint n = x.r; unint i,j ; int t = 3; long unsigned int curMax, oldMax; matrix r; r.c=x.c; r.pc=x.pc; r.r=s; r.pr=CPAD(s); r.ld=r.pc; r.mat = (real*)calloc( r.pc*r.pr, sizeof(*r.mat) ); size_t** NNs = (size_t**)calloc(r.r, sizeof(*NNs)); real** dToNNs = (real**)calloc(r.r, sizeof(*dToNNs)); for(i=0;i<r.pr;i++){ NNs[i] = (size_t*)calloc(t, sizeof(**NNs)); dToNNs[i] = (real*)calloc(t, sizeof(**dToNNs)); } real* ranges = (real*)calloc(r.pr, sizeof(*ranges)); unint *counts = (unint*)calloc(r.pr,sizeof(*counts)); size_t *p = (size_t*)calloc(r.pr, sizeof(*p)); //pick r random reps pickReps(x,&r); //printf("calling bruteKdists\n"); bruteKDists(x,r,NNs,dToNNs,t); // printf("done\n"); for(i=0;i<r.r;i++) ranges[i] = dToNNs[i][t-1]; for(i=0; i<10; i++){ rangeCount(x,r,ranges,counts); //gsl_sort_uint_index(p,counts,1,r.r); //printf("80 = %u \n",counts[p[5*r.r/10]]); for(j=0; j<r.r; j++) ranges[j]*=2.0; curMax = 0; unint avg = 0; for(j=0; j<r.r; j++){ // printf("%u ",counts[j]); curMax = MAX(counts[j],curMax); avg +=counts[j]; } // printf("\n"); // printf("avg = %6.4f \n",((double)avg)/((double)r.r)); // printf("%lu \n",curMax); } for(i=0;i<r.r;i++){ free(NNs[i]); free(dToNNs[i]); } free(NNs); free(dToNNs); free(r.mat); free(ranges); free(counts); free(p); }
RefPtr<Range> DOMSelection::getRangeAt(unsigned index, ExceptionCode& ec) { if (!m_frame) return nullptr; if (index >= rangeCount()) { ec = INDEX_SIZE_ERR; return nullptr; } // If you're hitting this, you've added broken multi-range selection support ASSERT(rangeCount() == 1); if (Node* shadowAncestor = selectionShadowAncestor(m_frame)) { ContainerNode* container = shadowAncestor->parentNodeGuaranteedHostFree(); unsigned offset = shadowAncestor->computeNodeIndex(); return Range::create(shadowAncestor->document(), container, offset, container, offset); } return m_frame->selection().selection().firstRange(); }
PassRefPtrWillBeRawPtr<Range> DOMSelection::getRangeAt(int index, ExceptionState& exceptionState) { if (!m_frame) return nullptr; if (index < 0 || index >= rangeCount()) { exceptionState.throwDOMException(IndexSizeError, String::number(index) + " is not a valid index."); return nullptr; } // If you're hitting this, you've added broken multi-range selection support ASSERT(rangeCount() == 1); Position anchor = anchorPosition(visibleSelection()); if (!anchor.anchorNode()->isInShadowTree()) return m_frame->selection().firstRange(); if (!visibleSelection().isBaseFirst()) return Range::create(*anchor.document(), focusNode(), focusOffset(), shadowAdjustedNode(anchor), anchorOffset()); return Range::create(*anchor.document(), shadowAdjustedNode(anchor), anchorOffset(), focusNode(), focusOffset()); }
PassRefPtr<Range> DOMSelection::getRangeAt(int index, ExceptionCode& ec) { if (!m_frame) return 0; if (index < 0 || index >= rangeCount()) { ec = INDEX_SIZE_ERR; return 0; } // If you're hitting this, you've added broken multi-range selection support ASSERT(rangeCount() == 1); if (Node* shadowAncestor = selectionShadowAncestor(m_frame)) { Node* container = shadowAncestor->parentNode(); int offset = shadowAncestor->nodeIndex(); return Range::create(shadowAncestor->document(), container, offset, container, offset); } const VisibleSelection& selection = m_frame->selection()->selection(); return selection.firstRange(); }
PassRefPtrWillBeRawPtr<Range> DOMSelection::getRangeAt(int index, ExceptionState& exceptionState) { if (!m_frame) return nullptr; if (index < 0 || index >= rangeCount()) { exceptionState.throwDOMException(IndexSizeError, String::number(index) + " is not a valid index."); return nullptr; } // If you're hitting this, you've added broken multi-range selection support ASSERT(rangeCount() == 1); if (Node* shadowAncestor = selectionShadowAncestor(m_frame)) { ASSERT(!shadowAncestor->isShadowRoot()); ContainerNode* container = shadowAncestor->parentOrShadowHostNode(); int offset = shadowAncestor->nodeIndex(); return Range::create(shadowAncestor->document(), container, offset, container, offset); } return m_frame->selection().firstRange(); }
PassRefPtr<Range> DOMSelection::getRangeAt(int index, ExceptionState& exceptionState) { if (!m_frame) return 0; if (index < 0 || index >= rangeCount()) { exceptionState.throwDOMException(IndexSizeError, String::number(index) + " is not a valid index."); return 0; } // If you're hitting this, you've added broken multi-range selection support ASSERT(rangeCount() == 1); if (Node* shadowAncestor = selectionShadowAncestor(m_frame)) { ContainerNode* container = shadowAncestor->parentNodeGuaranteedHostFree(); int offset = shadowAncestor->nodeIndex(); return Range::create(shadowAncestor->document(), container, offset, container, offset); } const VisibleSelection& selection = m_frame->selection().selection(); return selection.firstRange(); }
void evalApprox(matrix q, matrix x, unint *NNs){ real *ranges = (real*)calloc(q.pr, sizeof(*ranges)); unint *counts = (unint*)calloc(q.pr,sizeof(*counts)); unint i; for(i=0; i<q.r; i++) ranges[i] = distVec(q,x,i,NNs[i]); rangeCount(x,q,ranges,counts); double avgCount = 0.0; for(i=0; i<q.r; i++) avgCount += ((double)counts[i]); avgCount/=q.r; printf("average num closer = %6.5f \n",avgCount); free(counts); free(ranges); }