// ScaledDimensions returns the newWidth and newHeight obtained
// when an image of dimensions w x h has to be rescaled under
// mw x mh, while conserving the proportions.
// It returns 1,1 if any of the parameter is 0.
169482
func ScaledDimensions(w, h, mw, mh int) (newWidth int, newHeight int) {
	if w == 0 || h == 0 || mw == 0 || mh == 0 {
		imageDebug("ScaledDimensions was given as 0; returning 1x1 as dimensions.")
		return 1, 1
	}
	newWidth, newHeight = mw, mh
	if float32(h)/float32(mh) > float32(w)/float32(mw) {
		newWidth = w * mh / h
	} else {
		newHeight = h * mw / w
	}
	return
}
547878
func Dimensions(width, height float64) PrintToPDFOption {
	return func(o map[string]interface{}) {
		o["paperWidth"] = width
		o["paperHeight"] = height
	}
}
682718
func (s *SegmentGroup) SetDimensions(v []*SegmentDimensions) *SegmentGroup {
	s.Dimensions = v
	return s
}
1259731
func (mat *T) Scaled(f float64) T {
	r := *mat
	return *r.Scale(f)
}
787821
func (mat *T) Scaled(f float32) T {
	result := *mat
	result.Scale(f)
	return result
}
983819
func BuildDimensions(mTags map[string]string) []*cloudwatch.Dimension {
	const MaxDimensions = 10
	dimensions := make([]*cloudwatch.Dimension, 0, MaxDimensions)

	// This is pretty ugly but we always want to include the "host" tag if it exists.
	if host, ok := mTags["host"]; ok {
		dimensions = append(dimensions, &cloudwatch.Dimension{
			Name:  aws.String("host"),
			Value: aws.String(host),
		})
	}

	var keys []string
	for k := range mTags {
		if k != "host" {
			keys = append(keys, k)
		}
	}
	sort.Strings(keys)

	for _, k := range keys {
		if len(dimensions) >= MaxDimensions {
			break
		}

		value := mTags[k]
		if value == "" {
			continue
		}

		dimensions = append(dimensions, &cloudwatch.Dimension{
			Name:  aws.String(k),
			Value: aws.String(mTags[k]),
		})
	}

	return dimensions
}
331770
func (mat *T) Scaling() vec3.T {
	return vec3.T{mat[0][0], mat[1][1], mat[2][2]}
}
398742
func (p *Parser) parseDimensions() (Dimensions, error) {
	// If the next token is not GROUP then exit.
	if tok, _, _ := p.ScanIgnoreWhitespace(); tok != GROUP {
		p.Unscan()
		return nil, nil
	}

	// Now the next token should be "BY".
	if tok, pos, lit := p.ScanIgnoreWhitespace(); tok != BY {
		return nil, newParseError(tokstr(tok, lit), []string{"BY"}, pos)
	}

	var dimensions Dimensions
	for {
		// Parse the dimension.
		d, err := p.parseDimension()
		if err != nil {
			return nil, err
		}

		// Add new dimension.
		dimensions = append(dimensions, d)

		// If there's not a comma next then stop parsing dimensions.
		if tok, _, _ := p.Scan(); tok != COMMA {
			p.Unscan()
			break
		}
	}
	return dimensions, nil
}
1332741
func (w *WithDimensions) Datapoints() []*datapoint.Datapoint {
	return w.appendDimensions(w.Collector.Datapoints())
}
44368
func (co *Context) ScaleTensor(yDesc *TensorDescriptor, y Memory, alpha float64) error {
	var alphaC unsafe.Pointer
	switch yDesc.dataType {
	case Float, Half:
		var alphaF C.float
		alphaF = C.float(float32(alpha))
		alphaC = unsafe.Pointer(&alphaF)
	case Double:
		var alphaF C.double
		alphaF = C.double(alpha)
		alphaC = unsafe.Pointer(&alphaF)
	default:
		return errors.Errorf("Unsupported data type: %v", yDesc.dataType)
	}
	// call cudnnScaleTensor
	return result(C.cudnnScaleTensor(co.internal, yDesc.internal, y.Pointer(), alphaC))
}
90580
func (f *File) ajustSingleRowDimensions(r *xlsxRow, num int) {
	r.R = num
	for i, col := range r.C {
		colName, _, _ := SplitCellName(col.R)
		r.C[i].R, _ = JoinCellName(colName, num)
	}
}
300995
func (obj *GenericDimension) GetDimension(ctx context.Context) (*NxLibraryDimensionDef, error) {
	result := &struct {
		Dim *NxLibraryDimensionDef	`json:"qDim"`
	} {}
	err := obj.rpc(ctx, "GetDimension", result)
	return result.Dim, err 
}
26995
func (m *Matrix) Dimensions() []int {
	r := make([]int, len(m.dims))
	copy(r, m.dims)
	return r
}
1262317
func Scale(a []float64, s float64) {
	for i, v := range a {
		a[i] = v * s
	}
}
65156
func (mat *T) Scaling() vec4.T {
	return vec4.T{mat[0][0], mat[1][1], mat[2][2], mat[3][3]}
}
327006
func (p *BarChart) ScaleXYs(xWidth int, s ScaleFunc) []XYf {

	diff := p.MaxX - p.MinX
	scaleX := float64(diff) / float64(xWidth-1)

	buckets := make([]XYf, xWidth)
	for i := range buckets {
		buckets[i] = XYf{
			X:       float64(i)*scaleX + float64(p.MinX),
			Y:       nil,
			ScaledY: nil,
		}
	}

	miny, maxy := float64(p.xy[0].Y), float64(p.xy[0].Y)

	for _, val := range p.xy {
		minx := float64(p.MinX)
		xdiff := float64(val.X) - minx
		bi := int(xdiff / scaleX)

		slot := buckets[bi]
		if slot.Y == nil {
			slot.Y = new(float64)
			slot.ScaledY = new(float64)
		}
		y := float64(val.Y)
		*slot.Y += y
		miny = math.Min(*slot.Y, miny)
		maxy = math.Max(*slot.Y, maxy)
		buckets[bi] = slot
	}

	for _, val := range buckets {
		if val.Y == nil {
			continue
		}
		*val.ScaledY = s(miny, maxy, *val.Y)
	}

	return buckets
}
306744
func (s *Metric) SetDimensions(v []*Dimension) *Metric {
	s.Dimensions = v
	return s
}