mathjs 10.4.0 → 10.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.eigs = exports.efimovFactor = exports.e = exports.dotPow = exports.dotMultiply = exports.dotDivide = exports.dot = exports.divideScalar = exports.divide = exports.distance = exports.diff = exports.diag = exports.deuteronMass = exports.det = exports.deepEqual = exports.cumsum = exports.cube = exports.ctranspose = exports.csch = exports.csc = exports.cross = exports.createUnit = exports.count = exports.coulomb = exports.coth = exports.cot = exports.cosh = exports.cos = exports.conj = exports.conductanceQuantum = exports.concat = exports.composition = exports.complex = exports.compareText = exports.compareNatural = exports.compare = exports.combinationsWithRep = exports.combinations = exports.column = exports.clone = exports.classicalElectronRadius = exports.ceil = exports.cbrt = exports.catalan = exports.boolean = exports.boltzmann = exports.bohrRadius = exports.bohrMagneton = exports.bitXor = exports.bitOr = exports.bitNot = exports.bitAnd = exports.bin = exports.bignumber = exports.bellNumbers = exports.avogadro = exports.atomicMass = exports.atanh = exports.atan2 = exports.atan = exports.asinh = exports.asin = exports.asech = exports.asec = exports.arg = exports.apply = exports.and = exports.addScalar = exports.add = exports.acsch = exports.acsc = exports.acoth = exports.acot = exports.acosh = exports.acos = exports.abs = exports._true = exports._null = exports._false = exports._NaN = exports._Infinity = exports.Unit = exports.SparseMatrix = exports.Spa = exports.SQRT2 = exports.SQRT1_2 = exports.ResultSet = exports.Range = exports.Matrix = exports.LOG2E = exports.LOG10E = exports.LN2 = exports.LN10 = exports.Index = exports.ImmutableDenseMatrix = exports.Fraction = exports.FibonacciHeap = exports.DenseMatrix = exports.Complex = exports.BigNumber = void 0;
7
- exports.pickRandom = exports.pi = exports.phi = exports.permutations = exports.partitionSelect = exports.or = exports.ones = exports.oct = exports.numeric = exports.number = exports.nuclearMagneton = exports.nthRoots = exports.nthRoot = exports.not = exports.norm = exports.neutronMass = exports.multiplyScalar = exports.multiply = exports.multinomial = exports.molarVolume = exports.molarPlanckConstant = exports.molarMassC12 = exports.molarMass = exports.mode = exports.mod = exports.min = exports.median = exports.mean = exports.max = exports.matrixFromRows = exports.matrixFromFunction = exports.matrixFromColumns = exports.matrix = exports.map = exports.magneticFluxQuantum = exports.magneticConstant = exports.mad = exports.lusolve = exports.lup = exports.lsolveAll = exports.lsolve = exports.loschmidt = exports.log2 = exports.log1p = exports.log10 = exports.log = exports.leftShift = exports.lcm = exports.largerEq = exports.larger = exports.kron = exports.klitzing = exports.kldivergence = exports.isZero = exports.isPrime = exports.isPositive = exports.isNumeric = exports.isNegative = exports.isNaN = exports.isInteger = exports.invmod = exports.inverseConductanceQuantum = exports.inv = exports.intersect = exports.index = exports.im = exports.identity = exports.i = exports.hypot = exports.hex = exports.hasNumericValue = exports.hartreeEnergy = exports.gravity = exports.gravitationConstant = exports.getMatrixDataType = exports.gcd = exports.gasConstant = exports.gamma = exports.fraction = exports.format = exports.forEach = exports.floor = exports.flatten = exports.fix = exports.firstRadiation = exports.fineStructure = exports.filter = exports.fermiCoupling = exports.faraday = exports.factorial = exports.expm1 = exports.expm = exports.exp = exports.erf = exports.equalText = exports.equalScalar = exports.equal = exports.elementaryCharge = exports.electronMass = exports.electricConstant = exports.eigs = exports.efimovFactor = exports.e = exports.dotPow = exports.dotMultiply = exports.dotDivide = exports.dot = exports.divideScalar = exports.divide = exports.distance = exports.diff = exports.diag = exports.deuteronMass = exports.det = exports.deepEqual = exports.cumsum = exports.cube = exports.ctranspose = exports.csch = exports.csc = exports.cross = exports.createUnit = exports.count = exports.coulomb = exports.coth = exports.cot = exports.cosh = exports.cos = exports.conj = exports.conductanceQuantum = exports.concat = exports.composition = exports.complex = exports.compareText = exports.compareNatural = exports.compare = exports.combinationsWithRep = exports.combinations = exports.column = exports.clone = exports.classicalElectronRadius = exports.ceil = exports.cbrt = exports.catalan = exports.boolean = exports.boltzmann = exports.bohrRadius = exports.bohrMagneton = exports.bitXor = exports.bitOr = exports.bitNot = exports.bitAnd = exports.bin = exports.bignumber = exports.bellNumbers = exports.avogadro = exports.atomicMass = exports.atanh = exports.atan2 = exports.atan = exports.asinh = exports.asin = exports.asech = exports.asec = exports.arg = exports.apply = exports.and = exports.addScalar = exports.add = exports.acsch = exports.acsc = exports.acoth = exports.acot = exports.acosh = exports.acos = exports.abs = exports._true = exports._null = exports._false = exports._NaN = exports._Infinity = exports.Unit = exports.SparseMatrix = exports.Spa = exports.SQRT2 = exports.SQRT1_2 = exports.ResultSet = exports.Range = exports.Matrix = exports.LOG2E = exports.LOG10E = exports.LN2 = exports.LN10 = exports.Index = exports.ImmutableDenseMatrix = exports.Fraction = exports.FibonacciHeap = exports.DenseMatrix = exports.Complex = exports.BigNumber = void 0;
8
- exports.zeros = exports.xor = exports.xgcd = exports.wienDisplacement = exports.weakMixingAngle = exports.version = exports.variance = exports.vacuumImpedance = exports.usolveAll = exports.usolve = exports.unit = exports.unequal = exports.unaryPlus = exports.unaryMinus = exports.typed = exports.typeOf = exports.transpose = exports.trace = exports.to = exports.thomsonCrossSection = exports.tau = exports.tanh = exports.tan = exports.sum = exports.subtract = exports.subset = exports.string = exports.stirlingS2 = exports.stefanBoltzmann = exports.std = exports.squeeze = exports.square = exports.sqrtm = exports.sqrt = exports.splitUnit = exports.speedOfLight = exports.sparse = exports.sort = exports.smallerEq = exports.smaller = exports.slu = exports.size = exports.sinh = exports.sin = exports.sign = exports.setUnion = exports.setSymDifference = exports.setSize = exports.setPowerset = exports.setMultiplicity = exports.setIsSubset = exports.setIntersect = exports.setDistinct = exports.setDifference = exports.setCartesian = exports.secondRadiation = exports.sech = exports.sec = exports.sackurTetrode = exports.rydberg = exports.row = exports.round = exports.rotationMatrix = exports.rotate = exports.rightLogShift = exports.rightArithShift = exports.resize = exports.reshape = exports.replacer = exports.reducedPlanckConstant = exports.re = exports.range = exports.randomInt = exports.random = exports.quantumOfCirculation = exports.quantileSeq = exports.qr = exports.protonMass = exports.prod = exports.print = exports.pow = exports.planckTime = exports.planckTemperature = exports.planckMass = exports.planckLength = exports.planckConstant = exports.planckCharge = exports.pickRandom = exports.pi = exports.phi = exports.permutations = exports.partitionSelect = exports.or = exports.ones = exports.oct = exports.numeric = exports.number = exports.nuclearMagneton = exports.nthRoots = exports.nthRoot = exports.not = exports.norm = exports.neutronMass = exports.multiplyScalar = exports.multiply = exports.multinomial = exports.molarVolume = exports.molarPlanckConstant = exports.molarMassC12 = exports.molarMass = exports.mode = exports.mod = exports.min = exports.median = exports.mean = exports.max = exports.matrixFromRows = exports.matrixFromFunction = exports.matrixFromColumns = exports.matrix = exports.map = exports.magneticFluxQuantum = exports.magneticConstant = exports.mad = exports.lusolve = exports.lup = exports.lsolveAll = exports.lsolve = exports.loschmidt = exports.log2 = exports.log1p = exports.log10 = exports.log = exports.leftShift = exports.lcm = exports.largerEq = exports.larger = exports.kron = exports.klitzing = exports.kldivergence = exports.isZero = exports.isPrime = exports.isPositive = exports.isNumeric = exports.isNegative = exports.isNaN = exports.isInteger = exports.invmod = exports.inverseConductanceQuantum = exports.inv = exports.intersect = exports.index = exports.im = exports.identity = exports.i = exports.hypot = exports.hex = exports.hasNumericValue = exports.hartreeEnergy = exports.gravity = exports.gravitationConstant = exports.getMatrixDataType = exports.gcd = exports.gasConstant = exports.gamma = exports.fraction = exports.format = exports.forEach = exports.floor = exports.flatten = exports.fix = exports.firstRadiation = exports.fineStructure = exports.filter = exports.fermiCoupling = exports.faraday = exports.factorial = exports.expm1 = exports.expm = exports.exp = exports.erf = exports.equalText = exports.equalScalar = exports.equal = exports.elementaryCharge = exports.electronMass = exports.electricConstant = exports.eigs = exports.efimovFactor = exports.e = exports.dotPow = exports.dotMultiply = exports.dotDivide = exports.dot = exports.divideScalar = exports.divide = exports.distance = exports.diff = exports.diag = exports.deuteronMass = exports.det = exports.deepEqual = exports.cumsum = exports.cube = exports.ctranspose = exports.csch = exports.csc = exports.cross = exports.createUnit = exports.count = exports.coulomb = exports.coth = exports.cot = exports.cosh = exports.cos = exports.conj = exports.conductanceQuantum = exports.concat = exports.composition = exports.complex = exports.compareText = exports.compareNatural = exports.compare = exports.combinationsWithRep = exports.combinations = exports.column = exports.clone = exports.classicalElectronRadius = exports.ceil = exports.cbrt = exports.catalan = exports.boolean = exports.boltzmann = exports.bohrRadius = exports.bohrMagneton = exports.bitXor = exports.bitOr = exports.bitNot = exports.bitAnd = exports.bin = exports.bignumber = exports.bellNumbers = exports.avogadro = exports.atomicMass = exports.atanh = exports.atan2 = exports.atan = exports.asinh = exports.asin = exports.asech = exports.asec = exports.arg = exports.apply = exports.and = exports.addScalar = exports.add = exports.acsch = exports.acsc = exports.acoth = exports.acot = exports.acosh = exports.acos = exports.abs = exports._true = exports._null = exports._false = exports._NaN = exports._Infinity = exports.Unit = exports.SparseMatrix = exports.Spa = exports.SQRT2 = exports.SQRT1_2 = exports.ResultSet = exports.Range = exports.Matrix = exports.LOG2E = exports.LOG10E = exports.LN2 = exports.LN10 = exports.Index = exports.ImmutableDenseMatrix = exports.Fraction = exports.FibonacciHeap = exports.DenseMatrix = exports.Complex = exports.BigNumber = void 0;
7
+ exports.pickRandom = exports.pi = exports.phi = exports.permutations = exports.partitionSelect = exports.or = exports.ones = exports.oct = exports.numeric = exports.number = exports.nuclearMagneton = exports.nthRoots = exports.nthRoot = exports.not = exports.norm = exports.neutronMass = exports.multiplyScalar = exports.multiply = exports.multinomial = exports.molarVolume = exports.molarPlanckConstant = exports.molarMassC12 = exports.molarMass = exports.mode = exports.mod = exports.min = exports.median = exports.mean = exports.max = exports.matrixFromRows = exports.matrixFromFunction = exports.matrixFromColumns = exports.matrix = exports.map = exports.magneticFluxQuantum = exports.magneticConstant = exports.mad = exports.lusolve = exports.lup = exports.lsolveAll = exports.lsolve = exports.loschmidt = exports.log2 = exports.log1p = exports.log10 = exports.log = exports.leftShift = exports.lcm = exports.largerEq = exports.larger = exports.kron = exports.klitzing = exports.kldivergence = exports.isZero = exports.isPrime = exports.isPositive = exports.isNumeric = exports.isNegative = exports.isNaN = exports.isInteger = exports.invmod = exports.inverseConductanceQuantum = exports.inv = exports.intersect = exports.index = exports.im = exports.identity = exports.i = exports.hypot = exports.hex = exports.hasNumericValue = exports.hartreeEnergy = exports.gravity = exports.gravitationConstant = exports.getMatrixDataType = exports.gcd = exports.gasConstant = exports.gamma = exports.fraction = exports.format = exports.forEach = exports.floor = exports.flatten = exports.fix = exports.firstRadiation = exports.fineStructure = exports.filter = exports.fermiCoupling = exports.faraday = exports.factorial = exports.expm1 = exports.expm = exports.exp = exports.erf = exports.equalText = exports.equalScalar = exports.equal = exports.elementaryCharge = exports.electronMass = exports.electricConstant = void 0;
8
+ exports.zeros = exports.xor = exports.xgcd = exports.wienDisplacement = exports.weakMixingAngle = exports.version = exports.variance = exports.vacuumImpedance = exports.usolveAll = exports.usolve = exports.unit = exports.unequal = exports.unaryPlus = exports.unaryMinus = exports.typed = exports.typeOf = exports.transpose = exports.trace = exports.to = exports.thomsonCrossSection = exports.tau = exports.tanh = exports.tan = exports.sum = exports.subtract = exports.subset = exports.string = exports.stirlingS2 = exports.stefanBoltzmann = exports.std = exports.squeeze = exports.square = exports.sqrtm = exports.sqrt = exports.splitUnit = exports.speedOfLight = exports.sparse = exports.sort = exports.smallerEq = exports.smaller = exports.slu = exports.size = exports.sinh = exports.sin = exports.sign = exports.setUnion = exports.setSymDifference = exports.setSize = exports.setPowerset = exports.setMultiplicity = exports.setIsSubset = exports.setIntersect = exports.setDistinct = exports.setDifference = exports.setCartesian = exports.secondRadiation = exports.sech = exports.sec = exports.sackurTetrode = exports.rydberg = exports.row = exports.round = exports.rotationMatrix = exports.rotate = exports.rightLogShift = exports.rightArithShift = exports.resize = exports.reshape = exports.replacer = exports.reducedPlanckConstant = exports.re = exports.range = exports.randomInt = exports.random = exports.quantumOfCirculation = exports.quantileSeq = exports.qr = exports.protonMass = exports.prod = exports.print = exports.pow = exports.planckTime = exports.planckTemperature = exports.planckMass = exports.planckLength = exports.planckConstant = exports.planckCharge = void 0;
9
9
 
10
10
  var _configReadonly = require("./configReadonly.js");
11
11
 
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.mode = exports.mod = exports.min = exports.median = exports.mean = exports.max = exports.matrix = exports.map = exports.mad = exports.log2 = exports.log1p = exports.log10 = exports.log = exports.leftShift = exports.lcm = exports.largerEq = exports.larger = exports.isZero = exports.isPrime = exports.isPositive = exports.isNumeric = exports.isNegative = exports.isNaN = exports.isInteger = exports.index = exports.hypot = exports.hasNumericValue = exports.gcd = exports.gamma = exports.format = exports.forEach = exports.floor = exports.fix = exports.filter = exports.factorial = exports.expm1 = exports.exp = exports.erf = exports.equalText = exports.equalScalar = exports.equal = exports.e = exports.divideScalar = exports.divide = exports.deepEqual = exports.cumsum = exports.cube = exports.csch = exports.csc = exports.coth = exports.cot = exports.cosh = exports.cos = exports.composition = exports.compareText = exports.compareNatural = exports.compare = exports.combinationsWithRep = exports.combinations = exports.clone = exports.ceil = exports.cbrt = exports.catalan = exports.boolean = exports.bitXor = exports.bitOr = exports.bitNot = exports.bitAnd = exports.bellNumbers = exports.atanh = exports.atan2 = exports.atan = exports.asinh = exports.asin = exports.asech = exports.asec = exports.apply = exports.and = exports.addScalar = exports.add = exports.acsch = exports.acsc = exports.acoth = exports.acot = exports.acosh = exports.acos = exports.abs = exports._true = exports._null = exports._false = exports._NaN = exports._Infinity = exports.SQRT2 = exports.SQRT1_2 = exports.ResultSet = exports.Range = exports.LOG2E = exports.LOG10E = exports.LN2 = exports.LN10 = void 0;
7
- exports.xor = exports.xgcd = exports.version = exports.variance = exports.unequal = exports.unaryPlus = exports.unaryMinus = exports.typed = exports.typeOf = exports.tau = exports.tanh = exports.tan = exports.sum = exports.subtract = exports.subset = exports.string = exports.stirlingS2 = exports.std = exports.square = exports.sqrt = exports.smallerEq = exports.smaller = exports.size = exports.sinh = exports.sin = exports.sign = exports.sech = exports.sec = exports.round = exports.rightLogShift = exports.rightArithShift = exports.replacer = exports.range = exports.randomInt = exports.random = exports.quantileSeq = exports.prod = exports.print = exports.pow = exports.pickRandom = exports.pi = exports.phi = exports.permutations = exports.partitionSelect = exports.or = exports.numeric = exports.number = exports.nthRoot = exports.not = exports.norm = exports.multiplyScalar = exports.multiply = exports.multinomial = exports.mode = exports.mod = exports.min = exports.median = exports.mean = exports.max = exports.matrix = exports.map = exports.mad = exports.log2 = exports.log1p = exports.log10 = exports.log = exports.leftShift = exports.lcm = exports.largerEq = exports.larger = exports.isZero = exports.isPrime = exports.isPositive = exports.isNumeric = exports.isNegative = exports.isNaN = exports.isInteger = exports.index = exports.hypot = exports.hasNumericValue = exports.gcd = exports.gamma = exports.format = exports.forEach = exports.floor = exports.fix = exports.filter = exports.factorial = exports.expm1 = exports.exp = exports.erf = exports.equalText = exports.equalScalar = exports.equal = exports.e = exports.divideScalar = exports.divide = exports.deepEqual = exports.cumsum = exports.cube = exports.csch = exports.csc = exports.coth = exports.cot = exports.cosh = exports.cos = exports.composition = exports.compareText = exports.compareNatural = exports.compare = exports.combinationsWithRep = exports.combinations = exports.clone = exports.ceil = exports.cbrt = exports.catalan = exports.boolean = exports.bitXor = exports.bitOr = exports.bitNot = exports.bitAnd = exports.bellNumbers = exports.atanh = exports.atan2 = exports.atan = exports.asinh = exports.asin = exports.asech = exports.asec = exports.apply = exports.and = exports.addScalar = exports.add = exports.acsch = exports.acsc = exports.acoth = exports.acot = exports.acosh = exports.acos = exports.abs = exports._true = exports._null = exports._false = exports._NaN = exports._Infinity = exports.SQRT2 = exports.SQRT1_2 = exports.ResultSet = exports.Range = exports.LOG2E = exports.LOG10E = exports.LN2 = exports.LN10 = void 0;
7
+ exports.xor = exports.xgcd = exports.version = exports.variance = exports.unequal = exports.unaryPlus = exports.unaryMinus = exports.typed = exports.typeOf = exports.tau = exports.tanh = exports.tan = exports.sum = exports.subtract = exports.subset = exports.string = exports.stirlingS2 = exports.std = exports.square = exports.sqrt = exports.smallerEq = exports.smaller = exports.size = exports.sinh = exports.sin = exports.sign = exports.sech = exports.sec = exports.round = exports.rightLogShift = exports.rightArithShift = exports.replacer = exports.range = exports.randomInt = exports.random = exports.quantileSeq = exports.prod = exports.print = exports.pow = exports.pickRandom = exports.pi = exports.phi = exports.permutations = exports.partitionSelect = exports.or = exports.numeric = exports.number = exports.nthRoot = exports.not = exports.norm = exports.multiplyScalar = exports.multiply = exports.multinomial = void 0;
8
8
 
9
9
  var _configReadonly = require("./configReadonly.js");
10
10
 
@@ -253,18 +253,22 @@ var createParse = /* #__PURE__ */(0, _factory.factory)(name, dependencies, funct
253
253
  function getToken(state) {
254
254
  state.tokenType = TOKENTYPE.NULL;
255
255
  state.token = '';
256
- state.comment = ''; // skip over whitespaces
257
- // space, tab, and newline when inside parameters
256
+ state.comment = ''; // skip over ignored characters:
258
257
 
259
- while (parse.isWhitespace(currentCharacter(state), state.nestingLevel)) {
260
- next(state);
261
- } // skip comment
258
+ while (true) {
259
+ // comments:
260
+ if (currentCharacter(state) === '#') {
261
+ while (currentCharacter(state) !== '\n' && currentCharacter(state) !== '') {
262
+ state.comment += currentCharacter(state);
263
+ next(state);
264
+ }
265
+ } // whitespace: space, tab, and newline when inside parameters
262
266
 
263
267
 
264
- if (currentCharacter(state) === '#') {
265
- while (currentCharacter(state) !== '\n' && currentCharacter(state) !== '') {
266
- state.comment += currentCharacter(state);
268
+ if (parse.isWhitespace(currentCharacter(state), state.nestingLevel)) {
267
269
  next(state);
270
+ } else {
271
+ break;
268
272
  }
269
273
  } // check for end of expression
270
274
 
@@ -338,7 +338,7 @@ Object.defineProperty(exports, "createLargerEq", {
338
338
  }
339
339
  });
340
340
  exports.createLeftShift = exports.createLcm = void 0;
341
- exports.createLog2 = exports.createLog1p = exports.createLog10 = exports.createLog = exports.createLeftShift = exports.createLcm = void 0;
341
+ exports.createLog2 = exports.createLog1p = exports.createLog10 = exports.createLog = void 0;
342
342
  Object.defineProperty(exports, "createMad", {
343
343
  enumerable: true,
344
344
  get: function get() {
@@ -54,32 +54,36 @@ function createComplexEigs(_ref) {
54
54
  } // TODO check if any row/col are zero except the diagonal
55
55
  // make sure corresponding rows and columns have similar magnitude
56
56
  // important because of numerical stability
57
+ // MODIFIES arr by side effect!
57
58
 
58
59
 
59
60
  var R = balance(arr, N, prec, type, findVectors); // R is the row transformation matrix
60
- // A' = R A R⁻¹, A is the original matrix
61
+ // arr = A' = R A R⁻¹, A is the original matrix
61
62
  // (if findVectors is false, R is undefined)
63
+ // (And so to return to original matrix: A = R⁻¹ arr R)
62
64
  // TODO if magnitudes of elements vary over many orders,
63
65
  // move greatest elements to the top left corner
64
66
  // using similarity transformations, reduce the matrix
65
67
  // to Hessenberg form (upper triangular plus one subdiagonal row)
66
68
  // updates the transformation matrix R with new row operationsq
69
+ // MODIFIES arr by side effect!
67
70
 
68
- reduceToHessenberg(arr, N, prec, type, findVectors, R); // find eigenvalues
71
+ reduceToHessenberg(arr, N, prec, type, findVectors, R); // still true that original A = R⁻¹ arr R)
72
+ // find eigenvalues
69
73
 
70
74
  var _iterateUntilTriangul = iterateUntilTriangular(arr, N, prec, type, findVectors),
71
75
  values = _iterateUntilTriangul.values,
72
76
  C = _iterateUntilTriangul.C; // values is the list of eigenvalues, C is the column
73
- // transformation matrix that transforms the hessenberg
74
- // matrix to upper triangular
75
- // compose transformations A hess. and hess. triang.
77
+ // transformation matrix that transforms arr, the hessenberg
78
+ // matrix, to upper triangular
79
+ // (So U = C⁻¹ arr C and the relationship between current arr
80
+ // and original A is unchanged.)
76
81
 
77
82
 
78
- C = multiply(inv(R), C);
79
83
  var vectors;
80
84
 
81
85
  if (findVectors) {
82
- vectors = findEigenvectors(arr, N, C, values, prec, type);
86
+ vectors = findEigenvectors(arr, N, C, R, values, prec, type);
83
87
  vectors = matrixFromColumns.apply(void 0, (0, _toConsumableArray2.default)(vectors));
84
88
  }
85
89
 
@@ -412,16 +416,17 @@ function createComplexEigs(_ref) {
412
416
  };
413
417
  }
414
418
  /**
415
- * @param {Matrix} A original matrix
419
+ * @param {Matrix} A hessenberg-form matrix
416
420
  * @param {number} N size of A
417
421
  * @param {Matrix} C column transformation matrix that turns A into upper triangular
422
+ * @param {Matrix} R similarity that turns original matrix into A
418
423
  * @param {number[]} values array of eigenvalues of A
419
424
  * @param {'number'|'BigNumber'|'Complex'} type
420
425
  * @returns {number[][]} eigenvalues
421
426
  */
422
427
 
423
428
 
424
- function findEigenvectors(A, N, C, values, prec, type) {
429
+ function findEigenvectors(A, N, C, R, values, prec, type) {
425
430
  var Cinv = inv(C);
426
431
  var U = multiply(Cinv, A, C);
427
432
  var big = type === 'BigNumber';
@@ -438,12 +443,12 @@ function createComplexEigs(_ref) {
438
443
 
439
444
  try {
440
445
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
441
- var _λ = _step.value;
446
+ var λ = _step.value;
442
447
 
443
- var _i4 = indexOf(uniqueValues, _λ, equal);
448
+ var _i4 = indexOf(uniqueValues, λ, equal);
444
449
 
445
450
  if (_i4 === -1) {
446
- uniqueValues.push(_λ);
451
+ uniqueValues.push(λ);
447
452
  multiplicities.push(1);
448
453
  } else {
449
454
  multiplicities[_i4] += 1;
@@ -465,21 +470,16 @@ function createComplexEigs(_ref) {
465
470
 
466
471
  var failedLambdas = [];
467
472
 
468
- for (var i = 0; i < len; i++) {
473
+ var _loop = function _loop(i) {
469
474
  var λ = uniqueValues[i];
475
+ var S = subtract(U, multiply(λ, E)); // the characteristic matrix
470
476
 
471
- var _A = subtract(U, multiply(λ, E)); // the characteristic matrix
472
-
473
-
474
- var solutions = usolveAll(_A, b);
475
- solutions = solutions.map(function (v) {
476
- return multiply(C, v);
477
- });
477
+ var solutions = usolveAll(S, b);
478
478
  solutions.shift(); // ignore the null vector
479
479
  // looks like we missed something, try inverse iteration
480
480
 
481
481
  while (solutions.length < multiplicities[i]) {
482
- var approxVec = inverseIterate(_A, N, solutions, prec, type);
482
+ var approxVec = inverseIterate(S, N, solutions, prec, type);
483
483
 
484
484
  if (approxVec == null) {
485
485
  // no more vectors were found
@@ -488,11 +488,20 @@ function createComplexEigs(_ref) {
488
488
  }
489
489
 
490
490
  solutions.push(approxVec);
491
- }
491
+ } // Transform back into original array coordinates
492
492
 
493
+
494
+ var correction = multiply(inv(R), C);
495
+ solutions = solutions.map(function (v) {
496
+ return multiply(correction, v);
497
+ });
493
498
  vectors.push.apply(vectors, (0, _toConsumableArray2.default)(solutions.map(function (v) {
494
499
  return flatten(v);
495
500
  })));
501
+ };
502
+
503
+ for (var i = 0; i < len; i++) {
504
+ _loop(i);
496
505
  }
497
506
 
498
507
  if (failedLambdas.length !== 0) {
package/lib/cjs/header.js CHANGED
@@ -6,8 +6,8 @@
6
6
  * It features real and complex numbers, units, matrices, a large set of
7
7
  * mathematical functions, and a flexible expression parser.
8
8
  *
9
- * @version 10.4.0
10
- * @date 2022-03-07
9
+ * @version 10.4.1
10
+ * @date 2022-03-23
11
11
  *
12
12
  * @license
13
13
  * Copyright (C) 2013-2022 Jos de Jong <wjosdejong@gmail.com>
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.version = void 0;
7
- var version = '10.4.0'; // Note: This file is automatically generated when building math.js.
7
+ var version = '10.4.1'; // Note: This file is automatically generated when building math.js.
8
8
  // Changes made in this file will be overwritten.
9
9
 
10
10
  exports.version = version;
@@ -241,18 +241,22 @@ export var createParse = /* #__PURE__ */factory(name, dependencies, _ref => {
241
241
  function getToken(state) {
242
242
  state.tokenType = TOKENTYPE.NULL;
243
243
  state.token = '';
244
- state.comment = ''; // skip over whitespaces
245
- // space, tab, and newline when inside parameters
244
+ state.comment = ''; // skip over ignored characters:
246
245
 
247
- while (parse.isWhitespace(currentCharacter(state), state.nestingLevel)) {
248
- next(state);
249
- } // skip comment
246
+ while (true) {
247
+ // comments:
248
+ if (currentCharacter(state) === '#') {
249
+ while (currentCharacter(state) !== '\n' && currentCharacter(state) !== '') {
250
+ state.comment += currentCharacter(state);
251
+ next(state);
252
+ }
253
+ } // whitespace: space, tab, and newline when inside parameters
250
254
 
251
255
 
252
- if (currentCharacter(state) === '#') {
253
- while (currentCharacter(state) !== '\n' && currentCharacter(state) !== '') {
254
- state.comment += currentCharacter(state);
256
+ if (parse.isWhitespace(currentCharacter(state), state.nestingLevel)) {
255
257
  next(state);
258
+ } else {
259
+ break;
256
260
  }
257
261
  } // check for end of expression
258
262
 
@@ -38,32 +38,36 @@ export function createComplexEigs(_ref) {
38
38
  } // TODO check if any row/col are zero except the diagonal
39
39
  // make sure corresponding rows and columns have similar magnitude
40
40
  // important because of numerical stability
41
+ // MODIFIES arr by side effect!
41
42
 
42
43
 
43
44
  var R = balance(arr, N, prec, type, findVectors); // R is the row transformation matrix
44
- // A' = R A R⁻¹, A is the original matrix
45
+ // arr = A' = R A R⁻¹, A is the original matrix
45
46
  // (if findVectors is false, R is undefined)
47
+ // (And so to return to original matrix: A = R⁻¹ arr R)
46
48
  // TODO if magnitudes of elements vary over many orders,
47
49
  // move greatest elements to the top left corner
48
50
  // using similarity transformations, reduce the matrix
49
51
  // to Hessenberg form (upper triangular plus one subdiagonal row)
50
52
  // updates the transformation matrix R with new row operationsq
53
+ // MODIFIES arr by side effect!
51
54
 
52
- reduceToHessenberg(arr, N, prec, type, findVectors, R); // find eigenvalues
55
+ reduceToHessenberg(arr, N, prec, type, findVectors, R); // still true that original A = R⁻¹ arr R)
56
+ // find eigenvalues
53
57
 
54
58
  var {
55
59
  values,
56
60
  C
57
61
  } = iterateUntilTriangular(arr, N, prec, type, findVectors); // values is the list of eigenvalues, C is the column
58
- // transformation matrix that transforms the hessenberg
59
- // matrix to upper triangular
60
- // compose transformations A hess. and hess. triang.
62
+ // transformation matrix that transforms arr, the hessenberg
63
+ // matrix, to upper triangular
64
+ // (So U = C⁻¹ arr C and the relationship between current arr
65
+ // and original A is unchanged.)
61
66
 
62
- C = multiply(inv(R), C);
63
67
  var vectors;
64
68
 
65
69
  if (findVectors) {
66
- vectors = findEigenvectors(arr, N, C, values, prec, type);
70
+ vectors = findEigenvectors(arr, N, C, R, values, prec, type);
67
71
  vectors = matrixFromColumns(...vectors);
68
72
  }
69
73
 
@@ -394,16 +398,17 @@ export function createComplexEigs(_ref) {
394
398
  };
395
399
  }
396
400
  /**
397
- * @param {Matrix} A original matrix
401
+ * @param {Matrix} A hessenberg-form matrix
398
402
  * @param {number} N size of A
399
403
  * @param {Matrix} C column transformation matrix that turns A into upper triangular
404
+ * @param {Matrix} R similarity that turns original matrix into A
400
405
  * @param {number[]} values array of eigenvalues of A
401
406
  * @param {'number'|'BigNumber'|'Complex'} type
402
407
  * @returns {number[][]} eigenvalues
403
408
  */
404
409
 
405
410
 
406
- function findEigenvectors(A, N, C, values, prec, type) {
411
+ function findEigenvectors(A, N, C, R, values, prec, type) {
407
412
  var Cinv = inv(C);
408
413
  var U = multiply(Cinv, A, C);
409
414
  var big = type === 'BigNumber';
@@ -436,30 +441,34 @@ export function createComplexEigs(_ref) {
436
441
 
437
442
  var failedLambdas = [];
438
443
 
439
- for (var _i4 = 0; _i4 < len; _i4++) {
440
- var _λ = uniqueValues[_i4];
441
-
442
- var _A = subtract(U, multiply(_λ, E)); // the characteristic matrix
444
+ var _loop = function _loop(_i4) {
445
+ var λ = uniqueValues[_i4];
446
+ var S = subtract(U, multiply(λ, E)); // the characteristic matrix
443
447
 
444
-
445
- var solutions = usolveAll(_A, b);
446
- solutions = solutions.map(v => multiply(C, v));
448
+ var solutions = usolveAll(S, b);
447
449
  solutions.shift(); // ignore the null vector
448
450
  // looks like we missed something, try inverse iteration
449
451
 
450
452
  while (solutions.length < multiplicities[_i4]) {
451
- var approxVec = inverseIterate(_A, N, solutions, prec, type);
453
+ var approxVec = inverseIterate(S, N, solutions, prec, type);
452
454
 
453
455
  if (approxVec == null) {
454
456
  // no more vectors were found
455
- failedLambdas.push(_λ);
457
+ failedLambdas.push(λ);
456
458
  break;
457
459
  }
458
460
 
459
461
  solutions.push(approxVec);
460
- }
462
+ } // Transform back into original array coordinates
461
463
 
464
+
465
+ var correction = multiply(inv(R), C);
466
+ solutions = solutions.map(v => multiply(correction, v));
462
467
  vectors.push(...solutions.map(v => flatten(v)));
468
+ };
469
+
470
+ for (var _i4 = 0; _i4 < len; _i4++) {
471
+ _loop(_i4);
463
472
  }
464
473
 
465
474
  if (failedLambdas.length !== 0) {
@@ -1,2 +1,2 @@
1
- export var version = '10.4.0'; // Note: This file is automatically generated when building math.js.
1
+ export var version = '10.4.1'; // Note: This file is automatically generated when building math.js.
2
2
  // Changes made in this file will be overwritten.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mathjs",
3
- "version": "10.4.0",
3
+ "version": "10.4.1",
4
4
  "description": "Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with different data types like numbers, big numbers, complex numbers, fractions, units, and matrices.",
5
5
  "author": "Jos de Jong <wjosdejong@gmail.com> (https://github.com/josdejong)",
6
6
  "homepage": "https://mathjs.org",
@@ -25,7 +25,7 @@
25
25
  "unit"
26
26
  ],
27
27
  "dependencies": {
28
- "@babel/runtime": "^7.17.2",
28
+ "@babel/runtime": "^7.17.8",
29
29
  "complex.js": "^2.0.15",
30
30
  "decimal.js": "^10.3.1",
31
31
  "escape-latex": "^1.2.0",
@@ -33,21 +33,23 @@
33
33
  "javascript-natural-sort": "^0.7.1",
34
34
  "seedrandom": "^3.0.5",
35
35
  "tiny-emitter": "^2.1.0",
36
- "typed-function": "^2.0.0"
36
+ "typed-function": "^2.1.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@babel/core": "7.17.5",
39
+ "@babel/core": "7.17.8",
40
40
  "@babel/plugin-transform-object-assign": "7.16.7",
41
41
  "@babel/plugin-transform-runtime": "7.17.0",
42
42
  "@babel/preset-env": "7.16.11",
43
- "@babel/register": "7.17.0",
43
+ "@babel/register": "7.17.7",
44
+ "@types/assert": "^1.5.6",
44
45
  "assert": "2.0.0",
45
- "babel-loader": "8.2.3",
46
+ "babel-loader": "8.2.4",
46
47
  "benchmark": "2.1.4",
47
48
  "codecov": "3.8.3",
48
49
  "core-js": "3.21.1",
49
50
  "del": "6.0.0",
50
51
  "dtslint": "4.2.1",
52
+ "expect-type": "^0.13.0",
51
53
  "expr-eval": "2.0.2",
52
54
  "fancy-log": "2.0.0",
53
55
  "glob": "7.2.0",
@@ -55,8 +57,8 @@
55
57
  "gulp-babel": "8.0.0",
56
58
  "handlebars": "4.7.7",
57
59
  "istanbul": "0.4.5",
58
- "jsep": "1.3.0",
59
- "karma": "6.3.16",
60
+ "jsep": "1.3.4",
61
+ "karma": "6.3.17",
60
62
  "karma-browserstack-launcher": "1.6.0",
61
63
  "karma-firefox-launcher": "2.1.2",
62
64
  "karma-mocha": "2.0.1",
@@ -76,7 +78,8 @@
76
78
  "process": "0.11.10",
77
79
  "standard": "16.0.4",
78
80
  "sylvester": "0.0.21",
79
- "typescript": "4.5.5",
81
+ "ts-node": "10.7.0",
82
+ "typescript": "4.6.2",
80
83
  "webpack": "4.46.0",
81
84
  "zeros": "1.0.0"
82
85
  },
@@ -139,9 +142,10 @@
139
142
  "test:src": "mocha test/unit-tests",
140
143
  "test:generated": "mocha test/generated-code-tests",
141
144
  "test:node": "mocha test/node-tests/*.test.js test/node-tests/**/*.test.js",
142
- "test:all": "npm run test:src && npm run test:generated && npm run test:node",
145
+ "test:all": "npm run test:src && npm run test:generated && npm run test:node && npm run test:types",
143
146
  "test:browser": "karma start test/browser-test-config/local-karma.js",
144
147
  "test:browserstack": "karma start test/browser-test-config/browserstack-karma.js",
148
+ "test:types": "cd types && node --loader ts-node/esm ./index.ts",
145
149
  "coverage": "nyc --reporter=lcov --reporter=text-summary mocha test/unit-tests && echo \"\nDetailed coverage report is available at ./coverage/lcov-report/index.html\"",
146
150
  "prepublishOnly": "npm run test:all && npm run lint",
147
151
  "prepare": "npm run build",