// PointsToUnits converts the points to the documents unit type
347038
func (gp *GoPdf) PointsToUnits(u float64) float64 {
	return PointsToUnits(gp.config.Unit, u)
}
410776
func precomputeDistances(p PointSet) (float64, []float64) {
	total := 0.0
	dists := make([]float64, len(p)-1)
	for i := 0; i < len(p)-1; i++ {
		dists[i] = p[i].DistanceFrom(&p[i+1])
		total += dists[i]
	}

	return total, dists
}
853158
func ExplodePoints(org, bucket platform.ID, points []models.Point) ([]models.Point, error) {
	out := make([]models.Point, 0, len(points))

	// TODO(jeff): We should add a RawEncode() method or something to the platform.ID type
	// or we should use hex encoded measurement names. Either way, we shouldn't be doing a
	// decode of the encode here, and we don't want to depend on details of how the ID type
	// is represented.
	ob := EncodeName(org, bucket)
	name := string(ob[:])

	tags := make(models.Tags, 2)
	for _, pt := range points {
		tags = tags[:2]
		tags[1] = models.NewTag(MeasurementTagKeyBytes, pt.Name())
		pt.ForEachTag(func(k, v []byte) bool {
			tags = append(tags, models.NewTag(k, v))
			return true
		})

		t := pt.Time()
		itr := pt.FieldIterator()
		for itr.Next() {
			tags[0] = models.NewTag(FieldKeyTagKeyBytes, itr.FieldKey())

			var err error
			field := make(models.Fields, 1)
			switch itr.Type() {
			case models.Float:
				field[string(itr.FieldKey())], err = itr.FloatValue()
			case models.Integer:
				field[string(itr.FieldKey())], err = itr.IntegerValue()
			case models.Boolean:
				field[string(itr.FieldKey())], err = itr.BooleanValue()
			case models.String:
				field[string(itr.FieldKey())] = itr.StringValue()
			case models.Unsigned:
				field[string(itr.FieldKey())], err = itr.UnsignedValue()
			}
			if err != nil {
				return nil, err
			}

			pt, err := models.NewPoint(name, tags, field, t)
			if err != nil {
				return nil, err
			}
			out = append(out, pt)
		}
	}

	return out, nil
}
119931
func (i *FSTIterator) pointTo(key []byte) error {
	// tried to seek before start
	if bytes.Compare(key, i.startKeyInclusive) < 0 {
		key = i.startKeyInclusive
	}

	// tried to see past end
	if i.endKeyExclusive != nil &&
		bytes.Compare(key, i.endKeyExclusive) > 0 {
		key = i.endKeyExclusive
	}

	// reset any state, pointTo always starts over
	i.statesStack = i.statesStack[:0]
	i.keysStack = i.keysStack[:0]
	i.keysPosStack = i.keysPosStack[:0]
	i.valsStack = i.valsStack[:0]
	i.autStatesStack = i.autStatesStack[:0]

	root, err := i.f.decoder.stateAt(i.f.decoder.getRoot(), nil)
	if err != nil {
		return err
	}

	autStart := i.aut.Start()

	maxQ := -1
	// root is always part of the path
	i.statesStack = append(i.statesStack, root)
	i.autStatesStack = append(i.autStatesStack, autStart)
	for j := 0; j < len(key); j++ {
		keyJ := key[j]
		curr := i.statesStack[len(i.statesStack)-1]
		autCurr := i.autStatesStack[len(i.autStatesStack)-1]

		pos, nextAddr, nextVal := curr.TransitionFor(keyJ)
		if nextAddr == noneAddr {
			// needed transition doesn't exist
			// find last trans before the one we needed
			for q := curr.NumTransitions() - 1; q >= 0; q-- {
				if curr.TransitionAt(q) < keyJ {
					maxQ = q
					break
				}
			}
			break
		}
		autNext := i.aut.Accept(autCurr, keyJ)

		next, err := i.f.decoder.stateAt(nextAddr, nil)
		if err != nil {
			return err
		}

		i.statesStack = append(i.statesStack, next)
		i.keysStack = append(i.keysStack, keyJ)
		i.keysPosStack = append(i.keysPosStack, pos)
		i.valsStack = append(i.valsStack, nextVal)
		i.autStatesStack = append(i.autStatesStack, autNext)
		continue
	}

	if !i.statesStack[len(i.statesStack)-1].Final() ||
		!i.aut.IsMatch(i.autStatesStack[len(i.autStatesStack)-1]) ||
		bytes.Compare(i.keysStack, key) < 0 {
		return i.next(maxQ)
	}

	return nil
}
896188
func (r *Store) MountPoints() []string {
	mps := make([]string, 0, len(r.mounts))
	for k := range r.mounts {
		mps = append(mps, k)
	}
	sort.Sort(sort.Reverse(store.ByPathLen(mps)))
	return mps
}
1197852
func initDictLUTs() {
	// Sweep from minDictLen to maxDictLen, inclusive.
	for i := minDictLen; i <= maxDictLen; i++ {
		dictSizes[i] = 1 << uint(dictBitSizes[i])
		dictOffsets[i] = dictOffsets[i-1] + (i-1)*dictSizes[i-1]
	}
}
754931
func (e *Engine) WritePoints(points []models.Point) error {
	collection := tsdb.NewSeriesCollection(points)

	values, err := CollectionToValues(collection)
	if err != nil {
		return err
	}

	if err := e.WriteValues(values); err != nil {
		return err
	}

	return collection.PartialWriteError()
}
433150
func vecToInts(v mat.Vector) []int {
	n_obs, _ := v.Dims()
	var ints = make([]int, n_obs)
	for i := 0; i < n_obs; i++ {
		ints[i] = int(v.At(i, 0))
	}
	return ints
}
725765
func (p *PointsWriter) Next() models.Point {
	var points models.Point
	p.mu.RLock()
	if len(p.Points) == 0 {
		p.mu.RUnlock()
		return points
	}
	p.mu.RUnlock()

	p.mu.Lock()
	defer p.mu.Unlock()
	points, p.Points = p.Points[0], p.Points[1:]
	return points
}
861619
func (g *MultiPoint) Point(i int) *Point {
	return NewPointFlat(g.layout, g.Coord(i))
}
660837
func (b *Box) SizeHint() image.Point {
	var sizeHint image.Point

	for _, child := range b.children {
		size := child.SizeHint()
		if b.Alignment() == Horizontal {
			sizeHint.X += size.X
			if size.Y > sizeHint.Y {
				sizeHint.Y = size.Y
			}
		} else {
			sizeHint.Y += size.Y
			if size.X > sizeHint.X {
				sizeHint.X = size.X
			}
		}
	}

	if b.border {
		sizeHint = sizeHint.Add(image.Point{2, 2})
	}

	return sizeHint
}
843219
func typeIsPointerToStruct(typ reflect.Type) bool {
	return typ.Kind() == reflect.Ptr && typ.Elem().Kind() == reflect.Struct
}
424477
func (a *StorageAPIv3) AddToUnit(args params.StoragesAddParams) (params.ErrorResults, error) {
	v4results, err := a.addToUnit(args)
	if err != nil {
		return params.ErrorResults{}, err
	}
	v3results := make([]params.ErrorResult, len(v4results.Results))
	for i, result := range v4results.Results {
		v3results[i].Error = result.Error
	}
	return params.ErrorResults{v3results}, nil
}
1027797
func writePointer(bi *BinaryInfo, mem MemoryReadWriter, addr, val uint64) error {
	ptrbuf := make([]byte, bi.Arch.PtrSize())

	// TODO: use target architecture endianness instead of LittleEndian
	switch len(ptrbuf) {
	case 4:
		binary.LittleEndian.PutUint32(ptrbuf, uint32(val))
	case 8:
		binary.LittleEndian.PutUint64(ptrbuf, val)
	default:
		panic(fmt.Errorf("unsupported pointer size %d", len(ptrbuf)))
	}
	_, err := mem.WriteMemory(uintptr(addr), ptrbuf)
	return err
}
640973
func (s *Selection) NextUntilNodes(nodes ...*html.Node) *Selection {
	return pushStack(s, getSiblingNodes(s.Nodes, siblingNextUntil,
		nil, nodes))
}
783992
func (c *ArrayConstraint) PositionalItems(ac []Constraint) *ArrayConstraint {
	c.positionalItems = ac
	return c
}
1313323
func (f *Fpdf) PointToUnitConvert(pt float64) (u float64) {
	return pt / f.k
}