本文整理汇总了Golang中github.com/hrautila/matrix.EqualTypes函数的典型用法代码示例。如果您正苦于以下问题:Golang EqualTypes函数的具体用法?Golang EqualTypes怎么用?Golang EqualTypes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了EqualTypes函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Copy
// Copies a vector X to a vector Y (Y := X).
//
// ARGUMENTS
// X float or complex matrix
// Y float or complex matrix. Must have the same type as X.
//
// OPTIONS
// n integer. If n<0, the default value of n is used.
// The default value is given by 1+(len(x)-offsetx-1)/incx or 0
// if len(x) > offsetx+1
// incx nonzero integer
// incy nonzero integer
// offsetx nonnegative integer
// offsety nonnegative integer;
//
func Copy(X, Y matrix.Matrix, opts ...linalg.Option) (err error) {
ind := linalg.GetIndexOpts(opts...)
err = check_level1_func(ind, fcopy, X, Y)
if err != nil {
return
}
if ind.Nx == 0 {
return
}
sameType := matrix.EqualTypes(X, Y)
if !sameType {
err = onError("arrays not same type")
return
}
switch X.(type) {
case *matrix.ComplexMatrix:
Xa := X.(*matrix.ComplexMatrix).ComplexArray()
Ya := Y.(*matrix.ComplexMatrix).ComplexArray()
zcopy(ind.Nx, Xa[ind.OffsetX:], ind.IncX, Ya[ind.OffsetY:], ind.IncY)
case *matrix.FloatMatrix:
Xa := X.(*matrix.FloatMatrix).FloatArray()
Ya := Y.(*matrix.FloatMatrix).FloatArray()
dcopy(ind.Nx, Xa[ind.OffsetX:], ind.IncX, Ya[ind.OffsetY:], ind.IncY)
default:
err = onError("not implemented for parameter types")
}
return
}
开发者ID:hrautila,项目名称:linalg,代码行数:43,代码来源:level1.go
示例2: Dot
// Returns Y = X^H*Y for real or complex X, Y.
//
// ARGUMENTS
// X float or complex matrix
// Y float or complex matrix. Must have the same type as X.
//
// OPTIONS
// n integer. If n<0, the default value of n is used.
// The default value is equal to nx = 1+(len(x)-offsetx-1)/incx or 0 if
// len(x) > offsetx+1. If the default value is used, it must be equal to
// ny = 1+(len(y)-offsetx-1)/|incy| or 0 if len(y) > offsety+1
// incx nonzero integer [default=1]
// incy nonzero integer [default=1]
// offsetx nonnegative integer [default=0]
// offsety nonnegative integer [default=0]
//
func Dot(X, Y matrix.Matrix, opts ...linalg.Option) (v matrix.Scalar) {
v = matrix.FScalar(math.NaN())
//cv = cmplx.NaN()
ind := linalg.GetIndexOpts(opts...)
err := check_level1_func(ind, fdot, X, Y)
if err != nil {
return
}
if ind.Nx == 0 {
return matrix.FScalar(0.0)
}
sameType := matrix.EqualTypes(X, Y)
if !sameType {
err = onError("arrays not of same type")
return
}
switch X.(type) {
case *matrix.ComplexMatrix:
Xa := X.(*matrix.ComplexMatrix).ComplexArray()
Ya := Y.(*matrix.ComplexMatrix).ComplexArray()
v = matrix.CScalar(zdotc(ind.Nx, Xa[ind.OffsetX:], ind.IncX, Ya[ind.OffsetY:], ind.IncY))
case *matrix.FloatMatrix:
Xa := X.(*matrix.FloatMatrix).FloatArray()
Ya := Y.(*matrix.FloatMatrix).FloatArray()
v = matrix.FScalar(ddot(ind.Nx, Xa[ind.OffsetX:], ind.IncX, Ya[ind.OffsetY:], ind.IncY))
//default:
// err = onError("not implemented for parameter types", )
}
return
}
开发者ID:hrautila,项目名称:linalg,代码行数:46,代码来源:level1.go
示例3: Gemm
/*
General matrix-matrix product. (L3)
PURPOSE
Computes
C := alpha*A*B + beta*C if transA = PNoTrans and transB = PNoTrans.
C := alpha*A^T*B + beta*C if transA = PTrans and transB = PNoTrans.
C := alpha*A^H*B + beta*C if transA = PConjTrans and transB = PNoTrans.
C := alpha*A*B^T + beta*C if transA = PNoTrans and transB = PTrans.
C := alpha*A^T*B^T + beta*C if transA = PTrans and transB = PTrans.
C := alpha*A^H*B^T + beta*C if transA = PConjTrans and transB = PTrans.
C := alpha*A*B^H + beta*C if transA = PNoTrans and transB = PConjTrans.
C := alpha*A^T*B^H + beta*C if transA = PTrans and transB = PConjTrans.
C := alpha*A^H*B^H + beta*C if transA = PConjTrans and transB = PConjTrans.
The number of rows of the matrix product is m. The number of columns is n.
The inner dimension is k. If k=0, this reduces to C := beta*C.
ARGUMENTS
A float or complex matrix, m*k
B float or complex matrix, k*n
C float or complex matrix, m*n
alpha number (float or complex singleton matrix)
beta number (float or complex singleton matrix)
OPTIONS
transA PNoTrans, PTrans or PConjTrans
transB PNoTrans, PTrans or PConjTrans
m integer. If negative, the default value is used. The default value is
m = A.Rows of if transA != PNoTrans m = A.Cols.
n integer. If negative, the default value is used. The default value is
n = (transB == PNoTrans) ? B.Cols : B.Rows.
k integer. If negative, the default value is used. The default value is
k=A.Cols or if transA != PNoTrans) k = A.Rows, transA=PNoTrans.
If the default value is used it should also be equal to
(transB == PNoTrans) ? B.Rows : B.Cols.
ldA nonnegative integer. ldA >= max(1,m) of if transA != NoTrans max(1,k).
If zero, the default value is used.
ldB nonnegative integer. ldB >= max(1,k) or if transB != NoTrans max(1,n).
If zero, the default value is used.
ldC nonnegative integer. ldC >= max(1,m).
If zero, the default value is used.
offsetA nonnegative integer
offsetB nonnegative integer
offsetC nonnegative integer;
*/
func Gemm(A, B, C matrix.Matrix, alpha, beta matrix.Scalar, opts ...linalg.Option) (err error) {
params, e := linalg.GetParameters(opts...)
if e != nil {
err = e
return
}
ind := linalg.GetIndexOpts(opts...)
err = check_level3_func(ind, fgemm, A, B, C, params)
if err != nil {
return
}
if ind.M == 0 || ind.N == 0 {
return
}
if !matrix.EqualTypes(A, B, C) {
return onError("Parameters not of same type")
}
switch A.(type) {
case *matrix.FloatMatrix:
Aa := A.(*matrix.FloatMatrix).FloatArray()
Ba := B.(*matrix.FloatMatrix).FloatArray()
Ca := C.(*matrix.FloatMatrix).FloatArray()
aval := alpha.Float()
bval := beta.Float()
if math.IsNaN(aval) || math.IsNaN(bval) {
return onError("alpha or beta not a number")
}
transB := linalg.ParamString(params.TransB)
transA := linalg.ParamString(params.TransA)
dgemm(transA, transB, ind.M, ind.N, ind.K, aval,
Aa[ind.OffsetA:], ind.LDa, Ba[ind.OffsetB:], ind.LDb, bval,
Ca[ind.OffsetC:], ind.LDc)
case *matrix.ComplexMatrix:
Aa := A.(*matrix.ComplexMatrix).ComplexArray()
Ba := B.(*matrix.ComplexMatrix).ComplexArray()
Ca := C.(*matrix.ComplexMatrix).ComplexArray()
aval := alpha.Complex()
if cmplx.IsNaN(aval) {
return onError("alpha not a number")
}
bval := beta.Complex()
if cmplx.IsNaN(bval) {
return onError("beta not a number")
}
transB := linalg.ParamString(params.TransB)
transA := linalg.ParamString(params.TransA)
zgemm(transA, transB, ind.M, ind.N, ind.K, aval,
Aa[ind.OffsetA:], ind.LDa, Ba[ind.OffsetB:], ind.LDb, bval,
Ca[ind.OffsetC:], ind.LDc)
default:
return onError("Unknown type, not implemented")
}
//.........这里部分代码省略.........
开发者ID:jvlmdr,项目名称:linalg,代码行数:101,代码来源:level3.go
示例4: Gtrrf
/*
LU factorization of a real or complex tridiagonal matrix.
PURPOSE
Factors an n by n real or complex tridiagonal matrix A as A = P*L*U.
A is specified by its lower diagonal dl, diagonal d, and upper
diagonal du. On exit dl, d, du, du2 and ipiv contain the details
of the factorization.
ARGUMENTS.
DL float or complex matrix
D float or complex matrix. Must have the same type as DL.
DU float or complex matrix. Must have the same type as DL.
DU2 float or complex matrix of length at least n-2. Must have the
same type as DL.
ipiv int vector of length at least n
OPTIONS
n nonnegative integer. If negative, the default value is used.
offsetdl nonnegative integer
offsetd nonnegative integer
offsetdu nonnegative integer
*/
func Gtrrf(DL, D, DU, DU2 matrix.Matrix, ipiv []int32, opts ...linalg.Option) error {
ind := linalg.GetIndexOpts(opts...)
if ind.OffsetD < 0 {
return onError("Gttrf: offset D")
}
if ind.N < 0 {
ind.N = D.NumElements() - ind.OffsetD
}
if ind.N < 0 {
return onError("Gttrf: size D")
}
if ind.N == 0 {
return nil
}
if ind.OffsetDL < 0 {
return onError("Gttrf: offset DL")
}
sizeDL := DL.NumElements()
if sizeDL < ind.OffsetDL+ind.N-1 {
return onError("Gttrf: sizeDL")
}
if ind.OffsetDU < 0 {
return onError("Gttrf: offset DU")
}
sizeDU := DU.NumElements()
if sizeDU < ind.OffsetDU+ind.N-1 {
return onError("Gttrf: sizeDU")
}
sizeDU2 := DU2.NumElements()
if sizeDU2 < ind.N-2 {
return onError("Gttrf: sizeDU2")
}
if len(ipiv) < ind.N {
return onError("Gttrf: size ipiv")
}
info := -1
if !matrix.EqualTypes(DL, D, DU, DU2) {
return onError("Gttrf: arguments not same type")
}
switch DL.(type) {
case *matrix.FloatMatrix:
DLa := DL.(*matrix.FloatMatrix).FloatArray()
Da := D.(*matrix.FloatMatrix).FloatArray()
DUa := DU.(*matrix.FloatMatrix).FloatArray()
DU2a := DU2.(*matrix.FloatMatrix).FloatArray()
info = dgttrf(ind.N, DLa[ind.OffsetDL:], Da[ind.OffsetD:], DUa[ind.OffsetDU:],
DU2a, ipiv)
case *matrix.ComplexMatrix:
return onError("Gttrf: complex not yet implemented")
}
if info != 0 {
return onError(fmt.Sprintf("Gttrf lapack error: %d", info))
}
return nil
}
开发者ID:jvlmdr,项目名称:linalg,代码行数:80,代码来源:gttrf.go
示例5: Gels
/*
Solves a general real or complex set of linear equations.
PURPOSE
Solves A*X=B with A m by n real or complex.
ARGUMENTS.
A float or complex matrix
B float or complex matrix. Must have the same type as A.
OPTIONS:
trans
m nonnegative integer. If negative, the default value is used.
n nonnegative integer. If negative, the default value is used.
nrhs nonnegative integer. If negative, the default value is used.
ldA positive integer. ldA >= max(1,n). If zero, the default value is used.
ldB positive integer. ldB >= max(1,n). If zero, the default value is used.
*/
func Gels(A, B matrix.Matrix, opts ...linalg.Option) error {
pars, _ := linalg.GetParameters(opts...)
ind := linalg.GetIndexOpts(opts...)
arows := ind.LDa
brows := ind.LDb
if ind.M < 0 {
ind.M = A.Rows()
}
if ind.N < 0 {
ind.N = A.Cols()
}
if ind.Nrhs < 0 {
ind.Nrhs = B.Cols()
}
if ind.M == 0 || ind.N == 0 || ind.Nrhs == 0 {
return nil
}
if ind.LDa == 0 {
ind.LDa = max(1, A.LeadingIndex())
arows = max(1, A.Rows())
}
if ind.LDa < max(1, ind.M) {
return onError("Gesv: ldA")
}
if ind.LDb == 0 {
ind.LDb = max(1, B.LeadingIndex())
brows = max(1, B.Rows())
}
if ind.LDb < max(ind.M, ind.N) {
return onError("Gesv: ldB")
}
if !matrix.EqualTypes(A, B) {
return onError("Gesv: arguments not of same type")
}
_, _ = arows, brows // todo!! something
info := -1
trans := linalg.ParamString(pars.Trans)
switch A.(type) {
case *matrix.FloatMatrix:
Aa := A.(*matrix.FloatMatrix).FloatArray()
Ba := B.(*matrix.FloatMatrix).FloatArray()
info = dgels(trans, ind.M, ind.N, ind.Nrhs, Aa[ind.OffsetA:], ind.LDa,
Ba[ind.OffsetB:], ind.LDb)
case *matrix.ComplexMatrix:
Aa := A.(*matrix.ComplexMatrix).ComplexArray()
Ba := B.(*matrix.ComplexMatrix).ComplexArray()
info = zgels(trans, ind.M, ind.N, ind.Nrhs, Aa[ind.OffsetA:], ind.LDa,
Ba[ind.OffsetB:], ind.LDb)
}
if info != 0 {
return onError(fmt.Sprintf("Gels: lapack error: %d", info))
}
return nil
}
开发者ID:jvlmdr,项目名称:linalg,代码行数:73,代码来源:gels.go
示例6: Syevr
/*
Computes selected eigenvalues and eigenvectors of a real symmetric
matrix (RRR driver).
PURPOSE
Computes selected eigenvalues/vectors of a real symmetric n by n
matrix A.
If range is PRangeAll, all eigenvalues are computed.
If range is PRangeV all eigenvalues in the interval (vlimit[0],vlimit[1]] are
computed.
If range is PRangeI, all eigenvalues ilimit[0] through ilimit[1] are computed
(sorted in ascending order with 1 <= ilimit[0] <= ilimit[1] <= n).
If jobz is PJobNo, only the eigenvalues are returned in W.
If jobz is PJobV, the eigenvectors are also returned in Z.
On exit, the content of A is destroyed.
Syevr is usually the fastest of the four eigenvalue routines.
ARGUMENTS
A float matrix
W float matrix of length at least n. On exit, contains
the computed eigenvalues in ascending order.
Z float matrix or nil. Only required when jobz = PJobV.
If range is PRangeAll or PRangeV, Z must have at least n columns.
If range is PRangeI, Z must have at least iu-il+1 columns.
On exit the first m columns of Z contain the computed
(normalized) eigenvectors.
abstol double. Absolute error tolerance for eigenvalues.
If nonpositive, the LAPACK default value is used.
vlmit []float or nil. Only required when range is PRangeV.
ilimit []int or nil. Only required when range is PRangeI.
OPTIONS
jobz PJobNo or PJobV
range PRangeAll, PRangeV or PRangeI
uplo PLower or PUpper
n integer. If negative, the default value is used.
ldA nonnegative integer. ldA >= max(1,n).
If zero, the default value is used.
ldZ nonnegative integer. ldZ >= 1 if jobz is 'N' and
ldZ >= max(1,n) if jobz is PJobV. The default value
is 1 if jobz is PJobNo and max(1,Z.Rows) if jobz =PJboV.
If zero, the default value is used.
offsetA nonnegative integer
offsetW nonnegative integer
offsetZ nonnegative integer
m the number of eigenvalues computed
*/
func Syevr(A, W, Z matrix.Matrix, abstol float64, vlimit []float64, ilimit []int, opts ...linalg.Option) error {
if !matrix.EqualTypes(A, W, Z) {
return onError("Syevr: arguments not of same type")
}
switch A.(type) {
case *matrix.FloatMatrix:
Am := A.(*matrix.FloatMatrix)
Wm := W.(*matrix.FloatMatrix)
Zm := Z.(*matrix.FloatMatrix)
return SyevrFloat(Am, Wm, Zm, abstol, vlimit, ilimit, opts...)
}
return onError("Syevr: unknown types")
}
开发者ID:jvlmdr,项目名称:linalg,代码行数:65,代码来源:syevr.go
示例7: Syevd
/*
Eigenvalue decomposition of a real symmetric matrix
(divide-and-conquer driver).
PURPOSE
Returns eigenvalues/vectors of a real symmetric nxn matrix A.
On exit, W contains the eigenvalues in ascending order.
If jobz is PJobV, the (normalized) eigenvectors are also computed
and returned in A. If jobz is PJobNo, only the eigenvalues are
computed, and the content of A is destroyed.
ARGUMENTS
A float matrix
W float matrix of length at least n. On exit, contains
the computed eigenvalues in ascending order.
OPTIONS
jobz PJobNo or PJobV
uplo PLower or PUpper
n integer. If negative, the default value is used.
ldA nonnegative integer. ldA >= max(1,n). If zero, the
default value is used.
offsetA nonnegative integer
offsetB nonnegative integer;
*/
func Syevd(A, W matrix.Matrix, opts ...linalg.Option) error {
if !matrix.EqualTypes(A, W) {
return onError("Syevd: arguments not of same type")
}
switch A.(type) {
case *matrix.FloatMatrix:
Am := A.(*matrix.FloatMatrix)
Wm := W.(*matrix.FloatMatrix)
return SyevdFloat(Am, Wm, opts...)
case *matrix.ComplexMatrix:
return onError("Syevd: not a complex function")
}
return onError("Syevd: unknown types")
}
开发者ID:jvlmdr,项目名称:linalg,代码行数:40,代码来源:syevd.go
示例8: Herk
/*
Rank-k update of symmetric matrix. (L3)
Herk(A, C, alpha, beta, uplo=PLower, trans=PNoTrans, n=-1,
k=-1, ldA=max(1,A.Rows), ldC=max(1,C.Rows), offsetA=0, offsetB=0)
Computes
C := alpha*A*A^T + beta*C, if trans is PNoTrans
C := alpha*A^T*A + beta*C, if trans is PTrans
C is symmetric (real or complex) of order n. The inner dimension of the matrix
product is k. If k=0 this is interpreted as C := beta*C.
ARGUMENTS
A float or complex matrix.
C float or complex matrix. Must have the same type as A.
alpha number (float or complex singleton matrix). Complex alpha is only
allowed if A is complex.
beta number (float or complex singleton matrix). Complex beta is only
allowed if A is complex.
OPTIONS
uplo PLower or PUpper
trans PNoTrans or PTrans
n integer. If negative, the default value is used.
The default value is n = A.Rows or if trans == PNoTrans n = A.Cols.
k integer. If negative, the default value is used.
The default value is k = A.Cols, or if trans == PNoTrans k = A.Rows.
ldA nonnegative integer.
ldA >= max(1,n) or if trans != PNoTrans ldA >= max(1,k).
If zero, the default value is used.
ldC nonnegative integer. ldC >= max(1,n).
If zero, the default value is used.
offsetA nonnegative integer
offsetC nonnegative integer;
*/
func Herk(A, C matrix.Matrix, alpha, beta matrix.Scalar, opts ...linalg.Option) (err error) {
params, e := linalg.GetParameters(opts...)
if e != nil {
err = e
return
}
ind := linalg.GetIndexOpts(opts...)
err = check_level3_func(ind, fsyrk, A, nil, C, params)
if e != nil || err != nil {
return
}
if !matrix.EqualTypes(A, C) {
return onError("Parameters not of same type")
}
switch A.(type) {
case *matrix.FloatMatrix:
Aa := A.(*matrix.FloatMatrix).FloatArray()
Ca := C.(*matrix.FloatMatrix).FloatArray()
aval := alpha.Float()
bval := beta.Float()
if math.IsNaN(aval) || math.IsNaN(bval) {
return onError("alpha or beta not a number")
}
uplo := linalg.ParamString(params.Uplo)
trans := linalg.ParamString(params.Trans)
dsyrk(uplo, trans, ind.N, ind.K, aval, Aa[ind.OffsetA:], ind.LDa, bval,
Ca[ind.OffsetC:], ind.LDc)
case *matrix.ComplexMatrix:
Aa := A.(*matrix.ComplexMatrix).ComplexArray()
Ca := C.(*matrix.ComplexMatrix).ComplexArray()
aval := alpha.Complex()
if cmplx.IsNaN(aval) {
return onError("alpha not a real or complex number")
}
bval := beta.Float()
if math.IsNaN(bval) {
return onError("beta not a real number")
}
uplo := linalg.ParamString(params.Uplo)
trans := linalg.ParamString(params.Trans)
zherk(uplo, trans, ind.N, ind.K, aval, Aa[ind.OffsetA:], ind.LDa, bval,
Ca[ind.OffsetC:], ind.LDc)
default:
return onError("Unknown type, not implemented")
}
return
}
开发者ID:jvlmdr,项目名称:linalg,代码行数:85,代码来源:level3.go
示例9: Gbsv
/*
Solves a real or complex set of linear equations with a banded
coefficient matrix.
PURPOSE
Solves A*X = B
A an n by n real or complex band matrix with kl subdiagonals and
ku superdiagonals.
If ipiv is provided, then on entry the kl+ku+1 diagonals of the
matrix are stored in rows kl+1 to 2*kl+ku+1 of A, in the BLAS
format for general band matrices. On exit, A and ipiv contain the
details of the factorization. If ipiv is not provided, then on
entry the diagonals of the matrix are stored in rows 1 to kl+ku+1
of A, and Gbsv() does not return the factorization and does not
modify A. On exit B is replaced with solution X.
ARGUMENTS.
A float or complex banded matrix
B float or complex matrix. Must have the same type as A.
kl nonnegative integer
ipiv int array of length at least n
OPTIONS
ku nonnegative integer. If negative, the default value is
used. The default value is A.Rows-kl-1 if ipiv is
not provided, and A.Rows-2*kl-1 otherwise.
n nonnegative integer. If negative, the default value is used.
nrhs nonnegative integer. If negative, the default value is used.
ldA positive integer. ldA >= kl+ku+1 if ipiv is not provided
and ldA >= 2*kl+ku+1 if ipiv is provided. If zero, the
default value is used.
ldB positive integer. ldB >= max(1,n). If zero, the default
default value is used.
offsetA nonnegative integer
offsetB nonnegative integer;
*/
func Gbsv(A, B matrix.Matrix, ipiv []int32, kl int, opts ...linalg.Option) error {
if !matrix.EqualTypes(A, B) {
return onError("Gbsv: not same type")
}
switch A.(type) {
case *matrix.FloatMatrix:
Am := A.(*matrix.FloatMatrix)
Bm := B.(*matrix.FloatMatrix)
return GbsvFloat(Am, Bm, ipiv, kl, opts...)
case *matrix.ComplexMatrix:
Am := A.(*matrix.ComplexMatrix)
Bm := B.(*matrix.ComplexMatrix)
return GbsvComplex(Am, Bm, ipiv, kl, opts...)
}
return onError("Gbsv: unknown types types!")
}
开发者ID:jvlmdr,项目名称:linalg,代码行数:56,代码来源:gbsv.go
示例10: Posv
/*
Solves a real symmetric or complex Hermitian positive definite set
of linear equations.
PURPOSE
Solves A*X = B with A n by n, real symmetric or complex Hermitian,
and positive definite, and B n by nrhs.
On exit, if uplo is PLower, the lower triangular part of A is
replaced by L. If uplo is PUpper, the upper triangular part is
replaced by L^H. B is replaced by the solution.
ARGUMENTS.
A float or complex matrix
B float or complex matrix. Must have the same type as A.
OPTIONS
uplo PLower or PUpper
n nonnegative integer. If negative, the default value is used.
nrhs nonnegative integer. If negative, the default value is used.
ldA positive integer. ldA >= max(1,n). If zero, the default value is used.
ldB positive integer. ldB >= max(1,n). If zero, the default value is used.
offsetA nonnegative integer
offsetB nonnegative integer
*/
func Posv(A, B matrix.Matrix, opts ...linalg.Option) error {
if !matrix.EqualTypes(A, B) {
return onError("Posv: arguments not same type")
}
switch A.(type) {
case *matrix.FloatMatrix:
Am := A.(*matrix.FloatMatrix)
Bm := B.(*matrix.FloatMatrix)
return PosvFloat(Am, Bm, opts...)
case *matrix.ComplexMatrix:
Am := A.(*matrix.ComplexMatrix)
Bm := B.(*matrix.ComplexMatrix)
return PosvComplex(Am, Bm, opts...)
}
return onError("Posv: unknown types")
}
开发者ID:jvlmdr,项目名称:linalg,代码行数:41,代码来源:posv.go
示例11: Syevx
/*
Computes selected eigenvalues and eigenvectors of a real symmetric
matrix (expert driver).
PURPOSE
Computes selected eigenvalues/vectors of a real symmetric n by n
matrix A.
If range is OptRangeAll, all eigenvalues are computed.
If range is OptRangeValue, all eigenvalues in the interval (vlimit[0],vlimit[1]] are
computed.
If range is OptRangeInt, all eigenvalues il through iu are computed
(sorted in ascending order with 1 <= il <= iu <= n).
If jobz is OptJobNo, only the eigenvalues are returned in W.
If jobz is OptJobValue, the eigenvectors are also returned in Z.
On exit, the content of A is destroyed.
ARGUMENTS
A float matrix
W float matrix of length at least n. On exit, contains
the computed eigenvalues in ascending order.
Z float matrix. Only required when jobz is PJobValue. If range
is PRangeAll or PRangeValue, Z must have at least n columns. If
range is PRangeInt, Z must have at least iu-il+1 columns.
On exit the first m columns of Z contain the computed (normalized) eigenvectors.
vlimit []float64 or nul. Only required when range is PRangeValue
ilimit []int or nil. Only required when range is PRangeInt.
abstol double. Absolute error tolerance for eigenvalues.
If nonpositive, the LAPACK default value is used.
OPTIONS
jobz linalg.OptJobNo or linalg.OptJobValue
range linalg.OptRangeAll, linalg.OptRangeValue or linalg.OptRangeInt
uplo linalg.OptLower or linalg.OptUpper
n integer. If negative, the default value is used.
m the number of eigenvalues computed;
ldA nonnegative integer. ldA >= max(1,n). If zero, the
default value is used.
ldZ nonnegative integer. ldZ >= 1 if jobz is PJobNo and
ldZ >= max(1,n) if jobz is PJobValue. The default value
is 1 if jobz is PJobNo and max(1,Z.size[0]) if jobz =PJobValue.
If zero, the default value is used.
offsetA nonnegative integer
offsetW nonnegative integer
offsetZ nonnegative integer
*/
func Syevx(A, W, Z matrix.Matrix, abstol float64, vlimit []float64, ilimit []int, opts ...linalg.Option) error {
if !matrix.EqualTypes(A, W, Z) {
return onError("Syevx: not same type")
}
switch A.(type) {
case *matrix.FloatMatrix:
Am := A.(*matrix.FloatMatrix)
Wm := W.(*matrix.FloatMatrix)
var Zm *matrix.FloatMatrix = nil
if Z != nil {
Zm = Z.(*matrix.FloatMatrix)
}
return SyevrFloat(Am, Wm, Zm, abstol, vlimit, ilimit, opts...)
}
return onError("Syevr: unknown types")
}
开发者ID:jvlmdr,项目名称:linalg,代码行数:65,代码来源:syevx.go
示例12: Trsm
/*
Solution of a triangular system of equations with multiple righthand sides. (L3)
Trsm(A, B, alpha, side=PLeft, uplo=PLower, transA=PNoTrans, diag=PNonUnit,
m=-1, n=-1, ldA=max(1,A.Rows), ldB=max(1,B.Rows), offsetA=0, offsetB=0)
Computes
B := alpha*A^{-1}*B if transA is PNoTrans and side = PLeft
B := alpha*B*A^{-1} if transA is PNoTrans and side = PRight
B := alpha*A^{-T}*B if transA is PTrans and side = PLeft
B := alpha*B*A^{-T} if transA is PTrans and side = PRight
B := alpha*A^{-H}*B if transA is PConjTrans and side = PLeft
B := alpha*B*A^{-H} if transA is PConjTrans and side = PRight
B is m by n and A is triangular. The code does not verify whether A is nonsingular.
ARGUMENTS
A float or complex matrix.
B float or complex matrix. Must have the same type as A.
alpha number (float or complex). Complex alpha is only
allowed if A is complex.
OPTIONS
side PLeft or PRight
uplo PLower or PUpper
transA PNoTrans or PTrans
diag PNonUnit or PUnit
m integer. If negative, the default value is used.
The default value is m = A.Rows or if side == PRight m = B.Rows
If the default value is used and side is PLeft, m must be equal to A.Cols.
n integer. If negative, the default value is used.
The default value is n = B.Cols or if side )= PRight n = A.Rows.
If the default value is used and side is PRight, n must be equal to A.Cols.
ldA nonnegative integer.
ldA >= max(1,m) of if side == PRight lda >= max(1,n).
If zero, the default value is used.
ldB nonnegative integer. ldB >= max(1,m).
If zero, the default value is used.
offsetA nonnegative integer
offsetB nonnegative integer
*/
func Trsm(A, B matrix.Matrix, alpha matrix.Scalar, opts ...linalg.Option) (err error) {
params, e := linalg.GetParameters(opts...)
if e != nil {
err = e
return
}
ind := linalg.GetIndexOpts(opts...)
err = check_level3_func(ind, ftrsm, A, B, nil, params)
if err != nil {
return
}
if !matrix.EqualTypes(A, B) {
return onError("Parameters not of same type")
}
switch A.(type) {
case *matrix.FloatMatrix:
Aa := A.(*matrix.FloatMatrix).FloatArray()
Ba := B.(*matrix.FloatMatrix).FloatArray()
aval := alpha.Float()
if math.IsNaN(aval) {
return onError("alpha or beta not a number")
}
uplo := linalg.ParamString(params.Uplo)
transA := linalg.ParamString(params.TransA)
side := linalg.ParamString(params.Side)
diag := linalg.ParamString(params.Diag)
dtrsm(side, uplo, transA, diag, ind.M, ind.N, aval,
Aa[ind.OffsetA:], ind.LDa, Ba[ind.OffsetB:], ind.LDb)
case *matrix.ComplexMatrix:
Aa := A.(*matrix.ComplexMatrix).ComplexArray()
Ba := B.(*matrix.ComplexMatrix).ComplexArray()
aval := alpha.Complex()
if cmplx.IsNaN(aval) {
return onError("alpha not a number")
}
uplo := linalg.ParamString(params.Uplo)
transA := linalg.ParamString(params.TransA)
side := linalg.ParamString(params.Side)
diag := linalg.ParamString(params.Diag)
ztrsm(side, uplo, transA, diag, ind.M, ind.N, aval,
Aa[ind.OffsetA:], ind.LDa, Ba[ind.OffsetB:], ind.LDb)
default:
return onError("Unknown type, not implemented")
}
return
}
开发者ID:jvlmdr,项目名称:linalg,代码行数:88,代码来源:level3.go
示例13: Geqrf
/*
QR factorization.
PURPOSE
QR factorization of an m by n real or complex matrix A:
A = Q*R = [Q1 Q2] * [R1; 0] if m >= n
A = Q*R = Q * [R1 R2] if m <= n,
where Q is m by m and orthogonal/unitary and R is m by n with R1
upper triangular. On exit, R is stored in the upper triangular
part of A. Q is stored as a product of k=min(m,n) elementary
reflectors. The parameters of the reflectors are stored in the
first k entries of tau and in the lower triangular part of the
first k columns of A.
ARGUMENTS
A float or complex matrix
tau float or complex matrix of length at least min(m,n). Must
have the same type as A.
m integer. If negative, the default value is used.
n integer. If negative, the default value is used.
ldA nonnegative integer. ldA >= max(1,m). If zero, the
default value is used.
offsetA nonnegative integer
*/
func Geqrf(A, tau matrix.Matrix, opts ...linalg.Option) error {
ind := linalg.GetIndexOpts(opts...)
arows := ind.LDa
if ind.N < 0 {
ind.N = A.Cols()
}
if ind.M < 0 {
ind.M = A.Rows()
}
if ind.N == 0 || ind.M == 0 {
return nil
}
if ind.LDa == 0 {
ind.LDa = max(1, A.LeadingIndex())
arows = max(1, A.Rows())
}
if ind.LDa < max(1, ind.M) {
return onError("Geqrf: ldA")
}
if ind.OffsetA < 0 {
return onError("Geqrf: offsetA")
}
if A.NumElements() < ind.OffsetA+ind.K*arows {
return onError("Geqrf: sizeA")
}
if tau.NumElements() < min(ind.M, ind.N) {
return onError("Geqrf: sizeTau")
}
if !matrix.EqualTypes(A, tau) {
return onError("Geqrf: arguments not of same type")
}
info := -1
switch A.(type) {
case *matrix.FloatMatrix:
Aa := A.(*matrix.FloatMatrix).FloatArray()
taua := tau.(*matrix.FloatMatrix).FloatArray()
info = dgeqrf(ind.M, ind.N, Aa[ind.OffsetA:], ind.LDa, taua)
case *matrix.ComplexMatrix:
return onError("Geqrf: complex not yet implemented")
}
if info != 0 {
return onError(fmt.Sprintf("Geqrf lapack error: %d", info))
}
return nil
}
开发者ID:jvlmdr,项目名称:linalg,代码行数:73,代码来源:geqrf.go
示例14: Gesvd
/*
Singular value decomposition of a real or complex matrix.
PURPOSE
Computes singular values and, optionally, singular vectors of a
real or complex m by n matrix A.
The argument jobu controls how many left singular vectors are
computed:
PJobNo : no left singular vectors are computed.
PJobAll: all left singular vectors are computed and returned as
columns of U.
PJobS : the first min(m,n) left singular vectors are computed and
returned as columns of U.
PJobO : the first min(m,n) left singular vectors are computed and
returned as columns of A.
The argument jobvt controls how many right singular vectors are
computed:
PJobNo : no right singular vectors are computed.
PJobAll: all right singular vectors are computed and returned as
rows of Vt.
PJobS : the first min(m,n) right singular vectors are computed and
returned as rows of Vt.
PJobO : the first min(m,n) right singular vectors are computed and
returned as rows of A.
Note that the (conjugate) transposes of the right singular
vectors are returned in Vt or A.
On exit (in all cases), the contents of A are destroyed.
ARGUMENTS
A float or complex matrix
S float matrix of length at least min(m,n). On exit,
contains the computed singular values in descending order.
jobu PJobNo, PJobAll, PJobS or PJobO
jobvt PJobNo, PJobAll, PJobS or PJobO
U float or complex matrix. Must have the same type as A.
Not referenced if jobu is PJobNo or PJobO. If jobu is PJobAll,
a matrix with at least m columns. If jobu is PJobS, a
matrix with at least min(m,n) columns.
On exit (with jobu PJobAll or PJobS), the columns of U
contain the computed left singular vectors.
Vt float or complex matrix. Must have the same type as A.
Not referenced if jobvt is PJobNo or PJobO. If jobvt is
PJobAll or PJobS, a matrix with at least n columns.
On exit (with jobvt PJobAll or PJobS), the rows of Vt
contain the computed right singular vectors, or, in
the complex case, their complex conjugates.
m integer. If negative, the default value is used.
n integer. If negative, the default value is used.
ldA nonnegative integer. ldA >= max(1,m).
If zero, the default value is used.
ldU nonnegative integer.
ldU >= 1 if jobu is PJobNo or PJobO
ldU >= max(1,m) if jobu is PJobAll or PJobS.
The default value is max(1,U.Rows) if jobu is PJobAll
or PJobS, and 1 otherwise.
If zero, the default value is used.
ldVt nonnegative integer.
ldVt >= 1 if jobvt is PJobNo or PJobO.
ldVt >= max(1,n) if jobvt is PJobAll.
ldVt >= max(1,min(m,n)) if ldVt is PJobS.
The default value is max(1,Vt.Rows) if jobvt is PJobAll
or PJobS, and 1 otherwise.
If zero, the default value is used.
offsetA nonnegative integer
offsetS nonnegative integer
offsetU nonnegative integer
offsetVt nonnegative integer
*/
func Gesvd(A, S, U, Vt matrix.Matrix, opts ...linalg.Option) error {
if !matrix.EqualTypes(A, S, U, Vt) {
return onError("Gesvd: arguments not of same type")
}
switch A.(type) {
case *matrix.FloatMatrix:
Am := A.(*matrix.FloatMatrix)
Sm := S.(*matrix.FloatMatrix)
Um := U.(*matrix.FloatMatrix)
Vm := Vt.(*matrix.FloatMatrix)
return GesvdFloat(Am, Sm, Um, Vm, opts...)
case *matrix.ComplexMatrix:
Am := A.(*matrix.ComplexMatrix)
Sm := S.(*matrix.ComplexMatrix)
Um := U.(*matrix.ComplexMatrix)
Vm := Vt.(*matrix.ComplexMatrix)
return GesvdComplex(Am, Sm, Um, Vm, opts...)
}
return onError("Gesvd: unknown parameter types")
}
开发者ID:jvlmdr,项目名称:linalg,代码行数:95,代码来源:gesvd.go
示例15: Axpy
// Constant times a vector plus a vector (Y := alpha*X+Y).
//
// ARGUMENTS
// X float or complex matrix
// Y float or complex matrix. Must have the same type as X.
// alpha number (float or complex singleton matrix). Complex alpha is only
// allowed if x is complex.
//
// OPTIONS
// n integer. If n<0, the default value of n is used.
// The default value is equal to 1+(len(x)-offsetx-1)/incx
// or 0 if len(x) >= offsetx+1
// incx nonzero integer
// incy nonzero integer
// offsetx nonnegative integer
// offsety nonnegative integer;
//
func Axpy(X, Y matrix.Matrix, alpha matrix.Scalar, opts ...linalg.Option) (err error) {
ind := linalg.GetIndexOpts(opts...)
err = check_level1_func(ind, faxpy, X, Y)
if err != nil {
return
}
if ind.Nx == 0 {
return
}
sameType := matrix.EqualTypes(X, Y)
if !sameType {
err = onError("arrays not same type")
return
}
switch X.(type) {
case *matrix.ComplexMatrix:
Xa := X.(*matrix.ComplexMatrix).ComplexArray()
Ya := Y.(*matrix.ComplexMatrix).ComplexArray()
aval := alpha.Complex()
if cmplx.IsNaN(aval) {
return onError("alpha not complex value")
}
zaxpy(ind.Nx, aval, Xa[ind.OffsetX:],
ind.IncX, Ya[ind.OffsetY:], ind.IncY)
case *matrix.FloatMatrix:
Xa := X.(*matrix.FloatMatrix).FloatArray()
Ya := Y.(*matrix.FloatMatrix).FloatArray()
aval := alpha.Float()
if math.IsNaN(aval) {
return onError("alpha not float value")
}
daxpy(ind.Nx, aval, Xa[ind.OffsetX:],
ind.IncX, Ya[ind.OffsetY:], ind.IncY)
default:
err = onError("not implemented for parameter types")
}
return
}
开发者ID:hrautila,项目名称:linalg,代码行数:55,代码来源:level1.go
示例16: Gesv
/*
Solves a general real or complex set of linear equations.
PURPOSE
Solves A*X=B with A n by n real or complex.
If ipiv is provided, then on exit A is overwritten with the details
of the LU factorization, and ipiv contains the permutation matrix.
If ipiv is not provided, then gesv() does not return the
factorization and does not modify A. On exit B is replaced with
the solution X.
ARGUMENTS.
A float or complex matrix
B float or complex matrix. Must have the same type as A.
ipiv int vector of length at least n
OPTIONS:
n nonnegative integer. If negative, the default value is used.
nrhs nonnegative integer. If negative, the default value is used.
ldA positive integer. ldA >= max(1,n). If zero, the default value is used.
ldB positive integer. ldB >= max(1,n). If zero, the default value is used.
offsetA nonnegative integer
offsetA nonnegative integer;
*/
func Gesv(A, B matrix.Matrix, ipiv []int32, opts ...linalg.Option) error {
//pars, err := linalg.GetParameters(opts...)
ind := linalg.GetIndexOpts(opts...)
arows := ind.LDa
brows := ind.LDb
if ind.N < 0 {
ind.N = A.Rows()
if ind.N != A.Cols() {
return onError("Gesv: A not square")
}
}
if ind.Nrhs < 0 {
ind.Nrhs = B.Cols()
}
if ind.N == 0 || ind.Nrhs == 0 {
return nil
}
if ind.LDa == 0 {
ind.LDa = max(1, A.LeadingIndex())
arows = max(1, A.Rows())
}
if ind.LDa < max(1, ind.N) {
return onError("Gesv: ldA")
}
if ind.LDb == 0 {
ind.LDb = max(1, B.LeadingIndex())
brows = max(1, B.Rows())
}
if ind.LDb < max(1, ind.N) {
return onError("Gesv: ldB")
}
if ind.OffsetA < 0 {
return onError("Gesv: offsetA")
}
if ind.OffsetB < 0 {
return onError("Gesv: offsetB")
}
sizeA := A.NumElements()
if sizeA < ind.OffsetA+(ind.N-1)*arows+ind.N {
return onError("Gesv: sizeA")
}
sizeB := B.NumElements()
if sizeB < ind.OffsetB+(ind.Nrhs-1)*brows+ind.N {
return onError("Gesv: sizeB")
}
if ipiv != nil && len(ipiv) < ind.N {
return onError("Gesv: size ipiv")
}
if !matrix.EqualTypes(A, B) {
return onError("Gesv: arguments not of same type")
}
info := -1
if ipiv == nil {
ipiv = make([]int32, ind.N)
// Do not overwrite A.
A = A.MakeCopy()
}
switch A.(type) {
case *matrix.FloatMatrix:
Aa := A.(*matrix.FloatMatrix).FloatArray()
Aa = Aa[ind.OffsetA:]
// Ensure there are sufficient elements in A.
Aa = Aa[:ind.LDa*ind.LDb]
Ba := B.(*matrix.FloatMatrix).FloatArray()
Ba = Ba[ind.OffsetB:]
info = dgesv(ind.N, ind.Nrhs, Aa, ind.LDa, ipiv, Ba, ind.LDb)
case *matrix.ComplexMatrix:
Aa := A.(*matrix.ComplexMatrix).ComplexArray()
Aa = Aa[ind.OffsetA:]
// Ensure there are sufficient elements in A.
Aa = Aa[:ind.LDa*ind.LDb]
Ba := B.(*matrix.ComplexMatrix).ComplexArray()
Ba = Ba[ind.OffsetB:]
info = zgesv(ind.N, ind.Nrhs, Aa, ind.LDa, ipiv, Ba, ind.LDb)
//.........这里部分代码省略.........
开发者ID:jvlmdr,项目名称:linalg,代码行数:101,代码来源:gesv.go
示例17: Gtrrs
/*
Solves a real or complex tridiagonal set of linear equations,
given the LU factorization computed by gttrf().
PURPOSE
solves A*X=B, if trans is PNoTrans
solves A^T*X=B, if trans is PTrans
solves A^H*X=B, if trans is PConjTrans
On entry, DL, D, DU, DU2 and ipiv contain the LU factorization of
an n by n tridiagonal matrix A as computed by gttrf(). On exit B
is replaced by the solution X.
ARGUMENTS.
DL float or complex matrix
D float or complex matrix. Must have the same type as dl.
DU float or complex matrix. Must have the same type as dl.
DU2 float or complex matrix. Must have the same type as dl.
B float or complex matrix. Must have the same type oas dl.
ipiv int vector
OPTIONS
trans PNoTrans, PTrans, PConjTrans
n nonnegative integer. If negative, the default value is used.
nrhs nonnegative integer. If negative, the default value is used.
ldB positive integer, ldB >= max(1,n). If zero, the default value is used.
offsetdl nonnegative integer
offsetd nonnegative integer
offsetdu nonnegative integer
offsetB nonnegative integer
*/
func Gtrrs(DL, D, DU, DU2, B matrix.Matrix, ipiv []int32, opts ...linalg.Option) error {
pars, err := linalg.GetParameters(opts...)
if err != nil {
return err
}
ind := linalg.GetIndexOpts(opts...)
brows := ind.LDb
if ind.OffsetD < 0 {
return onError("Gttrs: offset D")
}
if ind.N < 0 {
ind.N = D.NumElements() - ind.OffsetD
}
if ind.N < 0 {
return onError("Gttrs: size D")
}
if ind.N == 0 {
return nil
}
if ind.OffsetDL < 0 {
return onError("Gttrs: offset DL")
}
sizeDL := DL.NumElements()
if sizeDL < ind.OffsetDL+ind.N-1 {
return onError("Gttrs: sizeDL")
}
if ind.OffsetDU < 0 {
return onError("Gttrs: offset DU")
}
sizeDU := DU.NumElements()
if sizeDU < ind.OffsetDU+ind.N-1 {
return onError("Gttrs: sizeDU")
}
sizeDU2 := DU2.NumElements()
if sizeDU2 < ind.N-2 {
return onError("Gttrs: sizeDU2")
}
if ind.Nrhs < 0 {
ind.Nrhs = B.Cols()
}
if ind.Nrhs == 0 {
return nil
}
if ind.LDb == 0 {
ind.LDb = max(1, B.LeadingIndex())
brows = max(1, B.Rows())
}
if ind.LDb < max(1, ind.N) {
return onError("Gttrs: ldB")
}
if ind.OffsetB < 0 {
return onError("Gttrs: offset B")
}
sizeB := B.NumElements(
|
请发表评论