mirror of
https://github.com/gonum/gonum.git
synced 2025-10-28 17:31:56 +08:00
mat: add TransposeVec
This commit is contained in:
@@ -18,13 +18,56 @@ var (
|
|||||||
_ Reseter = vector
|
_ Reseter = vector
|
||||||
)
|
)
|
||||||
|
|
||||||
// Vector is a column vector.
|
// Vector is a vector.
|
||||||
type Vector interface {
|
type Vector interface {
|
||||||
Matrix
|
Matrix
|
||||||
AtVec(int) float64
|
AtVec(int) float64
|
||||||
Len() int
|
Len() int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TransposeVec is a type for performing an implicit transpose of a Vector.
|
||||||
|
// It implements the Vector interface, returning values from the transpose
|
||||||
|
// of the vector within.
|
||||||
|
type TransposeVec struct {
|
||||||
|
Vector Vector
|
||||||
|
}
|
||||||
|
|
||||||
|
// At returns the value of the element at row i and column j of the transposed
|
||||||
|
// matrix, that is, row j and column i of the Vector field.
|
||||||
|
func (t TransposeVec) At(i, j int) float64 {
|
||||||
|
return t.Vector.At(j, i)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dims returns the dimensions of the transposed vector.
|
||||||
|
func (t TransposeVec) Dims() (r, c int) {
|
||||||
|
c, r = t.Vector.Dims()
|
||||||
|
return r, c
|
||||||
|
}
|
||||||
|
|
||||||
|
// T performs an implicit transpose by returning the Vector field.
|
||||||
|
func (t TransposeVec) T() Matrix {
|
||||||
|
return t.Vector
|
||||||
|
}
|
||||||
|
|
||||||
|
// Len returns the number of columns in the vector.
|
||||||
|
func (t TransposeVec) Len() int {
|
||||||
|
return t.Vector.Len()
|
||||||
|
}
|
||||||
|
|
||||||
|
// TVec performs an implicit transpose by returning the Vector field.
|
||||||
|
func (t TransposeVec) TVec() Vector {
|
||||||
|
return t.Vector
|
||||||
|
}
|
||||||
|
|
||||||
|
// Untranspose returns the Vector field.
|
||||||
|
func (t TransposeVec) Untranspose() Matrix {
|
||||||
|
return t.Vector
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t TransposeVec) UntransposeVec() Vector {
|
||||||
|
return t.Vector
|
||||||
|
}
|
||||||
|
|
||||||
// VecDense represents a column vector.
|
// VecDense represents a column vector.
|
||||||
type VecDense struct {
|
type VecDense struct {
|
||||||
mat blas64.Vector
|
mat blas64.Vector
|
||||||
|
|||||||
Reference in New Issue
Block a user