diff --git a/mat/matrix.go b/mat/matrix.go index 5ea5d716..ed90c993 100644 --- a/mat/matrix.go +++ b/mat/matrix.go @@ -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 } diff --git a/mat/vector.go b/mat/vector.go index 0f0f3cbf..884e5658 100644 --- a/mat/vector.go +++ b/mat/vector.go @@ -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.