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:
Dan Kortschak
2022-08-05 20:57:59 +09:30
parent fee5019b48
commit 5f0141ca4c
308 changed files with 5004 additions and 3064 deletions

View File

@@ -5,39 +5,48 @@
// Package mat provides implementations of float64 and complex128 matrix
// structures and linear algebra operations on them.
//
// Overview
// # Overview
//
// This section provides a quick overview of the mat package. The following
// sections provide more in depth commentary.
//
// mat provides:
// - Interfaces for Matrix classes (Matrix, Symmetric, Triangular)
// - Concrete implementations (Dense, SymDense, TriDense, VecDense)
// - Methods and functions for using matrix data (Add, Trace, SymRankOne)
// - Types for constructing and using matrix factorizations (QR, LU, etc.)
// - The complementary types for complex matrices, CMatrix, CSymDense, etc.
// - Interfaces for Matrix classes (Matrix, Symmetric, Triangular)
// - Concrete implementations (Dense, SymDense, TriDense, VecDense)
// - Methods and functions for using matrix data (Add, Trace, SymRankOne)
// - Types for constructing and using matrix factorizations (QR, LU, etc.)
// - The complementary types for complex matrices, CMatrix, CSymDense, etc.
//
// In the documentation below, we use "matrix" as a short-hand for all of
// the FooDense types implemented in this package. We use "Matrix" to
// refer to the Matrix interface.
//
// A matrix may be constructed through the corresponding New function. If no
// backing array is provided the matrix will be initialized to all zeros.
// // Allocate a zeroed real matrix of size 3×5
// zero := mat.NewDense(3, 5, nil)
//
// // Allocate a zeroed real matrix of size 3×5
// zero := mat.NewDense(3, 5, nil)
//
// If a backing data slice is provided, the matrix will have those elements.
// All matrices are stored in row-major format and users should consider
// this when expressing matrix arithmetic to ensure optimal performance.
// // Generate a 6×6 matrix of random values.
// data := make([]float64, 36)
// for i := range data {
// data[i] = rand.NormFloat64()
// }
// a := mat.NewDense(6, 6, data)
//
// // Generate a 6×6 matrix of random values.
// data := make([]float64, 36)
// for i := range data {
// data[i] = rand.NormFloat64()
// }
// a := mat.NewDense(6, 6, data)
//
// Operations involving matrix data are implemented as functions when the values
// of the matrix remain unchanged
// tr := mat.Trace(a)
//
// tr := mat.Trace(a)
//
// and are implemented as methods when the operation modifies the receiver.
// zero.Copy(a)
//
// zero.Copy(a)
//
// Note that the input arguments to most functions and methods are interfaces
// rather than concrete types `func Trace(Matrix)` rather than
// `func Trace(*Dense)` allowing flexible use of internal and external
@@ -47,7 +56,7 @@
// the operation will panic if the matrix is not the correct size.
// An exception to this is when the destination is empty (see below).
//
// Empty matrix
// # Empty matrix
//
// An empty matrix is one that has zero size. Empty matrices are used to allow
// the destination of a matrix operation to assume the correct size automatically.
@@ -55,15 +64,17 @@
// new data if necessary. The IsEmpty method returns whether the given matrix
// is empty. The zero-value of a matrix is empty, and is useful for easily
// getting the result of matrix operations.
// var c mat.Dense // construct a new zero-value matrix
// c.Mul(a, a) // c is automatically adjusted to be the right size
//
// var c mat.Dense // construct a new zero-value matrix
// c.Mul(a, a) // c is automatically adjusted to be the right size
//
// The Reset method can be used to revert a matrix to an empty matrix.
// Reset should not be used when multiple different matrices share the same backing
// data slice. This can cause unexpected data modifications after being resized.
// An empty matrix can not be sliced even if it does have an adequately sized
// backing data slice, but can be expanded using its Grow method if it exists.
//
// The Matrix Interfaces
// # The Matrix Interfaces
//
// The Matrix interface is the common link between the concrete types of real
// matrices. The Matrix interface is defined by three functions: Dims, which
@@ -71,11 +82,15 @@
// specified location, and T for returning a Transpose (discussed later). All of
// the matrix types can perform these behaviors and so implement the interface.
// Methods and functions are designed to use this interface, so in particular the method
// func (m *Dense) Mul(a, b Matrix)
//
// func (m *Dense) Mul(a, b Matrix)
//
// constructs a *Dense from the result of a multiplication with any Matrix types,
// not just *Dense. Where more restrictive requirements must be met, there are also
// additional interfaces like Symmetric and Triangular. For example, in
// func (s *SymDense) AddSym(a, b Symmetric)
//
// func (s *SymDense) AddSym(a, b Symmetric)
//
// the Symmetric interface guarantees a symmetric result.
//
// The CMatrix interface plays the same role for complex matrices. The difference
@@ -90,20 +105,22 @@
// see the Transpose and Conjugate types for more details. Note that some
// operations have a transpose as part of their definition, as in *SymDense.SymOuterK.
//
// Matrix Factorization
// # Matrix Factorization
//
// Matrix factorizations, such as the LU decomposition, typically have their own
// specific data storage, and so are each implemented as a specific type. The
// factorization can be computed through a call to Factorize
// var lu mat.LU
// lu.Factorize(a)
//
// var lu mat.LU
// lu.Factorize(a)
//
// The elements of the factorization can be extracted through methods on the
// factorized type, for example *LU.UTo. The factorization types can also be used
// directly, as in *Cholesky.SolveTo. Some factorizations can be updated directly,
// without needing to update the original matrix and refactorize, for example with
// *LU.RankOne.
//
// BLAS and LAPACK
// # BLAS and LAPACK
//
// BLAS and LAPACK are the standard APIs for linear algebra routines. Many
// operations in mat are implemented using calls to the wrapper functions
@@ -115,12 +132,14 @@
// a cgo BLAS implementation is registered, the lapack64 calls will be partially
// executed in Go and partially executed in C.
//
// Type Switching
// # Type Switching
//
// The Matrix abstraction enables efficiency as well as interoperability. Go's
// type reflection capabilities are used to choose the most efficient routine
// given the specific concrete types. For example, in
// c.Mul(a, b)
//
// c.Mul(a, b)
//
// if a and b both implement RawMatrixer, that is, they can be represented as a
// blas64.General, blas64.Gemm (general matrix multiplication) is called, while
// instead if b is a RawSymmetricer blas64.Symm is used (general-symmetric
@@ -132,19 +151,21 @@
// value. If there are specific special cases that are needed, please submit a
// pull-request or file an issue.
//
// Invariants
// # Invariants
//
// Matrix input arguments to package functions are never directly modified. If an
// operation changes Matrix data, the mutated matrix will be the receiver of a
// method, or will be the first, dst, argument to a method named with a To suffix.
//
// For convenience, a matrix may be used as both a receiver and as an input, e.g.
// a.Pow(a, 6)
// v.SolveVec(a.T(), v)
//
// a.Pow(a, 6)
// v.SolveVec(a.T(), v)
//
// though in many cases this will cause an allocation (see Element Aliasing).
// An exception to this rule is Copy, which does not allow a.Copy(a.T()).
//
// Element Aliasing
// # Element Aliasing
//
// Most methods in mat modify receiver data. It is forbidden for the modified
// data region of the receiver to overlap the used data area of the input
@@ -163,17 +184,17 @@
//
// mat will use the following rules to detect overlap between the receiver and one
// of the inputs:
// - the input implements one of the Raw methods, and
// - the address ranges of the backing data slices overlap, and
// - the strides differ or there is an overlap in the used data elements.
// - the input implements one of the Raw methods, and
// - the address ranges of the backing data slices overlap, and
// - the strides differ or there is an overlap in the used data elements.
//
// If such an overlap is detected, the method will panic.
//
// The following cases will not panic:
// - the data slices do not overlap,
// - there is pointer identity between the receiver and input values after
// the value has been untransposed if necessary.
// - the data slices do not overlap,
// - there is pointer identity between the receiver and input values after
// the value has been untransposed if necessary.
//
// mat will not attempt to detect element overlap if the input does not implement a
// Raw method. Method behavior is undefined if there is undetected overlap.
//
package mat // import "gonum.org/v1/gonum/mat"