Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

rot180

Return a read-only view of an input ndarray rotated 180 degrees in a specified plane.

Usage

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

rot180( x[, options] )

Returns a read-only view of an input ndarray rotated 180 degrees in a specified plane.

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

var x = array( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] );
// returns <ndarray>[ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]

var y = rot180( x );
// returns <ndarray>[ [ 4.0, 3.0 ], [ 2.0, 1.0 ] ]

The function accepts the following arguments:

  • x: input ndarray.
  • options: function options.

The function accepts the following options:

  • dims: dimension indices defining the plane of rotation. Must contain exactly two unique dimension indices. If a dimension index is provided as an integer less than zero, the dimension index is resolved relative to the last dimension, with the last dimension corresponding to the value -1. Default: [-2, -1].

Notes

  • Each provided dimension index must reside on the interval [-ndims, ndims-1].

Examples

var uniform = require( '@stdlib/random/uniform' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var rot180 = require( '@stdlib/ndarray/rot180' );

var x = uniform( [ 3, 3, 3 ], -10.0, 10.0 );
console.log( ndarray2array( x ) );

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