github.com/gonum/lapack@v0.0.0-20181123203213-e4cdc5a0bff9/native/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 native
     6  
     7  import (
     8  	"sort"
     9  
    10  	"github.com/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  	checkVector(n, d, 1)
    21  	d = d[:n]
    22  	switch s {
    23  	default:
    24  		panic(badSort)
    25  	case lapack.SortIncreasing:
    26  		sort.Float64s(d)
    27  	case lapack.SortDecreasing:
    28  		sort.Sort(sort.Reverse(sort.Float64Slice(d)))
    29  	}
    30  }