// See cairo_xlib_device_debug_get_precision().
//
// C API documentation: http://cairographics.org/manual/cairo-XLib-Surfaces.html#cairo-xlib-device-debug-get-precision
175809
func (device *XlibDevice) DebugGetPrecision() int {
	ret := int(C.cairo_xlib_device_debug_get_precision(device.Ptr))
	if err := device.status(); err != nil {
		panic(err)
	}
	return ret
}
690830
func (surface *XlibSurface) GetDisplay() unsafe.Pointer {
	ret := unsafe.Pointer(C.cairo_xlib_surface_get_display(surface.Ptr))
	if err := surface.status(); err != nil {
		panic(err)
	}
	return ret
}
777152
func GetScreenSize() (int, int) {
	size := C.get_screen_size()
	// fmt.Println("...", size, size.width)
	return int(size.width), int(size.height)
}
1314862
func errorWithPrecision(bits uint) (latErr, lngErr float64) {
	b := int(bits)
	latBits := b / 2
	lngBits := b - latBits
	latErr = math.Ldexp(180.0, -latBits)
	lngErr = math.Ldexp(360.0, -lngBits)
	return
}
738322
func (device *XlibDevice) DebugCapXrenderVersion(majorVersion, minorVersion int) {
	C.cairo_xlib_device_debug_cap_xrender_version(device.Ptr, C.int(majorVersion), C.int(minorVersion))
	if err := device.status(); err != nil {
		panic(err)
	}
}
742885
func (s NoopClient) PrecisionTiming(stat string, delta time.Duration) error {
	return nil
}
48235
func (xa XAxis) GetValueFormatter() ValueFormatter {
	if xa.ValueFormatter != nil {
		return xa.ValueFormatter
	}
	return FloatValueFormatter
}
799461
func (cr *Context) DeviceToUser(x, y *float64) {
	C.cairo_device_to_user(cr.Ptr, (*C.double)(unsafe.Pointer(x)), (*C.double)(unsafe.Pointer(y)))
	if err := cr.status(); err != nil {
		panic(err)
	}
}
317634
func (d *MyDecimal) PrecisionAndFrac() (precision, frac int) {
	frac = int(d.digitsFrac)
	_, digitsInt := d.removeLeadingZeros()
	precision = digitsInt + frac
	if precision == 0 {
		precision = 1
	}
	return
}
427164
func GetPrecisionMultiplier(precision string) int64 {
	d := time.Nanosecond
	switch precision {
	case "us":
		d = time.Microsecond
	case "ms":
		d = time.Millisecond
	case "s":
		d = time.Second
	}
	return int64(d)
}
393046
func (m *Millipede) getPadding(i uint64) string {
	if len(m.paddingOffsets) == 0 {
		m.paddingOffsets = append(m.paddingOffsets, "")
		//m.paddingOffsets = make([]string)
		if m.Curve > 0 {
			for n := uint64(1); n < m.Curve*2; n++ {
				size := int(math.Min(float64(n%(m.Curve*2)), float64(m.Curve*2-n%(m.Curve*2))))
				m.paddingOffsets = append(m.paddingOffsets, strings.Repeat(" ", size))
			}

			// --opposite support
			if m.Opposite {
				m.paddingOffsets = append(m.paddingOffsets[m.Curve:], m.paddingOffsets[:m.Curve]...)
			}
		}
	}
	if len(m.paddingOffsets) > 0 && m.Curve > 0 {
		return m.paddingOffsets[(m.Steps+i)%(m.Curve*2)]
	}
	return ""
}
510854
func (surface *XlibSurface) GetVisual() unsafe.Pointer {
	ret := unsafe.Pointer(C.cairo_xlib_surface_get_visual(surface.Ptr))
	if err := surface.status(); err != nil {
		panic(err)
	}
	return ret
}
106551
func (ya YAxis) GetValueFormatter() ValueFormatter {
	if ya.ValueFormatter != nil {
		return ya.ValueFormatter
	}
	return FloatValueFormatter
}
1347853
func (e TabletStats) GetTabletHostPort() string {
	vtPort := e.Tablet.PortMap["vt"]
	return netutil.JoinHostPort(e.Tablet.Hostname, vtPort)
}
245307
func (v *ViewPort) GetPhysical() (int, int, int, int) {
	return v.physx, v.physy, v.physx + v.width - 1, v.physy + v.height - 1
}
761440
func compareFloat64PrecisionLoss(x, y float64) int {
	if x-y < floatEpsilon && y-x < floatEpsilon {
		return 0
	} else if x-y < 0 {
		return -1
	}
	return 1
}
1170302
func (h *Histogram) StdDev() float64 {
	if h.totalCount == 0 {
		return 0
	}

	mean := h.Mean()
	geometricDevTotal := 0.0

	i := h.iterator()
	for i.next() {
		if i.countAtIdx != 0 {
			dev := float64(h.medianEquivalentValue(i.valueFromIdx)) - mean
			geometricDevTotal += (dev * dev) * float64(i.countAtIdx)
		}
	}

	return math.Sqrt(geometricDevTotal / float64(h.totalCount))
}