mirror of
https://github.com/gonum/gonum.git
synced 2025-10-14 03:13:46 +08:00
mat: add VecDense and RawVectorer cases to untransposeExtract (#1186)
* mat: add VecDense.SetRawVector * mat: add VecDense and RawVectorer cases to untransposeExtract * mat: add comments to VecDense.{RawVector,SetRawVector}
This commit is contained in:

committed by
GitHub

parent
7df05ce3f8
commit
af3666d0f9
@@ -244,7 +244,7 @@ func untranspose(a Matrix) (Matrix, bool) {
|
||||
func untransposeExtract(a Matrix) (Matrix, bool) {
|
||||
ut, trans := untranspose(a)
|
||||
switch m := ut.(type) {
|
||||
case *DiagDense, *SymBandDense, *TriBandDense, *BandDense, *TriDense, *SymDense, *Dense:
|
||||
case *DiagDense, *SymBandDense, *TriBandDense, *BandDense, *TriDense, *SymDense, *Dense, *VecDense:
|
||||
return m, trans
|
||||
// TODO(btracey): Add here if we ever have an equivalent of RawDiagDense.
|
||||
case RawSymBander:
|
||||
@@ -287,6 +287,10 @@ func untransposeExtract(a Matrix) (Matrix, bool) {
|
||||
var d Dense
|
||||
d.SetRawMatrix(m.RawMatrix())
|
||||
return &d, trans
|
||||
case RawVectorer:
|
||||
var v VecDense
|
||||
v.SetRawVector(m.RawVector())
|
||||
return &v, trans
|
||||
default:
|
||||
return ut, trans
|
||||
}
|
||||
|
@@ -215,10 +215,20 @@ func VecDenseCopyOf(a Vector) *VecDense {
|
||||
return v
|
||||
}
|
||||
|
||||
// RawVector returns the underlying blas64.Vector used by the receiver.
|
||||
// Changes to elements in the receiver following the call will be reflected
|
||||
// in returned blas64.Vector.
|
||||
func (v *VecDense) RawVector() blas64.Vector {
|
||||
return v.mat
|
||||
}
|
||||
|
||||
// SetRawVector sets the underlying blas64.Vector used by the receiver.
|
||||
// Changes to elements in the receiver following the call will be reflected
|
||||
// in the input.
|
||||
func (v *VecDense) SetRawVector(a blas64.Vector) {
|
||||
v.mat = a
|
||||
}
|
||||
|
||||
// CopyVec makes a copy of elements of a into the receiver. It is similar to the
|
||||
// built-in copy; it copies as much as the overlap between the two vectors and
|
||||
// returns the number of elements it copied.
|
||||
|
Reference in New Issue
Block a user