本文整理匯總了Golang中github.com/hrautila/cmat.FloatMatrix.IsVector方法的典型用法代碼示例。如果您正苦於以下問題:Golang FloatMatrix.IsVector方法的具體用法?Golang FloatMatrix.IsVector怎麽用?Golang FloatMatrix.IsVector使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/hrautila/cmat.FloatMatrix
的用法示例。
在下文中一共展示了FloatMatrix.IsVector方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: SolveDiag
/*
* Compute
* B = B*diag(D).-1 flags & RIGHT == true
* B = diag(D).-1*B flags & LEFT == true
*
* If flags is LEFT (RIGHT) then element-wise divides columns (rows) of B with vector D.
*
* Arguments:
* B M-by-N matrix if flags&RIGHT == true or N-by-M matrix if flags&LEFT == true
*
* D N element column or row vector or N-by-N matrix
*
* flags Indicator bits, LEFT or RIGHT
*/
func SolveDiag(B, D *cmat.FloatMatrix, flags int, confs ...*gomas.Config) *gomas.Error {
var c, d0 cmat.FloatMatrix
var d *cmat.FloatMatrix
conf := gomas.CurrentConf(confs...)
d = D
if !D.IsVector() {
d0.Diag(D)
d = &d0
}
dn := d0.Len()
br, bc := B.Size()
switch flags & (gomas.LEFT | gomas.RIGHT) {
case gomas.LEFT:
if br != dn {
return gomas.NewError(gomas.ESIZE, "SolveDiag")
}
// scale rows;
for k := 0; k < dn; k++ {
c.Row(B, k)
blasd.InvScale(&c, d.GetAt(k), conf)
}
case gomas.RIGHT:
if bc != dn {
return gomas.NewError(gomas.ESIZE, "SolveDiag")
}
// scale columns
for k := 0; k < dn; k++ {
c.Column(B, k)
blasd.InvScale(&c, d.GetAt(k), conf)
}
}
return nil
}
示例2: NormP
/*
* Compute matrix and vector norms.
*
* Arguments
* X A real valued matrix or vector
*
* norm Norm to compute
* NORM_ONE, NORM_TWO, NORM_INF
*
* Note: matrix NORM_TWO not yet implemented.
*/
func NormP(X *cmat.FloatMatrix, norm Norms) float64 {
if X.IsVector() {
switch norm {
case NORM_ONE:
return blasd.ASum(X)
case NORM_TWO:
return blasd.Nrm2(X)
case NORM_INF:
return blasd.Amax(X)
}
return 0.0
}
switch norm {
case NORM_ONE:
return mNorm1(X)
case NORM_TWO:
return 0.0
case NORM_INF:
return mNormInf(X)
}
return 0.0
}
示例3: MVUpdateDiag
/*
* Generic rank update of diagonal matrix.
* diag(D) = diag(D) + alpha * x * y.T
*
* Arguments:
* D N element column or row vector or N-by-N matrix
*
* x, y N element vectors
*
* alpha scalar
*/
func MVUpdateDiag(D, x, y *cmat.FloatMatrix, alpha float64, confs ...*gomas.Config) *gomas.Error {
var d *cmat.FloatMatrix
var d0 cmat.FloatMatrix
if !x.IsVector() || !y.IsVector() {
return gomas.NewError(gomas.ENEED_VECTOR, "MvUpdateDiag")
}
d = D
if !D.IsVector() {
d0.Diag(D)
d = &d0
}
for k := 0; k < d.Len(); k++ {
val := d.GetAt(k)
val += x.GetAt(k) * y.GetAt(k) * alpha
d.SetAt(k, val)
}
return nil
}