gonum.org/v1/gonum@v0.14.0/lapack/gonum/dlasrt.go (about) 1 // Copyright ©2015 The Gonum Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package gonum 6 7 import ( 8 "sort" 9 10 "gonum.org/v1/gonum/lapack" 11 ) 12 13 // Dlasrt sorts the numbers in the input slice d. If s == lapack.SortIncreasing, 14 // the elements are sorted in increasing order. If s == lapack.SortDecreasing, 15 // the elements are sorted in decreasing order. For other values of s Dlasrt 16 // will panic. 17 // 18 // Dlasrt is an internal routine. It is exported for testing purposes. 19 func (impl Implementation) Dlasrt(s lapack.Sort, n int, d []float64) { 20 switch { 21 case n < 0: 22 panic(nLT0) 23 case len(d) < n: 24 panic(shortD) 25 } 26 27 d = d[:n] 28 switch s { 29 default: 30 panic(badSort) 31 case lapack.SortIncreasing: 32 sort.Float64s(d) 33 case lapack.SortDecreasing: 34 sort.Sort(sort.Reverse(sort.Float64Slice(d))) 35 } 36 }