mirror of
https://github.com/gonum/gonum.git
synced 2025-10-08 16:40:06 +08:00
all: run gofmt and generate all packages
Changes made in dsp/fourier/internal/fftpack break the formatting used there, so these are reverted. There will be complaints in CI. [git-generate] gofmt -w . go generate gonum.org/v1/gonum/blas go generate gonum.org/v1/gonum/blas/gonum go generate gonum.org/v1/gonum/unit go generate gonum.org/v1/gonum/unit/constant go generate gonum.org/v1/gonum/graph/formats/dot go generate gonum.org/v1/gonum/graph/formats/rdf go generate gonum.org/v1/gonum/stat/card git checkout -- dsp/fourier/internal/fftpack
This commit is contained in:
62
unit/doc.go
62
unit/doc.go
@@ -11,7 +11,7 @@
|
||||
// base SI units and common derived units; and a system for dynamically
|
||||
// extensible user-defined units.
|
||||
//
|
||||
// Static SI units
|
||||
// # Static SI units
|
||||
//
|
||||
// This package provides a number of types representing either an SI base
|
||||
// unit or a common combination of base units, named for the physical quantity
|
||||
@@ -19,50 +19,50 @@
|
||||
// float64. The value of the float64 represents the quantity of that unit as
|
||||
// expressed in SI base units (kilogram, metre, Pascal, etc.). For example,
|
||||
//
|
||||
// height := 1.6 * unit.Metre
|
||||
// acc := unit.Acceleration(9.8)
|
||||
// height := 1.6 * unit.Metre
|
||||
// acc := unit.Acceleration(9.8)
|
||||
//
|
||||
// creates a variable named 'height' with a value of 1.6 metres, and
|
||||
// a variable named 'acc' with a value of 9.8 metres per second squared.
|
||||
// These types can be used to add compile-time safety to code. For
|
||||
// example,
|
||||
//
|
||||
// func unitVolume(t unit.Temperature, p unit.Pressure) unit.Volume {
|
||||
// ...
|
||||
// }
|
||||
// func unitVolume(t unit.Temperature, p unit.Pressure) unit.Volume {
|
||||
// ...
|
||||
// }
|
||||
//
|
||||
// func main(){
|
||||
// t := 300 * unit.Kelvin
|
||||
// p := 500 * unit.Kilo * unit.Pascal
|
||||
// v := unitVolume(p, t) // compile-time error
|
||||
// }
|
||||
// func main(){
|
||||
// t := 300 * unit.Kelvin
|
||||
// p := 500 * unit.Kilo * unit.Pascal
|
||||
// v := unitVolume(p, t) // compile-time error
|
||||
// }
|
||||
//
|
||||
// gives a compile-time error (temperature type does not match pressure type)
|
||||
// while the corresponding code using float64 runs without error.
|
||||
//
|
||||
// func float64Volume(temperature, pressure float64) float64 {
|
||||
// ...
|
||||
// }
|
||||
// func float64Volume(temperature, pressure float64) float64 {
|
||||
// ...
|
||||
// }
|
||||
//
|
||||
// func main(){
|
||||
// t := 300.0 // Kelvin
|
||||
// p := 500000.0 // Pascals
|
||||
// v := float64Volume(p, t) // no error
|
||||
// }
|
||||
// func main(){
|
||||
// t := 300.0 // Kelvin
|
||||
// p := 500000.0 // Pascals
|
||||
// v := float64Volume(p, t) // no error
|
||||
// }
|
||||
//
|
||||
// Many types have constants defined representing named SI units (Metre,
|
||||
// Kilogram, etc. ) or SI derived units (Pascal, Hz, etc.). The unit package
|
||||
// additionally provides untyped constants for SI prefixes, so the following
|
||||
// are all equivalent.
|
||||
//
|
||||
// l := 0.001 * unit.Metre
|
||||
// k := 1 * unit.Milli * unit.Metre
|
||||
// j := unit.Length(0.001)
|
||||
// l := 0.001 * unit.Metre
|
||||
// k := 1 * unit.Milli * unit.Metre
|
||||
// j := unit.Length(0.001)
|
||||
//
|
||||
// Additional SI-derived static units can also be defined by adding types that
|
||||
// satisfy the Uniter interface described below.
|
||||
//
|
||||
// Dynamic user-extensible unit system
|
||||
// # Dynamic user-extensible unit system
|
||||
//
|
||||
// The unit package also provides the Unit type, a representation of a general
|
||||
// dimensional value. Unit can be used to help prevent errors of dimensionality
|
||||
@@ -70,19 +70,19 @@
|
||||
// variables of type Unit can be created with the New function and the
|
||||
// Dimensions map. For example, the code
|
||||
//
|
||||
// rate := unit.New(1 * unit.Milli, Dimensions{MoleDim: 1, TimeDim: -1})
|
||||
// rate := unit.New(1 * unit.Milli, Dimensions{MoleDim: 1, TimeDim: -1})
|
||||
//
|
||||
// creates a variable "rate" which has a value of 1e-3 mol/s. Methods of
|
||||
// unit can be used to modify this value, for example:
|
||||
//
|
||||
// rate.Mul(1 * unit.Centi * unit.Metre).Div(1 * unit.Milli * unit.Volt)
|
||||
// rate.Mul(1 * unit.Centi * unit.Metre).Div(1 * unit.Milli * unit.Volt)
|
||||
//
|
||||
// To convert the unit back into a typed float64 value, the From methods
|
||||
// of the dimensional types should be used. From will return an error if the
|
||||
// dimensions do not match.
|
||||
//
|
||||
// var energy unit.Energy
|
||||
// err := energy.From(acc)
|
||||
// var energy unit.Energy
|
||||
// err := energy.From(acc)
|
||||
//
|
||||
// Domain-specific problems may need custom dimensions, and for this purpose
|
||||
// NewDimension should be used to help avoid accidental overlap between
|
||||
@@ -92,13 +92,13 @@
|
||||
// string which will be used for printing that dimension, and will return
|
||||
// a unique dimension number.
|
||||
//
|
||||
// wbc := unit.NewDimension("WhiteBloodCell")
|
||||
// wbc := unit.NewDimension("WhiteBloodCell")
|
||||
//
|
||||
// NewDimension should not be used, however, to create the unit of 'Slide',
|
||||
// because in this case slide is just a measurement of liquid volume. Instead,
|
||||
// a constant could be defined.
|
||||
//
|
||||
// const Slide unit.Volume = 0.1 * unit.Micro * unit.Litre
|
||||
// const Slide unit.Volume = 0.1 * unit.Micro * unit.Litre
|
||||
//
|
||||
// Note that unit cannot catch all errors related to dimensionality.
|
||||
// Different physical ideas are sometimes expressed with the same dimensions
|
||||
@@ -109,9 +109,9 @@
|
||||
// represent units can help to catch errors at compile-time. For example,
|
||||
// using unit.Torque allows you to define a statically typed function like so
|
||||
//
|
||||
// func LeverLength(apply unit.Force, want unit.Torque) unit.Length {
|
||||
// func LeverLength(apply unit.Force, want unit.Torque) unit.Length {
|
||||
// return unit.Length(float64(want)/float64(apply))
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// This will prevent an energy value being provided to LeverLength in place
|
||||
// of a torque value.
|
||||
|
Reference in New Issue
Block a user