github.com/jingcheng-WU/gonum@v0.9.1-0.20210323123734-f1a2a11a8f7b/lapack/gonum/lapack.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 "github.com/jingcheng-WU/gonum/lapack"
     8  
     9  // Implementation is the native Go implementation of LAPACK routines. It
    10  // is built on top of calls to the return of blas64.Implementation(), so while
    11  // this code is in pure Go, the underlying BLAS implementation may not be.
    12  type Implementation struct{}
    13  
    14  var _ lapack.Float64 = Implementation{}
    15  
    16  func min(a, b int) int {
    17  	if a < b {
    18  		return a
    19  	}
    20  	return b
    21  }
    22  
    23  func max(a, b int) int {
    24  	if a > b {
    25  		return a
    26  	}
    27  	return b
    28  }
    29  
    30  func abs(a int) int {
    31  	if a < 0 {
    32  		return -a
    33  	}
    34  	return a
    35  }
    36  
    37  const (
    38  	// dlamchE is the machine epsilon. For IEEE this is 2^{-53}.
    39  	dlamchE = 1.1102230246251565e-16
    40  
    41  	// dlamchB is the radix of the machine (the base of the number system).
    42  	dlamchB = 2
    43  
    44  	// dlamchP is base * eps.
    45  	dlamchP = dlamchB * dlamchE
    46  
    47  	// dlamchS is the "safe minimum", that is, the lowest number such that
    48  	// 1/dlamchS does not overflow, or also the smallest normal number.
    49  	// For IEEE this is 2^{-1022}.
    50  	dlamchS = 2.2250738585072014e-308
    51  
    52  	// (rtmin,rtmax) is a range of well-scaled numbers whose square
    53  	// or sum of squares is also safe.
    54  	// drtmin is sqrt(dlamchS/dlamchP)
    55  	drtmin = 1.0010415475915505e-146
    56  	drtmax = 1 / drtmin
    57  )