Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

toTransposed

Return a new ndarray containing the elements of an input ndarray but whose last two dimensions are transposed.

Usage

var toTransposed = require( '@stdlib/ndarray/to-transposed' );

toTransposed( x )

Returns a new ndarray containing the elements of an input ndarray but whose last two dimensions are transposed.

var array = require( '@stdlib/ndarray/array' );

var x = array( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] );
// returns <ndarray>[ [ 1, 2, 3 ], [ 4, 5, 6 ] ]

var y = toTransposed( x );
// returns <ndarray>[ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]

The function accepts the following arguments:

Notes

  • The function operates on a stack of matrices, transposing the last two dimensions of the input ndarray.
  • The input ndarray must have two or more dimensions.

Examples

var array = require( '@stdlib/ndarray/array' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var toTransposed = require( '@stdlib/ndarray/to-transposed' );

var x = array( [ [ [ 1, 2, 3 ], [ 4, 5, 6 ] ], [ [ 7, 8, 9 ], [ 10, 11, 12 ] ] ] );
console.log( ndarray2array( x ) );

var y = toTransposed( x );
console.log( ndarray2array( y ) );