Generalize transpose to all arrays
This commit is contained in:
parent
ea824a901b
commit
92fc8f00c9
|
@ -484,6 +484,15 @@ stack axis arrs = rewrite sym (lengthCorrect arrs) in
|
|||
getAxisInd FZ (i :: is) = (i, is)
|
||||
getAxisInd {s=_::_} (FS ax) (i :: is) = mapSnd (i::) (getAxisInd ax is)
|
||||
|
||||
export
|
||||
transpose : Array s a -> Array (reverse s) a
|
||||
transpose arr with (viewShape arr)
|
||||
_ | Shape s = fromFunctionNB (reverse s) (\is => arr !# reverse is)
|
||||
|
||||
export
|
||||
(.T) : Array s a -> Array (reverse s) a
|
||||
(.T) = transpose
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Implementations
|
||||
|
|
|
@ -141,16 +141,6 @@ hstack : {m : _} -> Vect n (Vector m a) -> Matrix m n a
|
|||
hstack = stack 1
|
||||
|
||||
|
||||
export
|
||||
transpose : Matrix m n a -> Matrix n m a
|
||||
transpose mat with (viewShape mat)
|
||||
_ | Shape [m,n] = fromFunctionNB [n,m] (\[i,j] => mat!#[j,i])
|
||||
|
||||
export
|
||||
(.T) : Matrix m n a -> Matrix n m a
|
||||
(.T) = transpose
|
||||
|
||||
|
||||
||| Calculate the outer product of two vectors as a matrix.
|
||||
export
|
||||
outer : Num a => Vector m a -> Vector n a -> Matrix m n a
|
||||
|
|
Loading…
Reference in a new issue