File: dlasrt.go

package info (click to toggle)
golang-gonum-v1-gonum 0.15.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 18,792 kB
  • sloc: asm: 6,252; fortran: 5,271; sh: 377; ruby: 211; makefile: 98
file content (36 lines) | stat: -rw-r--r-- 882 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright ©2015 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package gonum

import (
	"sort"

	"gonum.org/v1/gonum/lapack"
)

// Dlasrt sorts the numbers in the input slice d. If s == lapack.SortIncreasing,
// the elements are sorted in increasing order. If s == lapack.SortDecreasing,
// the elements are sorted in decreasing order. For other values of s Dlasrt
// will panic.
//
// Dlasrt is an internal routine. It is exported for testing purposes.
func (impl Implementation) Dlasrt(s lapack.Sort, n int, d []float64) {
	switch {
	case n < 0:
		panic(nLT0)
	case len(d) < n:
		panic(shortD)
	}

	d = d[:n]
	switch s {
	default:
		panic(badSort)
	case lapack.SortIncreasing:
		sort.Float64s(d)
	case lapack.SortDecreasing:
		sort.Sort(sort.Reverse(sort.Float64Slice(d)))
	}
}