matrix-transposer
v0.10.1
Published
Transpose 2D array.
Downloads
1
Readme
matrix-transposer
Abstract
Transpose 2D array.
License
MIT
install
$ npm install --save matrix-transposer
import
Node.js
var MatrixTransposer = require('matrix-transposer').default;
EcmaScript2015
import MatrixTransposer from 'matrix-transposer';
How to use
Example 1
var array = [
[1, 2, 3],
[4, 5, 6]
];
var result = MatrixTransposer.arrayTranspose(array);
// result
// [
// [1, 4],
// [2, 5],
// [3, 6]
// ]
Example 2
var array = [
[1],
[4, 5, 6]
];
// option
var option = {
referenceIndex: 1, // default: 0
defaultValue: 0 // default: null
};
var result = MatrixTransposer.arrayTranspose(array, option);
// result
// [
// [1, 4],
// [0, 5],
// [0, 6]
// ]
var array = [
[1],
[4, 5, 6]
];
// option
var option = {
referenceIndex: 0, // default: 0
defaultValue: 0 // default: null
};
var result = MatrixTransposer.arrayTranspose(array, option);
// result
// [
// [1, 4]
// ]