mirror of
https://github.com/gonum/gonum.git
synced 2025-10-14 03:13:46 +08:00
all: fix spelling and typos
This commit is contained in:
@@ -15,7 +15,7 @@ import (
|
||||
type Implementation struct{}
|
||||
|
||||
// [SD]gemm behavior constants. These are kept here to keep them out of the
|
||||
// way during single precision code genration.
|
||||
// way during single precision code generation.
|
||||
const (
|
||||
blockSize = 64 // b x b matrix
|
||||
minParBlock = 4 // minimum number of blocks needed to go parallel
|
||||
|
@@ -1556,7 +1556,7 @@ func (Implementation) Ssbmv(ul blas.Uplo, n, k int, alpha float32, a []float32,
|
||||
return
|
||||
}
|
||||
|
||||
// Casses where a has bands below the diagonal.
|
||||
// Cases where a has bands below the diagonal.
|
||||
if incX == 1 {
|
||||
iy := ky
|
||||
for i := 0; i < n; i++ {
|
||||
|
@@ -1534,7 +1534,7 @@ func (Implementation) Dsbmv(ul blas.Uplo, n, k int, alpha float64, a []float64,
|
||||
return
|
||||
}
|
||||
|
||||
// Casses where a has bands below the diagonal.
|
||||
// Cases where a has bands below the diagonal.
|
||||
if incX == 1 {
|
||||
iy := ky
|
||||
for i := 0; i < n; i++ {
|
||||
|
@@ -255,7 +255,7 @@ func EqualFunc(s1, s2 []complex128, f func(complex128, complex128) bool) bool {
|
||||
}
|
||||
|
||||
// EqualLengths returns true when all of the slices have equal length,
|
||||
// and false otherwise. It also eturns true when there are no input slices.
|
||||
// and false otherwise. It also returns true when there are no input slices.
|
||||
func EqualLengths(slices ...[]complex128) bool {
|
||||
// This length check is needed: http://play.golang.org/p/sdty6YiLhM
|
||||
if len(slices) == 0 {
|
||||
|
@@ -87,7 +87,7 @@ var Central = Formula{
|
||||
Step: 6e-6,
|
||||
}
|
||||
|
||||
// Central2nd represents a secord-order accurate centered approximation
|
||||
// Central2nd represents a second-order accurate centered approximation
|
||||
// to the second derivative.
|
||||
var Central2nd = Formula{
|
||||
Stencil: []Point{{Loc: -1, Coeff: 1}, {Loc: 0, Coeff: -2}, {Loc: 1, Coeff: 1}},
|
||||
|
@@ -89,7 +89,7 @@ func DsaturExact(term Terminator, g graph.Undirected) (k int, colors map[int64]i
|
||||
// Brélaz Dsatur coloring, using the result if the recurrence is
|
||||
// cancelled.
|
||||
// We also use the initial maximum clique as a starting point for
|
||||
// the exact search. If there is more than one maxumum clique, we
|
||||
// the exact search. If there is more than one maximum clique, we
|
||||
// need to ensure that we pick the one that will lead us down the
|
||||
// easiest branch of the search tree. This will be the maximum
|
||||
// clique with the lowest degree into the remainder of the graph.
|
||||
@@ -174,7 +174,7 @@ func (c dSaturColoring) uncolor(id int64) {
|
||||
c.uncolored.Add(id)
|
||||
}
|
||||
|
||||
// dSaturExact recursively searches for an exact mimimum vertex coloring of the
|
||||
// dSaturExact recursively searches for an exact minimum vertex coloring of the
|
||||
// full graph in cand. If no chromatic number lower than ub is found, colors is
|
||||
// returned as nil.
|
||||
func dSaturExact(term Terminator, selector *saturationDegree, cand dSaturColoring, k, ub int, best map[int64]int) (newK int, colors map[int64]int, err error) {
|
||||
|
@@ -12,7 +12,7 @@ import (
|
||||
"gonum.org/v1/gonum/graph/traverse"
|
||||
)
|
||||
|
||||
// KCliqueCommunities returns the k-clique communties of the undirected graph g for
|
||||
// KCliqueCommunities returns the k-clique communities of the undirected graph g for
|
||||
// k greater than zero. The returned communities are identified by linkage via k-clique
|
||||
// adjacency, where adjacency is defined as having k-1 common nodes. KCliqueCommunities
|
||||
// returns a single component including the full set of nodes of g when k is 1,
|
||||
|
@@ -44,7 +44,7 @@ const (
|
||||
)
|
||||
|
||||
// Type returns the element type of the receiver. It returns an error if the Element Group
|
||||
// is invalid or does not match the Element Data, or if the Elelement Data is an incomplete
|
||||
// is invalid or does not match the Element Data, or if the Element Data is an incomplete
|
||||
// edge.
|
||||
func (e Element) Type() (ElemType, error) {
|
||||
et := InvalidElement
|
||||
|
@@ -30,7 +30,7 @@ var (
|
||||
|
||||
// WeightedUndirectedGraph implements a generalized undirected graph.
|
||||
type WeightedUndirectedGraph struct {
|
||||
// EdgeWEightFunc is used to provide
|
||||
// EdgeWeightFunc is used to provide
|
||||
// the WeightFunc function for WeightedEdge
|
||||
// values returned by the graph.
|
||||
// WeightFunc must accept a nil input.
|
||||
|
@@ -177,7 +177,7 @@ type WeightedMultigraphBuilder interface {
|
||||
WeightedLineAdder
|
||||
}
|
||||
|
||||
// UndirectedMultgraphBuilder is an undirected multigraph builder.
|
||||
// UndirectedMultigraphBuilder is an undirected multigraph builder.
|
||||
type UndirectedMultigraphBuilder interface {
|
||||
UndirectedMultigraph
|
||||
MultigraphBuilder
|
||||
|
@@ -18,7 +18,7 @@ import (
|
||||
// If g is a graph.Graph, all nodes of the graph will be stored in the shortest-path
|
||||
// tree, otherwise only nodes reachable from u will be stored.
|
||||
//
|
||||
// The time complexity of DijkstrFrom is O(|E|.log|V|).
|
||||
// The time complexity of DijkstraFrom is O(|E|.log|V|).
|
||||
func DijkstraFrom(u graph.Node, g traverse.Graph) Shortest {
|
||||
var path Shortest
|
||||
if h, ok := g.(graph.Graph); ok {
|
||||
@@ -91,7 +91,7 @@ func DijkstraFrom(u graph.Node, g traverse.Graph) Shortest {
|
||||
// If g is a graph.Graph, all nodes of the graph will be stored in the shortest-path
|
||||
// tree, otherwise only nodes reachable from u will be stored.
|
||||
//
|
||||
// The time complexity of DijkstrAllFrom is O(|E|.log|V|).
|
||||
// The time complexity of DijkstraAllFrom is O(|E|.log|V|).
|
||||
func DijkstraAllFrom(u graph.Node, g traverse.Graph) ShortestAlts {
|
||||
var path ShortestAlts
|
||||
if h, ok := g.(graph.Graph); ok {
|
||||
@@ -161,7 +161,7 @@ func DijkstraAllFrom(u graph.Node, g traverse.Graph) ShortestAlts {
|
||||
// If the graph does not implement graph.Weighter, UniformCost is used.
|
||||
// DijkstraAllPaths will panic if g has a negative edge weight.
|
||||
//
|
||||
// The time complexity of DijkstrAllPaths is O(|V|.|E|+|V|^2.log|V|).
|
||||
// The time complexity of DijkstraAllPaths is O(|V|.|E|+|V|^2.log|V|).
|
||||
func DijkstraAllPaths(g graph.Graph) (paths AllShortest) {
|
||||
paths = newAllShortest(graph.NodesOf(g.Nodes()), false)
|
||||
dijkstraAllPaths(g, paths)
|
||||
|
@@ -16,8 +16,8 @@ import (
|
||||
|
||||
const (
|
||||
Closed = '*' // Closed is the closed grid node representation.
|
||||
Open = '.' // Open is the open grid node repesentation.
|
||||
Unknown = '?' // Unknown is the unknown grid node repesentation.
|
||||
Open = '.' // Open is the open grid node representation.
|
||||
Unknown = '?' // Unknown is the unknown grid node representation.
|
||||
)
|
||||
|
||||
// Grid is a 2D grid planar undirected graph.
|
||||
|
@@ -742,7 +742,7 @@ func EdgeExistence(t *testing.T, b Builder, reversedEdge bool) {
|
||||
|
||||
// LineExistence tests the constructed graph for the ability to correctly
|
||||
// return the existence of lines within the graph. This is a check of the
|
||||
// Line methods of graph.MultiGraph, the EdgeBetween method of graph.Undirected
|
||||
// Line methods of graph.Multigraph, the EdgeBetween method of graph.Undirected
|
||||
// and the EdgeFromTo method of graph.Directed. LineExistence also checks
|
||||
// that the nodes and traversed edges exist within the graph, checking the
|
||||
// Node, Edge, EdgeBetween and HasEdgeBetween methods of graph.Graph, the
|
||||
|
@@ -106,7 +106,7 @@ func (pl PiecewiseLinear) Predict(x float64) float64 {
|
||||
return pl.ys[i] + pl.slopes[i]*(x-xI)
|
||||
}
|
||||
|
||||
// PiecewiseConstant is a left-continous, piecewise constant
|
||||
// PiecewiseConstant is a left-continuous, piecewise constant
|
||||
// 1-dimensional interpolator.
|
||||
type PiecewiseConstant struct {
|
||||
// Interpolated X values.
|
||||
|
@@ -473,7 +473,7 @@ func (impl Implementation) Dgesvd(jobU, jobVT lapack.SVDJob, m, n int, a []float
|
||||
work[itauq:], work[iwork:], lwork-iwork)
|
||||
iwork = ie + n
|
||||
|
||||
// Perform bidiagonal QR iteration, compuing left singular
|
||||
// Perform bidiagonal QR iteration, computing left singular
|
||||
// vectors of R in work[ir:].
|
||||
ok = impl.Dbdsqr(blas.Upper, n, 0, n, 0, s, work[ie:], work, 1,
|
||||
work[ir:], ldworkr, work, 1, work[iwork:])
|
||||
|
@@ -20,7 +20,7 @@ import "math"
|
||||
// On entry, b contains the n×nrhs right-hand side matrix B. On return, b will
|
||||
// be overwritten. If ok is true, it will be overwritten by the solution matrix X.
|
||||
//
|
||||
// Dgtsv returns whether the solution X has been successfuly computed.
|
||||
// Dgtsv returns whether the solution X has been successfully computed.
|
||||
func (impl Implementation) Dgtsv(n, nrhs int, dl, d, du []float64, b []float64, ldb int) (ok bool) {
|
||||
switch {
|
||||
case n < 0:
|
||||
|
@@ -62,7 +62,7 @@ func (impl Implementation) Dorglq(m, n, k int, a []float64, lda int, tau, work [
|
||||
}
|
||||
|
||||
nbmin := 2 // Minimum block size
|
||||
var nx int // Crossover size from blocked to unbloked code
|
||||
var nx int // Crossover size from blocked to unblocked code
|
||||
iws := m // Length of work needed
|
||||
var ldwork int
|
||||
if 1 < nb && nb < k {
|
||||
@@ -90,7 +90,7 @@ func (impl Implementation) Dorglq(m, n, k int, a []float64, lda int, tau, work [
|
||||
}
|
||||
}
|
||||
if kk < m {
|
||||
// Perform the operation on colums kk to the end.
|
||||
// Perform the operation on columns kk to the end.
|
||||
impl.Dorgl2(m-kk, n-kk, k-kk, a[kk*lda+kk:], lda, tau[kk:], work)
|
||||
}
|
||||
if kk > 0 {
|
||||
|
@@ -73,7 +73,7 @@ func (impl Implementation) Dorgqr(m, n, k int, a []float64, lda int, tau, work [
|
||||
}
|
||||
|
||||
nbmin := 2 // Minimum block size
|
||||
var nx int // Crossover size from blocked to unbloked code
|
||||
var nx int // Crossover size from blocked to unblocked code
|
||||
iws := n // Length of work needed
|
||||
var ldwork int
|
||||
if 1 < nb && nb < k {
|
||||
@@ -100,7 +100,7 @@ func (impl Implementation) Dorgqr(m, n, k int, a []float64, lda int, tau, work [
|
||||
}
|
||||
}
|
||||
if kk < n {
|
||||
// Perform the operation on colums kk to the end.
|
||||
// Perform the operation on columns kk to the end.
|
||||
impl.Dorg2r(m-kk, n-kk, k-kk, a[kk*lda+kk:], lda, tau[kk:], work)
|
||||
}
|
||||
if kk > 0 {
|
||||
|
@@ -465,7 +465,7 @@ func Ggsvd3(jobU, jobV, jobQ lapack.GSVDJob, a, b blas64.General, alpha, beta []
|
||||
// On entry, b contains the n×nrhs right-hand side matrix B. On return, it will
|
||||
// be overwritten. If ok is true, it will be overwritten by the solution matrix X.
|
||||
//
|
||||
// Gtsv returns whether the solution X has been successfuly computed.
|
||||
// Gtsv returns whether the solution X has been successfully computed.
|
||||
//
|
||||
// Dgtsv is not part of the lapack.Float64 interface and so calls to Gtsv are
|
||||
// always executed by the Gonum implementation.
|
||||
@@ -621,7 +621,7 @@ func Ormqr(side blas.Side, trans blas.Transpose, a blas64.General, tau []float64
|
||||
}
|
||||
|
||||
// Pocon estimates the reciprocal of the condition number of a positive-definite
|
||||
// matrix A given the Cholesky decmposition of A. The condition number computed
|
||||
// matrix A given the Cholesky decomposition of A. The condition number computed
|
||||
// is based on the 1-norm and the ∞-norm.
|
||||
//
|
||||
// anorm is the 1-norm and the ∞-norm of the original matrix A.
|
||||
|
@@ -36,7 +36,7 @@ func Dlags2Test(t *testing.T, impl Dlags2er) {
|
||||
b2 := rnd.Float64()
|
||||
b3 := rnd.Float64()
|
||||
|
||||
// Compute orthogal matrices U, V, Q
|
||||
// Compute orthogonal matrices U, V, Q
|
||||
// U = [ csu snu ], V = [ csv snv ], Q = [ csq snq ]
|
||||
// [ -snu csu ] [ -snv csv ] [ -snq csq ]
|
||||
// that transform A and B.
|
||||
|
@@ -80,14 +80,14 @@ func DlarftTest(t *testing.T, impl Dlarfter) {
|
||||
tData := make([]float64, len(tm))
|
||||
copy(tData, tm)
|
||||
if direct == lapack.Forward {
|
||||
// Zero out the lower traingular portion.
|
||||
// Zero out the lower triangular portion.
|
||||
for i := 0; i < k; i++ {
|
||||
for j := 0; j < i; j++ {
|
||||
tData[i*ldt+j] = 0
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Zero out the upper traingular portion.
|
||||
// Zero out the upper triangular portion.
|
||||
for i := 0; i < k; i++ {
|
||||
for j := i + 1; j < k; j++ {
|
||||
tData[i*ldt+j] = 0
|
||||
|
@@ -287,7 +287,7 @@ func (v VecDense) MarshalBinary() ([]byte, error) {
|
||||
// MarshalBinaryTo encodes the receiver into a binary form, writes it to w and
|
||||
// returns the number of bytes written and an error if any.
|
||||
//
|
||||
// See MarshalBainry for the on-disk format.
|
||||
// See MarshalBinary for the on-disk format.
|
||||
func (v VecDense) MarshalBinaryTo(w io.Writer) (int, error) {
|
||||
header := storage{
|
||||
Form: 'G', Packing: 'F', Uplo: 'A',
|
||||
|
@@ -413,7 +413,7 @@ func Cond(a Matrix, norm float64) float64 {
|
||||
return lq.Cond()
|
||||
}
|
||||
|
||||
// Det returns the determinant of the quare matrix a. In many expressions using
|
||||
// Det returns the determinant of the square matrix a. In many expressions using
|
||||
// LogDet will be more numerically stable.
|
||||
//
|
||||
// Det panics with ErrSquare if a is not square and with ErrZeroLength if a has
|
||||
|
@@ -400,7 +400,7 @@ func verifyInputs(initialBasic []int, c []float64, A mat.Matrix, b []float64) er
|
||||
|
||||
// Do some sanity checks so that ab does not become singular during the
|
||||
// simplex solution. If the ZeroRow checks are removed then the code for
|
||||
// finding a set of linearly indepent columns must be improved.
|
||||
// finding a set of linearly independent columns must be improved.
|
||||
|
||||
// Check that if a row of A only has zero elements that corresponding
|
||||
// element in b is zero, otherwise the problem is infeasible.
|
||||
|
@@ -97,7 +97,7 @@ func NewNormalPrecision(mu []float64, prec *mat.SymDense, src rand.Source) (norm
|
||||
if dim != len(mu) {
|
||||
panic(badSizeMismatch)
|
||||
}
|
||||
// TODO(btracey): Computing a matrix inverse is generally numerically instable.
|
||||
// TODO(btracey): Computing a matrix inverse is generally numerically unstable.
|
||||
// This only has to compute the inverse of a positive definite matrix, which
|
||||
// is much better, but this still loses precision. It is worth considering if
|
||||
// instead the precision matrix should be stored explicitly and used instead
|
||||
|
@@ -89,7 +89,7 @@ func (b Beta) Mean() float64 {
|
||||
|
||||
// Mode returns the mode of the distribution.
|
||||
//
|
||||
// Mode returns NaN if both parametera are less than or equal to 1 as a special case,
|
||||
// Mode returns NaN if both parameters are less than or equal to 1 as a special case,
|
||||
// 0 if only Alpha <= 1 and 1 if only Beta <= 1.
|
||||
func (b Beta) Mode() float64 {
|
||||
if b.Alpha <= 1 {
|
||||
|
@@ -11,7 +11,7 @@ import (
|
||||
// Logistic implements the Logistic distribution, a two-parameter distribution with support on the real axis.
|
||||
// Its cumulative distribution function is the logistic function.
|
||||
//
|
||||
// General form of probability density fuction for Logistic distribution is
|
||||
// General form of probability density function for Logistic distribution is
|
||||
// E(x) / (s * (1 + E(x))^2)
|
||||
// where E(x) = exp(-(x-μ)/s)
|
||||
//
|
||||
|
@@ -35,7 +35,7 @@ type StudentsT struct {
|
||||
// standard deviation by std = Sigma * sqrt(Nu/(Nu-2))
|
||||
Sigma float64
|
||||
|
||||
// Nu is the shape prameter of the distribution, representing the number of
|
||||
// Nu is the shape parameter of the distribution, representing the number of
|
||||
// degrees of the distribution, and one less than the number of observations
|
||||
// from a Normal distribution.
|
||||
Nu float64
|
||||
|
@@ -190,7 +190,7 @@ func NewProposalNormal(sigma *mat.SymDense, src rand.Source) (*ProposalNormal, b
|
||||
// ConditionalLogProb panics if the input slices are not the same length or
|
||||
// are not equal to the dimension of the covariance matrix.
|
||||
func (p *ProposalNormal) ConditionalLogProb(x, y []float64) (prob float64) {
|
||||
// Either SetMean or LogProb will panic if the slice lengths are innaccurate.
|
||||
// Either SetMean or LogProb will panic if the slice lengths are inaccurate.
|
||||
p.normal.SetMean(y)
|
||||
return p.normal.LogProb(x)
|
||||
}
|
||||
|
@@ -166,10 +166,10 @@ var ErrRejection = errors.New("rejection: acceptance ratio above 1")
|
||||
//
|
||||
// The number of proposed locations during sampling can be found with a call to
|
||||
// Proposed. If there was an error during sampling, all elements of samples are
|
||||
// set to NaN and the error can be accesssed with the Err method. If src != nil,
|
||||
// set to NaN and the error can be accessed with the Err method. If src != nil,
|
||||
// it will be used to generate random numbers, otherwise rand.Float64 will be used.
|
||||
//
|
||||
// Target may return the true (log of) the probablity of the location, or it may return
|
||||
// Target may return the true (log of) the probability of the location, or it may return
|
||||
// a value that is proportional to the probability (logprob + constant). This is
|
||||
// useful for cases where the probability distribution is only known up to a normalization
|
||||
// constant.
|
||||
|
@@ -155,10 +155,10 @@ var ErrRejection = errors.New("rejection: acceptance ratio above 1")
|
||||
//
|
||||
// The number of proposed locations during sampling can be found with a call to
|
||||
// Proposed. If there was an error during sampling, all elements of samples are
|
||||
// set to NaN and the error can be accesssed with the Err method. If src != nil,
|
||||
// set to NaN and the error can be accessed with the Err method. If src != nil,
|
||||
// it will be used to generate random numbers, otherwise rand.Float64 will be used.
|
||||
//
|
||||
// Target may return the true (log of) the probablity of the location, or it may return
|
||||
// Target may return the true (log of) the probability of the location, or it may return
|
||||
// a value that is proportional to the probability (logprob + constant). This is
|
||||
// useful for cases where the probability distribution is only known up to a normalization
|
||||
// constant.
|
||||
|
@@ -562,7 +562,7 @@ func Histogram(count, dividers, x, weights []float64) []float64 {
|
||||
// p and q. The Jensen-Shannon divergence is defined as
|
||||
// m = 0.5 * (p + q)
|
||||
// JS(p, q) = 0.5 ( KL(p, m) + KL(q, m) )
|
||||
// Unlike Kullback-Liebler, the Jensen-Shannon distance is symmetric. The value
|
||||
// Unlike Kullback-Leibler, the Jensen-Shannon distance is symmetric. The value
|
||||
// is between 0 and ln(2).
|
||||
func JensenShannon(p, q []float64) float64 {
|
||||
if len(p) != len(q) {
|
||||
|
Reference in New Issue
Block a user