/**
* Determines whether a square Matrix is skew symmetric or not.<br><br>
*
* Skew symmetric Matrix is a square Matrix whose transpose equals its negative.<br><br>
*
* The result is cached.
* @memberof Matrix
* @instance
* @param {number} [digit=8] - Number of significant digits
* @returns {boolean} Returns true if the square Matrix is skew symmetric
*/
function isSkewSymmetric(digit = this._digit) {
if (this._isSkewSymmetric !== undefined) {
return this._isSkewSymmetric;
}
if (!this.isSquare()) {
this._isSkewSymmetric = false;
return false;
}
const A = this._matrix;
const EPSILON = 1 / ((10 ** digit) * 2);
const size = A.length;
if (size === 0) {
this._isSkewSymmetric = true;
return true; // []
}
for (let i = 0; i < size; i++) {
for (let j = 0; j < i; j++) {
if (Math.abs(A[i][j] + A[j][i]) >= EPSILON) {
this._isSkewSymmetric = false;
return false;
}
}
}
this._isSkewSymmetric = true;
return true;
};
module.exports = isSkewSymmetric;