From fbd14d97f3f9d9926e14df13957a60e6fccee034 Mon Sep 17 00:00:00 2001 From: btracey Date: Mon, 12 Oct 2015 23:36:34 -0600 Subject: [PATCH] Add Dlasrt --- lapack.go | 8 ++++++++ native/dlasrt.go | 27 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 native/dlasrt.go diff --git a/lapack.go b/lapack.go index fb3003cc..35c81f5a 100644 --- a/lapack.go +++ b/lapack.go @@ -50,6 +50,14 @@ const ( Backward Direct = 'B' // Reflectors are left-multiplied, H_k * ... * H_2 * H_1 ) +// Sort is the sorting order. +type Sort byte + +const ( + SortIncreasing Sort = 'I' + SortDecreasing Sort = 'D' +) + // StoreV indicates the storage direction of elementary reflectors. type StoreV byte diff --git a/native/dlasrt.go b/native/dlasrt.go new file mode 100644 index 00000000..3c9b1a78 --- /dev/null +++ b/native/dlasrt.go @@ -0,0 +1,27 @@ +// 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 native + +import ( + "sort" + + "github.com/gonum/lapack" +) + +// Dlasrt sorts the numbers in the input slice d. If sort == lapack.SortIncreasing, +// the elements are sorted in increasing order. If sort == lapack.SortDecreasing, +// the elements are sorted in decreasing order. +func (impl Implementation) Dlasrt(s lapack.Sort, n int, d []float64) { + checkVector(n, d, 1) + d = d[:n] + switch s { + default: + panic("lapack: bad sort") + case lapack.SortIncreasing: + sort.Sort(sort.Reverse(sort.Float64Slice(d))) + case lapack.SortDecreasing: + sort.Float64s(d) + } +}