github.com/jingcheng-WU/gonum@v0.9.1-0.20210323123734-f1a2a11a8f7b/unit/constant/magneticconstant.go (about) 1 // Code generated by "go generate github.com/jingcheng-WU/gonum/unit/constant”; DO NOT EDIT. 2 3 // Copyright ©2019 The Gonum Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file. 6 7 package constant 8 9 import ( 10 "fmt" 11 12 "github.com/jingcheng-WU/gonum/unit" 13 ) 14 15 // MagneticConstant is the magnetic constant (μ₀), the magnetic permeability in a classical vacuum. 16 // The dimensions of MagneticConstant are A^2 s^4 kg^-1 m^-3. The standard uncertainty of the constant is 1.9e-16 A^2 s^4 kg^-1 m^-3. 17 const MagneticConstant = magneticConstantUnits(1.2566370621238374e-06) 18 19 type magneticConstantUnits float64 20 21 // Unit converts the magneticConstantUnits to a *unit.Unit 22 func (cnst magneticConstantUnits) Unit() *unit.Unit { 23 return unit.New(float64(cnst), unit.Dimensions{ 24 unit.CurrentDim: 2, 25 unit.TimeDim: 4, 26 unit.MassDim: -1, 27 unit.LengthDim: -3, 28 }) 29 } 30 31 func (cnst magneticConstantUnits) Format(fs fmt.State, c rune) { 32 switch c { 33 case 'v': 34 if fs.Flag('#') { 35 fmt.Fprintf(fs, "%T(%v)", cnst, float64(cnst)) 36 return 37 } 38 fallthrough 39 case 'e', 'E', 'f', 'F', 'g', 'G': 40 p, pOk := fs.Precision() 41 w, wOk := fs.Width() 42 switch { 43 case pOk && wOk: 44 fmt.Fprintf(fs, "%*.*"+string(c), w, p, cnst.Unit()) 45 case pOk: 46 fmt.Fprintf(fs, "%.*"+string(c), p, cnst.Unit()) 47 case wOk: 48 fmt.Fprintf(fs, "%*"+string(c), w, cnst.Unit()) 49 default: 50 fmt.Fprintf(fs, "%"+string(c), cnst.Unit()) 51 } 52 default: 53 fmt.Fprintf(fs, "%%!"+string(c)+"(constant.magneticConstantUnits=%v A^2 s^4 kg^-1 m^-3)", float64(cnst)) 54 } 55 }