本文整理匯總了Golang中github.com/henrylee2cn/algorithm/linalg.GetIndexOpts函數的典型用法代碼示例。如果您正苦於以下問題:Golang GetIndexOpts函數的具體用法?Golang GetIndexOpts怎麽用?Golang GetIndexOpts使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GetIndexOpts函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Scal
// Scales a vector by a constant (X := alpha*X).
//
// ARGUMENTS
// X float or complex matrix
// 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)-offset-1)/inc or 0
// if len(x) > offset+1.
// inc positive integer, default = 1
// offset nonnegative integer, default = 0
//
func Scal(X matrix.Matrix, alpha matrix.Scalar, opts ...linalg.Option) (err error) {
ind := linalg.GetIndexOpts(opts...)
err = check_level1_func(ind, fscal, X, nil)
if err != nil {
return
}
if ind.Nx == 0 {
return
}
switch X.(type) {
case *matrix.ComplexMatrix:
Xa := X.(*matrix.ComplexMatrix).ComplexArray()
cval := alpha.Complex()
zscal(ind.Nx, cval, Xa[ind.OffsetX:], ind.IncX)
case *matrix.FloatMatrix:
Xa := X.(*matrix.FloatMatrix).FloatArray()
rval := alpha.Float()
if math.IsNaN(rval) {
return onError("alpha not float value")
}
dscal(ind.Nx, rval, Xa[ind.OffsetX:], ind.IncX)
default:
err = onError("not implemented for parameter types")
}
return
}
示例2: Tbsv
/*
Solution of a triangular and banded set of equations.
Tbsv(A, X, uplo=PLower, trans=PNoTrans, diag=PNonDiag, n=A.Cols,
k=max(0,A.Rows-1), ldA=A.size[0], incx=1, offsetA=0, offsetx=0)
PURPOSE
X := A^{-1}*X, if trans is PNoTrans
X := A^{-T}*X, if trans is PTrans
X := A^{-H}*X, if trans is PConjTrans
A is banded triangular of order n and with bandwidth k.
ARGUMENTS
A float or complex m*k matrix.
X float or complex k*1 matrix. Must have the same type as A.
OPTIONS
uplo PLower or PUpper
trans PNoTrans, PTrans or PConjTrans
diag PNoNUnit or PUnit
n nonnegative integer. If negative, the default value is used.
k nonnegative integer. If negative, the default value is used.
ldA nonnegative integer. ldA >= 1+k.
If zero the default value is used.
incx nonzero integer
offsetA nonnegative integer
offsetx nonnegative integer;
*/
func Tbsv(A, X matrix.Matrix, opts ...linalg.Option) (err error) {
var params *linalg.Parameters
if !matrix.EqualTypes(A, X) {
err = onError("Parameters not of same type")
return
}
params, err = linalg.GetParameters(opts...)
if err != nil {
return
}
ind := linalg.GetIndexOpts(opts...)
err = check_level2_func(ind, ftbsv, X, nil, A, params)
if err != nil {
return
}
if ind.N == 0 {
return
}
switch X.(type) {
case *matrix.FloatMatrix:
Xa := X.(*matrix.FloatMatrix).FloatArray()
Aa := A.(*matrix.FloatMatrix).FloatArray()
uplo := linalg.ParamString(params.Uplo)
trans := linalg.ParamString(params.Trans)
diag := linalg.ParamString(params.Diag)
dtbsv(uplo, trans, diag, ind.N, ind.K,
Aa[ind.OffsetA:], ind.LDa, Xa[ind.OffsetX:], ind.IncX)
case *matrix.ComplexMatrix:
return onError("Not implemented yet for complx.Matrix")
default:
return onError("Unknown type, not implemented")
}
return
}
示例3: GemmFloat
// See function Gemm.
func GemmFloat(A, B, C *matrix.FloatMatrix, alpha, beta float64, 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
}
Aa := A.FloatArray()
Ba := B.FloatArray()
Ca := C.FloatArray()
transB := linalg.ParamString(params.TransB)
transA := linalg.ParamString(params.TransA)
//diag := linalg.ParamString(params.Diag)
dgemm(transA, transB, ind.M, ind.N, ind.K, alpha,
Aa[ind.OffsetA:], ind.LDa, Ba[ind.OffsetB:], ind.LDb, beta,
Ca[ind.OffsetC:], ind.LDc)
return
}
示例4: 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
}
示例5: GbmvFloat
// See function Gbmv.
func GbmvFloat(A, X, Y *matrix.FloatMatrix, alpha, beta float64, opts ...linalg.Option) (err error) {
var params *linalg.Parameters
params, err = linalg.GetParameters(opts...)
if err != nil {
return
}
ind := linalg.GetIndexOpts(opts...)
err = check_level2_func(ind, fgbmv, X, Y, A, params)
if err != nil {
return
}
if ind.M == 0 && ind.N == 0 {
return
}
Xa := X.FloatArray()
Ya := Y.FloatArray()
Aa := A.FloatArray()
if params.Trans == linalg.PNoTrans && ind.N == 0 {
dscal(ind.M, beta, Ya[ind.OffsetY:], ind.IncY)
} else if params.Trans == linalg.PTrans && ind.M == 0 {
dscal(ind.N, beta, Ya[ind.OffsetY:], ind.IncY)
} else {
trans := linalg.ParamString(params.Trans)
dgbmv(trans, ind.M, ind.N, ind.Kl, ind.Ku,
alpha, Aa[ind.OffsetA:], ind.LDa, Xa[ind.OffsetX:], ind.IncX,
beta, Ya[ind.OffsetY:], ind.IncY)
}
return
}
示例6: Syr2
/*
Symmetric rank-2 update.
syr2(x, y, A, uplo='L', alpha=1.0, n=A.size[0], incx=1, incy=1,
ldA=max(1,A.size[0]), offsetx=0, offsety=0, offsetA=0)
PURPOSE
Computes A := A + alpha*(x*y^T + y*x^T) with A real symmetric matrix of order n.
ARGUMENTS
x float matrix
y float matrix
A float matrix
alpha real number (int or float)
OPTIONS
uplo 'L' or 'U'
n integer. If negative, the default value is used.
incx nonzero integer
incy nonzero integer
ldA nonnegative integer. ldA >= max(1,n).
If zero the default value is used.
offsetx nonnegative integer
offsety nonnegative integer
offsetA nonnegative integer;
*/
func Syr2(X, Y, A matrix.Matrix, alpha matrix.Scalar, opts ...linalg.Option) (err error) {
var params *linalg.Parameters
params, err = linalg.GetParameters(opts...)
if err != nil {
return
}
ind := linalg.GetIndexOpts(opts...)
err = check_level2_func(ind, fsyr2, X, Y, A, params)
if err != nil {
return
}
if !matrix.EqualTypes(A, X, Y) {
return onError("Parameters not of same type")
}
switch X.(type) {
case *matrix.FloatMatrix:
Xa := X.(*matrix.FloatMatrix).FloatArray()
Ya := X.(*matrix.FloatMatrix).FloatArray()
Aa := A.(*matrix.FloatMatrix).FloatArray()
aval := alpha.Float()
if math.IsNaN(aval) {
return onError("alpha not a number")
}
uplo := linalg.ParamString(params.Uplo)
dsyr2(uplo, ind.N, aval, Xa[ind.OffsetX:], ind.IncX,
Ya[ind.OffsetY:], ind.IncY,
Aa[ind.OffsetA:], ind.LDa)
case *matrix.ComplexMatrix:
return onError("Not implemented yet for complx.Matrix")
default:
return onError("Unknown type, not implemented")
}
return
}
示例7: TrsmFloat
// See function Trsm.
func TrsmFloat(A, B *matrix.FloatMatrix, alpha float64, 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 ind.N == 0 || ind.M == 0 {
return
}
Aa := A.FloatArray()
Ba := B.FloatArray()
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, alpha,
Aa[ind.OffsetA:], ind.LDa, Ba[ind.OffsetB:], ind.LDb)
return
}
示例8: Syr2kFloat
// See function Syrk2.
func Syr2kFloat(A, B, C *matrix.FloatMatrix, alpha, beta float64, 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, fsyr2k, A, B, C, params)
if err != nil {
return
}
if ind.N == 0 {
return
}
Aa := A.FloatArray()
Ba := B.FloatArray()
Ca := C.FloatArray()
uplo := linalg.ParamString(params.Uplo)
trans := linalg.ParamString(params.Trans)
//diag := linalg.ParamString(params.Diag)
dsyr2k(uplo, trans, ind.N, ind.K, alpha, Aa[ind.OffsetA:], ind.LDa,
Ba[ind.OffsetB:], ind.LDb, beta, Ca[ind.OffsetC:], ind.LDc)
return
}
示例9: SymmFloat
// See function Symm.
func SymmFloat(A, B, C *matrix.FloatMatrix, alpha, beta float64, 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, fsymm, A, B, C, params)
if err != nil {
return
}
if ind.M == 0 || ind.N == 0 {
return
}
Aa := A.FloatArray()
Ba := B.FloatArray()
Ca := C.FloatArray()
uplo := linalg.ParamString(params.Uplo)
side := linalg.ParamString(params.Side)
dsymm(side, uplo, ind.M, ind.N, alpha, Aa[ind.OffsetA:], ind.LDa,
Ba[ind.OffsetB:], ind.LDb, beta, Ca[ind.OffsetC:], ind.LDc)
return
}
示例10: 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
}
示例11: 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")
}
//.........這裏部分代碼省略.........
示例12: ScalFloat
// See function Scal.
func ScalFloat(X *matrix.FloatMatrix, alpha float64, opts ...linalg.Option) (err error) {
ind := linalg.GetIndexOpts(opts...)
err = check_level1_func(ind, fscal, X, nil)
if err != nil {
return
}
if ind.Nx == 0 {
return
}
Xa := X.FloatArray()
dscal(ind.Nx, alpha, Xa[ind.OffsetX:], ind.IncX)
return
}
示例13: AsumComplex
// See function Asum.
func AsumComplex(X *matrix.ComplexMatrix, opts ...linalg.Option) (v float64, err error) {
v = 0.0
ind := linalg.GetIndexOpts(opts...)
err = check_level1_func(ind, fasum, X, nil)
if err != nil {
return
}
if ind.Nx == 0 {
return
}
Xa := X.ComplexArray()
v = dzasum(ind.Nx, Xa[ind.OffsetX:], ind.IncX)
return
}
示例14: CopyFloat
// See function Copy.
func CopyFloat(X, Y *matrix.FloatMatrix, 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
}
Xa := X.FloatArray()
Ya := Y.FloatArray()
dcopy(ind.Nx, Xa[ind.OffsetX:], ind.IncX, Ya[ind.OffsetY:], ind.IncY)
return
}
示例15: Hbmv
/*
Matrix-vector product with a real symmetric or complex hermitian band matrix.
Computes with A real symmetric and banded of order n and with bandwidth k.
Y := alpha*A*X + beta*Y
ARGUMENTS
A float or complex n*n matrix
X float or complex n*1 matrix
Y float or complex n*1 matrix
alpha number (float or complex singleton matrix)
beta number (float or complex singleton matrix)
OPTIONS
uplo PLower or PUpper
n integer. If negative, the default value is used.
k integer. If negative, the default value is used.
The default value is k = max(0,A.Rows()-1).
ldA nonnegative integer. ldA >= k+1.
If zero, the default vaule is used.
incx nonzero integer
incy nonzero integer
offsetA nonnegative integer
offsetx nonnegative integer
offsety nonnegative integer
*/
func Hbmv(A, X, Y matrix.Matrix, alpha, beta matrix.Scalar, opts ...linalg.Option) (err error) {
var params *linalg.Parameters
params, err = linalg.GetParameters(opts...)
if err != nil {
return
}
ind := linalg.GetIndexOpts(opts...)
err = check_level2_func(ind, fsbmv, X, Y, A, params)
if err != nil {
return
}
if ind.N == 0 {
return
}
if !matrix.EqualTypes(A, X, Y) {
return onError("Parameters not of same type")
}
switch X.(type) {
case *matrix.FloatMatrix:
Xa := X.(*matrix.FloatMatrix).FloatArray()
Ya := Y.(*matrix.FloatMatrix).FloatArray()
Aa := A.(*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)
dsbmv(uplo, ind.N, ind.K, aval, Aa[ind.OffsetA:], ind.LDa,
Xa[ind.OffsetX:], ind.IncX, bval, Ya[ind.OffsetY:], ind.IncY)
case *matrix.ComplexMatrix:
Xa := X.(*matrix.ComplexMatrix).ComplexArray()
Ya := Y.(*matrix.ComplexMatrix).ComplexArray()
Aa := A.(*matrix.ComplexMatrix).ComplexArray()
aval := alpha.Complex()
bval := beta.Complex()
uplo := linalg.ParamString(params.Uplo)
zhbmv(uplo, ind.N, ind.K, aval, Aa[ind.OffsetA:], ind.LDa,
Xa[ind.OffsetX:], ind.IncX, bval, Ya[ind.OffsetY:], ind.IncY)
//zhbmv(uplo, ind.N, aval, Aa[ind.OffsetA:], ind.LDa,
// Xa[ind.OffsetX:], ind.IncX,
// bval, Ya[ind.OffsetY:], ind.IncY)
default:
return onError("Unknown type, not implemented")
}
return
}