mat: handle vector transposes better

This commit is contained in:
kortschak
2018-01-11 09:31:30 +10:30
committed by Dan Kortschak
parent 69fc04c7c3
commit 6861c60a47

View File

@@ -38,6 +38,11 @@ func (t TransposeVec) At(i, j int) float64 {
return t.Vector.At(j, i)
}
// AtVec returns the element at position i. It panics if i is out of bounds.
func (t TransposeVec) AtVec(i int) float64 {
return t.Vector.AtVec(i)
}
// Dims returns the dimensions of the transposed vector.
func (t TransposeVec) Dims() (r, c int) {
c, r = t.Vector.Dims()
@@ -150,6 +155,11 @@ func (v *VecDense) T() Matrix {
return Transpose{v}
}
// TVec performs an implicit transpose by returning the receiver inside a TransposeVec.
func (v *VecDense) TVec() Vector {
return TransposeVec{v}
}
// Reset zeros the length of the vector so that it can be reused as the
// receiver of a dimensionally restricted operation.
//