mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
In matlab and octave the expression A' produces the Hermitian conjugate, the complex conjugate of the transpose. Now transpose produces the transpose, while ctranspose produces the conjugate transpose. These are equal for real numbers, while for complex numbers only the conjugate transpose is of much use.
54 lines
1.3 KiB
JavaScript
54 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
|
|
function factory (type, config, load, typed) {
|
|
var transpose = load(require('./transpose'));
|
|
var conj = load(require('../complex/conj'));
|
|
var latex = require('../../utils/latex');
|
|
|
|
/**
|
|
* Transpose and complex conjugate a matrix. All values of the matrix are
|
|
* reflected over its main diagonal and then the complex conjugate is
|
|
* taken. This is equivalent to complex conjugation for scalars and
|
|
* vectors.
|
|
*
|
|
* Syntax:
|
|
*
|
|
* math.ctranspose(x)
|
|
*
|
|
* Examples:
|
|
*
|
|
* var A = [[1, 2, 3], [4, 5, math.complex(6,7)]];
|
|
* math.ctranspose(A); // returns [[1, 4], [2, 5], [3, {re:6,im:7}]]
|
|
*
|
|
* See also:
|
|
*
|
|
* transpose, diag, inv, subset, squeeze
|
|
*
|
|
* @param {Array | Matrix} x Matrix to be ctransposed
|
|
* @return {Array | Matrix} The ctransposed matrix
|
|
*/
|
|
var ctranspose = typed('ctranspose', {
|
|
|
|
'Array': function (x) {
|
|
return conj( transpose( x ) );
|
|
},
|
|
|
|
'Matrix': function (x) {
|
|
return conj( transpose( x ) );
|
|
},
|
|
|
|
// scalars
|
|
'any': function (x) {
|
|
return conj(x);
|
|
}
|
|
});
|
|
|
|
ctranspose.toTex = {1: '\\left(${args[0]}\\right)' + latex.operators['ctranspose']};
|
|
|
|
return ctranspose;
|
|
}
|
|
|
|
exports.name = 'ctranspose';
|
|
exports.factory = factory;
|