Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

toRot180

Return a new ndarray where an input ndarray is rotated 180 degrees in a specified plane.

Usage

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

toRot180( x[, options] )

Returns a new ndarray where an input ndarray is 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 = toRot180( 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 toRot180 = require( '@stdlib/ndarray/to-rot180' );

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

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