// Normalize normalizes the vector to unit length.
548249
func (vec *T) Normalize() *T {
	sl := vec.LengthSqr()
	if sl == 0 || sl == 1 {
		return vec
	}
	return vec.Scale(1 / math.Sqrt(sl))
}
927225
func (lrs *LinearRegressionSeries) normalize(xvalue float64) float64 {
	return (xvalue - lrs.avgx) / lrs.stddevx
}
99947
func normalize(name string) (string, error) {
	host, remoteName := splitHostname(name)
	if strings.ToLower(remoteName) != remoteName {
		return "", errors.New("invalid reference format: repository name must be lowercase")
	}
	if host == DefaultHostname {
		if strings.HasPrefix(remoteName, DefaultRepoPrefix) {
			return strings.TrimPrefix(remoteName, DefaultRepoPrefix), nil
		}
		return remoteName, nil
	}
	return name, nil
}
1305725
func Normalize(senml SenML) SenML {
	var bname string = ""
	var btime float64 = 0
	var bunit string = ""
	var ver = 5
	var ret SenML

	var totalRecords int = 0
	for _, r := range senml.Records {
		if (r.Value != nil) || (len(r.StringValue) > 0) || (len(r.DataValue) > 0) || (r.BoolValue != nil) {
			totalRecords += 1
		}
	}

	ret.XMLName = senml.XMLName
	ret.Xmlns = senml.Xmlns
	ret.Records = make([]SenMLRecord, totalRecords)
	var numRecords = 0

	for _, r := range senml.Records {
		if r.BaseTime != 0 {
			btime = r.BaseTime
		}
		if r.BaseVersion != 0 {
			ver = r.BaseVersion
		}
		if len(r.BaseUnit) > 0 {
			bunit = r.BaseUnit
		}
		if len(r.BaseName) > 0 {
			bname = r.BaseName
		}
		r.BaseTime = 0
		r.BaseUnit = ""
		r.BaseName = ""
		r.Name = bname + r.Name
		r.Time = btime + r.Time
		if len(r.Unit) == 0 {
			r.Unit = bunit
		}
		r.BaseVersion = ver

		if r.Time <= 0 {
			// convert to absolute time
			var now int64 = time.Now().UnixNano()
			var t int64 = now / 1000000000.0
			r.Time = float64(t) + r.Time
		}

		if (r.Value != nil) || (len(r.StringValue) > 0) || (len(r.DataValue) > 0) || (r.BoolValue != nil) {
			ret.Records[numRecords] = r
			numRecords += 1
		}
	}

	return ret
}
81711
func (s *stateV4) normalize() {
	sort.Stable(sortResourcesV4(s.Resources))
	for _, rs := range s.Resources {
		sort.Stable(sortInstancesV4(rs.Instances))
	}
}
695499
func (s *Schema) Normalize() error {
	if s == nil {
		return errors.New("is nil")
	}
	if s.Schema == nil {
		return errors.New("has no type")
	}
	if enum := s.GetEnum(); enum != nil {
		return enum.Normalize()
	}
	return nil
}
1130119
func (n *SimpleNameNormalizer) Normalize(name string) string {
	var retMe []byte
	nameBytes := []byte(name)
	for i, b := range nameBytes {
		if n.safeByte(b) {
			if retMe != nil {
				retMe[i] = b
			}
		} else {
			if retMe == nil {
				retMe = make([]byte, len(nameBytes))
				copy(retMe[0:i], nameBytes[0:i])
			}
			retMe[i] = n.Replacement
		}
	}
	if retMe == nil {
		return name
	}
	return string(retMe)
}
1000214
func normalizeImage(image string) string {
	if strings.Contains(image, ":") {
		t := strings.Split(image, ":")
		return t[0]
	}
	return image
}
1211786
func (i *Parameters_Job_Inputs) Normalize() (err error) {
	if i.Cipd == nil && len(i.Isolated) == 0 {
		return errors.New(
			"job.inputs: at least one of packages and isolated must be specified")
	}
	if i.Cipd != nil {
		if err = i.Cipd.Normalize(); err != nil {
			return
		}
	}
	return
}
1225876
func (env *EnvironmentItemModel) Normalize() error {
	opts, err := env.GetOptions()
	if err != nil {
		return err
	}
	(*env)[OptionsKey] = opts
	return nil
}
582219
func (workflow *WorkflowModel) Normalize() error {
	for _, env := range workflow.Environments {
		if err := env.Normalize(); err != nil {
			return err
		}
	}

	for _, stepListItem := range workflow.Steps {
		stepID, step, err := GetStepIDStepDataPair(stepListItem)
		if err != nil {
			return err
		}
		if err := step.Normalize(); err != nil {
			return err
		}
		stepListItem[stepID] = step
	}

	return nil
}
36343
func Normalize(cmd *cobra.Command) *cobra.Command {
	if len(cmd.Long) > 0 {
		cmd.Long = LongDesc(cmd.Long)
	}
	if len(cmd.Example) > 0 {
		cmd.Example = Examples(cmd.Example)
	}
	return cmd
}
814983
func (t *Quest_Desc_Meta_Timeouts) Normalize() error {
	if d := google.DurationFromProto(t.Start); d < 0 {
		return fmt.Errorf("desc.meta.timeouts.start < 0: %s", d)
	}
	if d := google.DurationFromProto(t.Run); d < 0 {
		return fmt.Errorf("desc.meta.timeouts.run < 0: %s", d)
	}
	if d := google.DurationFromProto(t.Stop); d < 0 {
		return fmt.Errorf("desc.meta.timeouts.stop < 0: %s", d)
	}
	return nil
}
215616
func (a Angle) Normalized() Angle {
	rad := math.Remainder(float64(a), 2*math.Pi)
	if rad <= -math.Pi {
		rad = math.Pi
	}
	return Angle(rad)
}
306007
func (d *DepsStage) Normalize() error {
	for _, d := range d.Deps {
		if err := d.Normalize(); err != nil {
			return err
		}
	}
	return nil
}
654481
func (h Host) Normalize() string {

	s := string(h)

	switch {
	case strings.HasPrefix(s, TransportTLS+"://"):
		s = s[len(TransportTLS+"://"):]
	case strings.HasPrefix(s, TransportDNS+"://"):
		s = s[len(TransportDNS+"://"):]
	case strings.HasPrefix(s, TransportGRPC+"://"):
		s = s[len(TransportGRPC+"://"):]
	}

	// The error can be ignore here, because this function is called after the corefile
	// has already been vetted.
	host, _, _, _ := SplitHostPort(s)
	return Name(host).Normalize()
}
158365
func (a Angle) Normalized() Angle {
	rad := math.Mod(float64(a), 2*math.Pi)
	if rad < 0 {
		rad += 2 * math.Pi
	}
	return Angle(rad)
}