-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
eigs function b̶r̶o̶k̶e̶n̶ has a confusing interface #3014
Comments
Hm, that looks wrong indeed. Thanks for reporting. Anyone able to dive into this bug with |
I can provide some code, but I don't know how general it is. It would need to be ported to math.js syntax. @josdejong do you want me to make PR or post it somewhere here so someone could take it on? |
Thanks! Both will help, though I guess a PR will be closest to a concrete fix. |
Created a draft, so someone can get inspired :) |
@been-jamming is it [-2, 1] for sure? wolfram alpha shows different results (I just want to be sure) |
@bartekleon You're right, |
Thanks for the PRs (#3016, #3017) and your feedbacks @bartekleon and @been-jamming. I indeed have the feeling too that there is some more generic issue in play, and that we should figure that out rather than implementing a special case for a 2x2 matrix. I did try out how
|
I will try making more generalized version this week. If possible, test cases would be nice. (I don't know how big / many / edge cases I should make so contributions are welcome) |
Thanks Bartosz! |
Sorry I didn't have a chance to look at this issue before now. I do not think there is any serious difficulty with the current behavior of eigs in mathjs, just some misunderstandings: (1) eigs(A) by design returns the matrix E whose columns are eigenvectors. That's the canonical way they are presented, because then AE equals the matrix ΛE, where Λ = diag(λ) is the diagonal matrix of eigenvalues. However if in mathjs you let So the quick upshot is that to get the eigenvector corresponding to the first eigenvalue, you want Now I do agree this is nevertheless somewhat confusing, even though I hope I've justified that it's really the only reasonable way for the function to work. So a couple of things we might do: (a) rename the property of eigs(A) from (2) Then it was hard to recognize the transposition that was going on because of the "funny" numbers in the returned E. After all, we know that "the" eigenvectors of A are (1,2) and (-1, 1). But the fact is there is no such thing as "the" eigenvectors: if v is an eigenvector, then so is kv for any scalar k. Hence (1/3, 2/3) and (1,-1) are just as good a pair of eigenvectors, as are 2.42535(1,2) and -0.97014(-1,1) -- which just happens to be the pair of eigenvectors that this particular algorithm finds. I do not think it's worth significant effort to replace mathjs's current eigs function, given its maturity (been through a lot of overhauls above!) unless someone in this conversation has a proposal that will be demonstrably faster/more accurate/better in some other metric. But I think a PR for either of (a) or (b) would be a good idea -- renaming the issue to reflect that. |
Thanks for investigating the issue, Glen! However, my 2¢ are that changing the eigs API should at least be considered, as it confused even the project owner and the guy who implemented a part of it 😅 EDIT: Oh, now I recall even thinking about how to improve the API, and failing to. The problem is that in Math.js a two-dimensional array of numbers is automatically interpreted as a row matrix. So it is literally impossible to return an array of vectors and not have users confuse it with a row matrix. If there ever was Math.js 2, I would strongly argue against that decision, having now seen too many confusing edge-cases this leads to. But right now, it is baked deep inside Math.js, so there's no coming back. EDIT 2: How about renaming the prop to |
Right, I was trying to say that in my analysis, but may not have been clear enough. That's the central problem here. I do think some changes are in order, and a PR will be needed for #2879 anyway, so there is a good opportunity here. Note that because of defective matrices, the eigenvector matrix will in generally not be nxn, and we do need to associate specific eigenvalues with specific eigenvectors. So one totally unambiguous data structure to pass back would be an array of objects, in order from largest eigenvalue (in abs value) to smallest, with each object having just two properties: |
Thanks for your clear explanation Glen, I now see that the results are indeed technically correct 😅, though the API and the actual values cause confusion. So, we're mixing rows/columns when extracting the vector. As a solution, I propose the following:
Does that make sense? |
@gwhitney so I like your idea of an API |
I think there are only two cases really: One being the ideal one: Other being defective matrix: I think there might be a case that you can't perform eigenvalue decomposition at all. (I do believe it might be a case of non-diagonalizable matrices. But teeechnically you still can do eigenvalue decomposition) E.x you have "two" eigenvalues being But generally having eigenvalue = 0 means that matrix is not diagonalizable |
I feel strongly that the data structure we pass back should not depend on whether the matrix is defective or not, so we should design a data structure that works in either case; the current one does not. Jos has already said he prefers a single breaking change to a non-breaking one followed by a breaking one. So I propose we pass back an array of values as we do now, with their algebraic multiplicities (so the vector will always have n entries for an nxn matrix), and then under the key 'eigenvectors' (just to change the key, so that anyone switching will immediately know there is a difference as there is no 'vectors' key), we pass back an array of plain objects, one for each independent eigenvector. Each of these plain objects has two keys: value and vector. The value property reiterates the eigenvalue for that eigenvector, but is necessary because you can't predict the geometric multiplicities from the arithmetic ones. The vector property gives a single eigenvector for that value. An alternative might be a map from eigenvalues to eigenvectors, but then it seems as though the values would be arrays of vectors, which have the confusability property that started this whole thread. I am not wedded to this proposal by any means, but I haven't thought of a better one. |
Sorry I don't think I addressed the comment of @josdejong about how this API proposal handles defective matrices. For non-defective matrices, there is one item in the |
Yes that is a very good point, let's make sure of that. The current API looks like this: math.eigs([[2, 0, 0], [0, 1, 0], [0, 0, 5]])
// {
// values: [1, 2, 5],
// vectors: [ // Remember to take the columns, not the rows!
// [ 0, 1, 0 ],
// [ 1, 0, 0 ],
// [ 0, 0, 1 ]
// ]
// }
math.eigs([[2, 1], [0, 2]])
// Currently: Error
// Result should be: a double eigenvalue 2, with only one distinct eigenvector `[1; 0]` One question: I'm not sure whether the index of the eigenvector currently correlates with the index of the correspondingeigenvalue, is that the case? I guess so? @gwhitney If we output fewer eigenvectors than eigenvalues, how can we know when eigenvector belongs to which eigenvalue? I would like an API where that is clear. What do you have in mind in that regard? Here some ideas with different output for Idea 1(I think too complex) {
values: [2, 2],
vectors: [
{
vector: [1, 0],
valueIndices: [0, 1]
}
]
} Idea 2Just repeat double eigenvalues and eigenvectors, and inform about that via a flag [
{
value: 2,
vector: [1, 0],
multiplicity: 2
},
{
value: 2,
vector: [1, 0],
multiplicity: 2
}
] Idea 3Do not repeat double eigenvalues, and inform about the multiplicity [
{
value: 2,
vector: [1, 0],
multiplicity: 2
}
] Any thoughts on this? I'm not sure if it is handiest in practice to always have a number of eigenvalues equal to the size of your matrix, or not (that would be the only reason for Idea 2). |
@josdejong you have have same eigenvalues having different eigenvectors so option 3 isn't really perfect. Maybe something like: Array[{
value: vector
vectors: vector[]
multiplicity: number
}] So: [
{
value: 2,
vectors: [[1, 0], [1, 0]],
multiplicity: 2
},
{
value: 3,
vectors: [[1, 0], [0, 1]],
multiplicity: 2
},
{
value: 1,
vectors: [[1, 0]],
multiplicity: 1
}
] Also general rule is to order eigenvalues by their real part (I believe) |
Sorry if I have not been writing clearly. Altihough I understand that you are OK with breaking changes, I think that we should try to keep the interface as close as we can. In particular, I think we should continue to return as the values key a vector always of length n of the eigenvalues. That conveys two of the four pieces of information the client may want: (A) what the eigenvalues are and (B) the algebraic multiplicity of each. Also a significant amount of time all the client wants is the values, so they should be kept easy to access. Then we need to replace the current vectors key, as it is ambiguous in defective cases, and prone to misinterpretation. The remaining info we need to convey is (C) the geometric multiplicity of each eigenvalue and (D) as many independent eigenvectors as exist. Since eigenvalues may repeat and we don't want to put eigenvectors in lists, a map from eigenvalues to eigenvectors is out. Instead we want a more general association of values and vectors, which we can pass back in a new key to make transition safer. I am proposing the key 'eigenvectors'. The value of this key would be a list of plain objects, each with a 'value' property giving the eigenvalue and a 'vector' property giving the eigenvector. An alternative would be just a list of pairs [value, vector] but that's more opaque. Anyhow, this gives you D from the vector part of each entry and C by counting how many times a given value appears. To make this concrete, suppose M has eigenvalue 4 with algebraic multiplicity 3 but geometric multiplicity 2 and independent eigenvectors [1,0,0,0] and [0,1,0,0], and also eigenvalue -2 with algebraic multiplicity 1 and eigenvector [0,0,0,1]. Then I propose eigs would return:
(but as I mention we could opt for the value of eigenvectors to be
to be more compact but also more opaque.) As to your ideas 1,2,3: As for bartekleon's suggestion, it has arrays of vectors which I think we are trying to avoid because of the structural confusion of array of vectors and matrix in mathjs, exacerbated by the fact that then the vectors look like rows when they are actually columns. Hopefully I have finally been clearer. I am fine in the end with any return value that conveys all of A,B,C,D. Within that we should strive to maximize clarity and minimize redundancy. Thanks for considering. |
Thanks Glen and Bartosz. From what I read here it looks like at least Matlab doesn't sort the returned eigenvalues. I'm not sure if there is value in sorting them. At least you can always sort them yourselves if needed. I'm OK with either sorting the output or not though if you guys think it is helpful. I like Glen's proposal a lot: {
values: [4, 4, 4, -2],
eigenvectors: [
{value: 4, vector: [1,0,0,0]},
{value: 4, vector: [0,1,0,0]},
{value: -2, vector: [0,0,0,1]}
]
} It solves the ambiguity that One last thought: using names {
values: Array | Matrix
eigenvectors: Array<{ value: number | BigNumber, vector: Array | Matrix}>
vectors: void // throws an error explaining to use eigenvectors instead
} What do you think? |
Looks good to me :) |
I do agree that the top level properties being And to your final point -- are you saying you want to, in the new version, return an object that has a getter/setter for the OK, I think we are super close --- I think Jos can just make his pronouncements on these final tiny points and then I can get started on a PR. Thanks to all! |
Ah, missed this point. I would not alter the order of the values property from whatever it is now. Even if you decide we should rename it, my goal for the PR is that there would be no change in what array of eigenvalues is produced. So if it's sorted now, it would stay sorted, and if it's not, it would stay that way, too. In my mind, the fewer collateral changes from bugfixes, the better. |
👍 sounds good. Ok let's do the following:
|
Previously, attempting to take the `eigs` of any defective matrix was doomed to fail in an attempt to solve a singular linear system. This PR detects the situation (as best as it can given the inherent numerical instability of the current methods used) and handles it. Note that in such cases, it's not possible to return a square matrix whose columns are the eigenvectors corresponding to the returned eigenvalues. In light of that fact and issue josdejong#3014, this PR also changes the return value of `eigs` so that the eigenvectors are passed back in a property `eigenvectors` which is an array of plain objects `{value: e, vector: v}`. Note that this PR makes the ancillary changes of correcting the spelling of the filename which was "realSymetric.js," and replacing the now-unnecessary auxiliary function "createArray" therein with `Array(size).fill(element)`. The rationale for performing these changes not strictly related to the issues at hand is that this file is rarely touched and with the level of maintenance hours we have at hand, it's more efficient to do these small refactorings in parallel with the actual bugfixes, which are orthogonal and so will not be obfuscated by this refactor. Note `git diff` does properly track the file name change. However, it also makes a potentially more pervasive change: in order for the numerically-sensitive algorithm to work, it changes the condition on when two very close (double) numbers are "nearlyEqual" from differing by less than DBL_EPSILON to differing by less than or equal to DBL_EPSILON. Although this may change other behaviors than the ones primarily being addressed, I believe it is an acceptable change because (a) It preserves all tests. (b) DBL_EPSILON is well below the standard config.epsilon anyway (c) I believe there are extant issues noting the odd/inconsistent behavior of nearlyEqual near 0 anyway, so I believe this will be overhauled in the future in any case. If so, the eigenvector computation will make a good test that a future nearlyEqual algorithm is working well. To be clear, the direct motivation for the change is that there are multiple cases in the eigenvector computation in which a coefficient that is "supposed" to be zero comes out to precisely DBL_EPSILON, which is fairly unsurprising given that these coefficients are produced by subtracting an eigenvalue from a diagonal entry of a matrix, which is likely to be essentially equal to that eigenvalue. As many tests of defective matrices as I could readily find by web searching have been added as unit tests (and one more in the typescript type testing). An additional case I found still fails, but in the _eigenvalue_ computation rather than the _eigenvector_ search, so that was deemed beyond the scope of this PR and has been filed as issue josdejong#3036. Resolves josdejong#2879. Resolves josdejong#2927. Resolves josdejong#3014.
Fixed in |
* fix: Find eigenvectors of defective matrices (josdejong#3037) * fix: Find eigenvectors of defective matrices Previously, attempting to take the `eigs` of any defective matrix was doomed to fail in an attempt to solve a singular linear system. This PR detects the situation (as best as it can given the inherent numerical instability of the current methods used) and handles it. Note that in such cases, it's not possible to return a square matrix whose columns are the eigenvectors corresponding to the returned eigenvalues. In light of that fact and issue josdejong#3014, this PR also changes the return value of `eigs` so that the eigenvectors are passed back in a property `eigenvectors` which is an array of plain objects `{value: e, vector: v}`. Note that this PR makes the ancillary changes of correcting the spelling of the filename which was "realSymetric.js," and replacing the now-unnecessary auxiliary function "createArray" therein with `Array(size).fill(element)`. The rationale for performing these changes not strictly related to the issues at hand is that this file is rarely touched and with the level of maintenance hours we have at hand, it's more efficient to do these small refactorings in parallel with the actual bugfixes, which are orthogonal and so will not be obfuscated by this refactor. Note `git diff` does properly track the file name change. However, it also makes a potentially more pervasive change: in order for the numerically-sensitive algorithm to work, it changes the condition on when two very close (double) numbers are "nearlyEqual" from differing by less than DBL_EPSILON to differing by less than or equal to DBL_EPSILON. Although this may change other behaviors than the ones primarily being addressed, I believe it is an acceptable change because (a) It preserves all tests. (b) DBL_EPSILON is well below the standard config.epsilon anyway (c) I believe there are extant issues noting the odd/inconsistent behavior of nearlyEqual near 0 anyway, so I believe this will be overhauled in the future in any case. If so, the eigenvector computation will make a good test that a future nearlyEqual algorithm is working well. To be clear, the direct motivation for the change is that there are multiple cases in the eigenvector computation in which a coefficient that is "supposed" to be zero comes out to precisely DBL_EPSILON, which is fairly unsurprising given that these coefficients are produced by subtracting an eigenvalue from a diagonal entry of a matrix, which is likely to be essentially equal to that eigenvalue. As many tests of defective matrices as I could readily find by web searching have been added as unit tests (and one more in the typescript type testing). An additional case I found still fails, but in the _eigenvalue_ computation rather than the _eigenvector_ search, so that was deemed beyond the scope of this PR and has been filed as issue josdejong#3036. Resolves josdejong#2879. Resolves josdejong#2927. Resolves josdejong#3014. * refactor: remove comma that lint now doesn't like * test: add a test for eigs with a precision argument * feat: Use simple shifts in QR eigenvalue iterations that improve convergence Although we might want to use better shifts in the future, we might just use a library instead. But for now I think this: Resolves josdejong#2178. Also responds to the review feedback provided in PR josdejong#3037. * docs: update history * fix: josdejong#3074 improve error message when using function `max` in `derivative` * fix: josdejong#3073 parsing quotes inside a string * fix: josdejong#2027 cannot use named operators like `to` or `mod` as property name * chore: update devDependencies * chore: run `npm audit fix` * chore: publish v11.11.2 * Drop official support for Node.js 14 and 16 * fix: change toTex variable and function assignment from `:=` to `=` (see josdejong#2980, josdejong#3032) * Update history * docs: fix typo in `p.set` example in the documentation of matrices (josdejong#3080) * feat: Add option to eigs() to turn off eigenvector computation (josdejong#3057) * feat: Add option to eigs() to turn off eigenvector computation For large matrices, the eigenvector computation can be noticeably expensive and so it's worthwhile to have a way to turn it off if the eigenvectors will not be used. Resolves josdejong#2180. * fix: Add test for precision in options arg of eigs And also a fix for a small bug that the new test uncovered. * test: check eigs with matrix and options * refactor: remove dead code from complexEigs.js * fix: add new signatures of eigs to typescript * test: ensure eigenvectors property not present with eigenvectors: false option * fix: correct balancing code in complexEigs * Fix: josdejong#3073 escaping in strings (josdejong#3082) * chore: refactor parsing strings to not rely on `JSON.parse` * fix: josdejong#3073 function `format` not escaping control characters and double quotes in strings * chore: add more unit tests * feat: implement subtractScalar (josdejong#3081, josdejong#2643) * added subtractScaler * added subtractScaler missing entries * added test cases for 2 or more parameters, test for subtractScalar instead fo subtract * replaced subtract with subtractScalar whereever possible --------- Co-authored-by: Jos de Jong <[email protected]> * fix: function `clone` not throwing an error in case of an unsupported type like a function * chore: make the unit test more robust * fix: josdejong#2960 add type definition of function `symbolicEqual` (josdejong#3035) * chore: update devDependencies * chore: publish v11.12.0 * fix: josdejong#2919 TypeScript types not working with NodeNext module resolution (josdejong#3079) * docs: update deprecation messages * chore: publish v12.0.0 * chore: update history (forgot to mention a feature in v12) * fix: josdejong#3088 error in the description of the return type of `pickRandom` * fix josdejong#3087: extend function `mod` with support for negative divisors in when using `BigNumber` or `Fraction` * fix josdejong#3092: a typo in an error message when converting a string into a number * fix josdejong#3094: function `derivative` mutates the input expression when it fails * feat: extend function `round` with support for units (josdejong#3095) * fix josdejong#2761: implement support for units in function `round` (WIP) * fix josdejong#2761: extend function `round` with support for units * docs: describe all signatures in the docs of function round * chore: fix linting issue * chore: remove less-useful signatures for round with units and matrices * chore: update devDependencies * chore: publish v12.1.0 * docs: update the release date in history.md * fix: josdejong#3096 embedded docs of `eigs` throwing an error * chore: update history * fix: accidentally passing a scope as third _and_ fourth argument to raw functions * feat: lazy evaluation of and, or, &, | (josdejong#3101, josdejong#3090) * If fn has rawArgs set, pass unevaluated args * Add shared helper function for evaluating truthiness * Add and & or transform functions for lazy evaluation * Add lazy evaluation of bitwise & and | operators * Add unit tests for lazy evaluation * Add lazy evaluation note to docs * Move documentation to Syntax page * Replace `testCondition()` with test evaluation of logical function itself * Use `isCollection()` to simplify bitwise transform functions * fix: do not copy scope in raw OperatorNode, test lazy operators scope * fix: linting issues --------- Co-authored-by: Brooks Smith <[email protected]> * docs: update history * chore: update devDependencies * chore: publish `v12.2.0` * fix: josdejong#3109 method `Node.toHTML` not accepting a custom `handler` * chore: upgrade node and Github actions versions for CI * chore: upgrade devDependencies * chore: publish v12.2.1 * chore: oopsie, update version number in version.js * chore: up version number, and pin fraction.js at v4.3.4 * chore: publish v12.2.1 * docs: update maintenance badge to 2024 * docs: fix the github sponsors badge * Support new metric prefixes: Q, R, r, and q (josdejong#3113) * added Q, R, r, q metrix prefixes * tests added for new prefixes * removed duplicate tests * maybe square and cubic tests will bump code cov into the positive * Check numeric value --------- Co-authored-by: Jos de Jong <[email protected]> * chore: update history * docs: change 2023 to 2024 * Unitless quantity conversion bug (josdejong#3117) * Add test for conversion to unitless quantity * Avoid access to missing array index * Also check that other.units is not empty * Add test for abs of dimensionless unit * Fix: avoid access to missing units array index --------- Co-authored-by: Jos de Jong <[email protected]> * chore: update history * fix `toSI()` wrongly converting `degC` (josdejong#3118) * Add new test for degC toSI * Convert value using to() if needed * Only set ret.value = null when it is not already null --------- Co-authored-by: Jos de Jong <[email protected]> * chore: update history * chore: update devDependencies * chore: publish v12.3.0 * chore: run `npm audit fix` * Infer types of arguments more precisely (josdejong#3123) * Prefer inferring types of nodes as tuples * Implement for IndexNode * Test for types * Use tuple type for array node --------- Co-authored-by: Jos de Jong <[email protected]> * chore: update history * CodeEditorExample (josdejong#3027) * broadcasting * Simplified broadcasting * Updated for broadcasting * Changed to camel case * Camel case and auto formating * Added comments * Skip if matrices have the same size * Fixed issue with undefined variable missing dot in `A._size` * Implemented broadcasting in all functions * Added helper functions * Added function to check for broadcasting rules * Tests for broadcasted arithmetic * Fixed issue with matrix the size of a vector * Documented and updated broadcasting * Included broadcast.test * Included math to syntax when missing * Add code editor example * Vite mini project * Initial example * added alpine debounce * Fixed display * Added parser.clear * Added mathjs-language * Made module to get expressions * Added custom events * Issue with help formatting * Simplified help format * Restored package.json * removed unneded icons * Added readme file * Fixed versions * Commented getExpressions * Documented main.js * Fixed title * Fixed alpine version * Removed AlpineJS * Added documentation and renamed variables for clarity * Fixed naming errors --------- Co-authored-by: David Contreras <[email protected]> Co-authored-by: Jos de Jong <[email protected]> * chore: minor refinement in the `code editor` example * chore: update HISTORY.md * fix: josdejong#3114 build warnings related to a number of wrong `/* #__PURE__ */` annotations * chore: do not output documentation warnings unless running with a `--debug-docs` flag * docs: update authors * Fixed issue with long lines in Code Editor Example (josdejong#3130) * broadcasting * Simplified broadcasting * Updated for broadcasting * Changed to camel case * Camel case and auto formating * Added comments * Skip if matrices have the same size * Fixed issue with undefined variable missing dot in `A._size` * Implemented broadcasting in all functions * Added helper functions * Added function to check for broadcasting rules * Tests for broadcasted arithmetic * Fixed issue with matrix the size of a vector * Documented and updated broadcasting * Included broadcast.test * Included math to syntax when missing * Add code editor example * Vite mini project * Initial example * added alpine debounce * Fixed display * Added parser.clear * Added mathjs-language * Made module to get expressions * Added custom events * Issue with help formatting * Simplified help format * Restored package.json * removed unneded icons * Added readme file * Fixed versions * Commented getExpressions * Documented main.js * Fixed title * Fixed alpine version * Removed AlpineJS * Added documentation and renamed variables for clarity * Fixed naming errors * Fixed issue with long lines * Edge case where multiple expressions are on the same line not ending in ";" --------- Co-authored-by: David Contreras <[email protected]> Co-authored-by: Jos de Jong <[email protected]> * docs: josdejong#3145 fix documentation about REPL, it does require a build step nowadays * fix: josdejong#3142 support BigNumber values for the options of function `format`: `precision`, `wordSize`, `lowerExp`, `upperExp` * Improve type definitions of function `hypot` (josdejong#3144) * Addressed silentmissile's comment in josdejong#3125 * Added method overload to index.d.ts, have to revert commit due to changes to package-lock.json with using npm install to run the unit tests & lint tests * chore: update HISTORY.md * fix: josdejong#3141 `help(config)` altering the actual `config` when evaluating the examples * chore: update devDependencies * chore: publish `v12.3.1` * chore: add a benchmark to get a feel for how fast scope variables are resolved * chore: fix linting issue * Fix not being able to use `and` and `or` inside a function definition (josdejong#3150) * chore: write unit tests using `and` and `or` inside a function definition (WIP) * fix: josdejong#3143 fix scope issues in rawArgs functions by implementing a `PartitionedMap` * fix: add more unit tests for `ObjectWrappingMap` * fix: don't let `ObjectWrappingMap` and `PartitionedMap` extend `Map` (risk of having non-overwritten methods) * docs: update docs about `rawArgs` functions * chore: update devDependencies * chore: publish v12.3.2 * chore: publish v12.3.2 * fix: josdejong#3155 remove an outdated section about complex numbers from the docs * docs: describe `getAllAsMap` in the Parser docs (josdejong#3158) * chore: update history * Determinant with small numbers fix (josdejong#3139) * feat: trailing commas in matrices (josdejong#3154) * chore: update history * docs: fix broken example in the documentation about matrices (see josdejong#3159) * fix: `PartitionedMap` and `ObjectWrappingMap` missing a property `Symbol.iterator` * fix: linting issue * fix: mode signature return types (josdejong#3153) * fix: mode type signatures * Add ts tests for mode * Add assertions mode type tests * Update author Rich in AUTHORS file --------- Co-authored-by: Rich Martinez <[email protected]> Co-authored-by: Jos de Jong <[email protected]> * chore: update history * feat: improve the performance f `multiply` by adding matrix type inferencing (josdejong#3149) * added type inference * added back accidentally removed return statement and made it so that the explicitly defined type is returned at the end * made sure that mixed types are ignored in the process data types check * fixed issue with undefined _data for SparseMatrix and linting issues * simplified syntax and added type inferencing to src/type/matrix/utils and src/function/matrix/dot.js * shortened the final part of the type inferencing and moved it to matrix creation in multiply --------- Co-authored-by: Jos de Jong <[email protected]> * chore: update history * Fix: josdejong#3100 function `round` not handling round-off errors (josdejong#3136) * Fixing rounding bug from issue 3100 * Corrected syntax and converted if...else to logic using ternary operator * Removing nearlyEqual comparison because a false return value was mathematically impossible by user input. Adding dynamic epsilon logic to cover cases when a user requests to round a number to a higher precision than epsilon in the config file. Also adding tests to cover dynamic epsilon cases. * Removing dynamic epsilon and adding test for changing config.epsilon during runtime * Reintroducing nearly equal verification for round function. Adding test case for changing epsilon at runtime. Both tests for changing epsilon at runtime also verify the false nearlyEqual scenario. --------- Co-authored-by: Jos de Jong <[email protected]> * chore: update history * chore: update devDependencies (most notably eslint) * chore: publish v12.4.0 * fix josdejong#3163: `toTex` wrongly returning `Infinity` for large BigNumbers * fix josdejong#3162: add license information about CSParse (josdejong#3164) * update history * fix: faster startup time of the CLI and REPL by loading the bundled file * feat: Interactive lorenz example (josdejong#3151) * Interactive lorenz * Separate Interactive Lorenz * Cleanup * Bigger graphs * Full screen examples --------- Co-authored-by: Jos de Jong <[email protected]> * fix: give the inputsDiv a white background (see josdejong#3151) * chore: update history * chore: remove `polyfill.io` inside example (josdejong#3167) Co-authored-by: Jos de Jong <[email protected]> * fix josdejong#3175: expose `math.Unit.ALIASES`, update history * chore: update history * doc: create CODE_OF_CONDUCT.md See josdejong#3174 * fix: josdejong#3172 simplify `"true and true"` * fix: josdejong#3175 cannot delete units using `math.Unit.deleteUnit` * chore: update devDependencies * chore: run `npm audit fix` * chore: publish v12.4.1 * docs: fix misleading documentation for expression tree traverse (josdejong#3177) Callback function for MathNode.traverse() returns void. Documentation says callback must return a replacement for the existing node (possibly copied from transform() above). * chore: update history * fix: josdejong#3180 fix type definitions of function `add` and `multiply` to allow more than two arguments * chore: update devDependencies (most notably `gulp@5`) * chore: replace utility function `values` with `Object.values` (fix josdejong#3194) * fix josdejong#3192: function `isNaN` returns `false` for `NaN` units in a matrix or array * Use referToSelf() to recursively check if various types are NaN in an array or matrix * fix array test description from isNegative to isNaN * Add test for units in a matrix --------- Co-authored-by: Jos de Jong <[email protected]> * chore: update history * chore: update devDependencies * chore: publish `v12.4.2` * chore: replace util functions `values` and `contains` with using native JS functions (see josdejong#3194) * chore: replace util functions `values` and `contains` and usages of `indexOf` with using native JS functions `values` and `contains` (see josdejong#3194) * fix: serialization of Units without a value, see josdejong#1240 * Fix: outdated, incorrect documentation about the order of precedence for operator modulus `%`. See josdejong#3189 * feat: nearly equal with relative and absolute tolerance (josdejong#3152) * nearlyEqual with absolute and relative tolerances * Format * nearlyEqual for bigNumber * Added skip for NaN * Reduce diff a bit * Issue with examples in jsdcos * Updated all calls for nearlyEqual * Fixed failing tests * Changed epsilon to relTol, absTol * Changed references to epsilon in docs and tests * Added warning for config.epsilon * Fix warning in zeta.test * Added config test * Added sinon to test console.warn --------- Co-authored-by: Jos de Jong <[email protected]> * chore: move `sinon` to devDependencies and fix two typos * chore: adjust `isPositive`, `isNegative`, and `isZero` to the new `relTol` and `absTol` * docs: document how to run tests for the type definitions * Improve quantileSeq typings (josdejong#3198) * Improve quantileSeq typings * Add tests, revert comment changes * Fix type tests * chore: update HISTORY.md * chore: cleanup entry files that are deprecated since `v8.0.0` (2020-11-06) * fix: upgrade to `[email protected]` * chore: convert CJS files to ESM (josdejong#3204) * chore: added test cases to deepForEach (josdejong#3211) * feat: implement support for `bigint` (josdejong#3207, josdejong#2737) * chore: move browserslist from package.json into `.browserslistrc` * chore: change browerslist to browsers that are not dead and fully support es6 * chore: improve browserslist to explicity require bigint support * chore: publish v12.4.3 * chore: update package-lock.json * chore: update devDependencies * chore: publish v13.0.0 * docs: document dropping JS engines that do not support E6 or bigint in v13 * fix: example advanced/custom_argument_parsing.js * chore: add unit tests for `deepMap`, `isCollection`, and `reduce` * docs: fix example `convert_fraction_to_bignumber.js` by upgrading to `[email protected]` * Broadcast refactor (josdejong#3220) * chore: update history * fix: josdejong#3227 generated bundle containing `catch` blocks without parameters * fix: josdejong#2348 update type definitions of the `Parser` methods (josdejong#3226) Co-authored-by: Jos de Jong <[email protected]> * chore: update devDependencies and run `npm audit fix` * chore: publish v13.0.1 * Further improve quantileSeq typings (josdejong#3223) Co-authored-by: Jos de Jong <[email protected]> * chore: update history * chore: update devDependencies * fix josdejong#3227: change the minimum required JS version to ES2020 in the docs * chore: publish v13.0.2 * chore: update dependencies of the code editor example * fix: josdejong#3232 fix type definitions of function `format` to support notations `hex`, `bin`, and `oct` * fix: use exact values for US liquid volume units (josdejong#3229) 1 US gallon is defined as 231 cubic inches, which is exactly 3.785411784 L (since 1 inch is defined as 25.4 mm). Other units are defined against the gallon. Co-authored-by: Jos de Jong <[email protected]> * fix: types static methods and members for Unit class (josdejong#3230) * fix: types static method for Unit class Changes unit interface to declare class to enable the adding of static methods. * refactor: change to not using declare class * fix: adds more unit static methods and updates tests * chore: moves test from wrong location * fix: adds additional static methods and updates jsDocs --------- Co-authored-by: Jos de Jong <[email protected]> * chore: update history * chore: update devDependencies * chore: publish `v13.0.3` * chore: update package-lock.json * chore: revert updating devDependencies * chore: revert reverting updating devDependencies * chore: try use `ubuntu-24.04` instead of `ubuntu-latest` * chore: try use `ubuntu-22.04` instead of `ubuntu-24.04` * chore: try use `ubuntu-latest` instead of `ubuntu-22.04` again * chore: disable testing on Node 22 for now until we get mocha working again in GitHub actions * chore: publish `v13.0.3` for real * chore: enable testing on Node 22 again * feat: add matrix datatypes in more cases (josdejong#3235) * chore: update history * docs: add a link to the documentation page about the syntax expression from the function `evaluate` (fix josdejong#3238) * feat: export util functions for maps and improve documentation of `scope` (josdejong#3243) * feat: export util functions `isMap`, `isPartitionedMap`, and `isObjectWrappingMap` and improve the documentation of `scope` (see josdejong#3150) * chore: fix broken unit tests * docs: refine the explanation about scopes * chore: update history * fix: josdejong#3244 fix broken link to `ResultSet` in the docs about classes * fix: function `map` not always working with matrices (josdejong#3242) * Removed maxArgumentCount in favor of applyCallback * Making a pure _recurse function * Added cbrt tests, removed unnecesary changes in functions. * Fixed main bottleneck * Restored back function before unintended change * Fix format --------- Co-authored-by: Jos de Jong <[email protected]> * chore: update history * chore: add tea.yaml file * docs: spelling fixes in the embedded docs (josdejong#3252) Co-authored-by: Jos de Jong <[email protected]> * chore: update history * chore: add a benchmark testing `DenseMatrix.map(...)` and `DenseMatrix.forEach(...)` (see josdejong#3251) * feat: support multiple inputs in function `map` (josdejong#3228) * chore: update history * chore: update devDependencies * chore: publish `v13.1.0` * fix: various security vulnerabilities (josdejong#3255) * fix: disable parser functions in the CLI (security issue) * fix: ensure `ObjectWrappingMap` doesn't allow deleting unsafe properties (security issue) * fix: enable using methods and (safe) properties on plain arrays * docs: update the "Less vulnerable expression parser" section in the docs * chore: fix typos and linting issues * chore: keep functions like `simplify` enabled in the CLI * docs: update the security page * fix: ensure `ObjectWrappingMap.keys` cannot list unsafe properties * fix: when overwriting a rawArgs function with a non-rawArgs function it was still called with raw arguments * docs: fix a typo * chore: publish v13.1.1 * fix broken links in configuration.md (josdejong#3254) Co-authored-by: Jos de Jong <[email protected]> * chore: update history * fix: improve the type definitions of `ConstantNode` to support all data types (josdejong#3257) * chore: update history * chore: fix broken benchmark * fix: josdejong#3259 function `symbolicEqual` missing in the TypeScript definitions * chore: update AUTHORS file * fix: josdejong#3259 revert the duplicate `symbolicEqual` definition and just export the existing definitions * fix: josdejong#3246 add type definitions for function `leafCount` * fix: josdejong#3253 cannot use identifiers containing special characters in function `derivative` * chore: update history * chore: extend the `map.js` benchmark * chore: fix linting issue * chore: improve performance of functions `map`, `filter` and `forEach` (josdejong#3256) * Implement reduceCallback * Add jsdocs * implement simplifyCallback in other functions * Moved recurse to array.js * Format * Separate transform callback * forEach transform * Renamed applyCallback to simplifyCallback * Simplified index transform * renamed to reducedCallback and simplifiedCallback to simpleCallback * chore: fix linting issue * Added forEach benchmark * renamed simplifyCallback to optimizeCallback --------- Co-authored-by: Jos de Jong <[email protected]> * chore: update history * fix: josdejong#3267 implicit multiplication with a negative number and unit `in` * feat: speed up the `map()` and `forEach()` functions in DenseMatrix.js (josdejong#3251) * Optimize the map and forEach functions in DenseMatrix.js * Changed index back to Array from Uint32Array and clone it using index.slice(0) instead of [...index] * Fixed merge conflicts with the fast callback optimization * Fixed the documentation for _forEach() * Fixed _forEach comment and made it return an immutable index array * Resolved DenseMatrix unit test suggestions --------- Co-authored-by: Jos de Jong <[email protected]> * chore: update HISTORY.md and AUTHORS * chore: use `codecov/codecov-action` * chore: try fix the codecov-action * chore: try fix the codecov-action * chore: try fix the codecov-action * chore: try fix the codecov-action * docs: document the syntax of `map` and `forEach` in the expression parser (josdejong#3272) * chore: update docs * chore: update devDependencies * chore: publish `v13.2.0` * chore: add a missing comma * docs: fix a typo on the Syntax page (josdejong#3276) * fix: update dependencies and devDependencies * chore: cleanup unused imports * chore: revert to `[email protected]` to keep the (old) eslint version happy --------- Co-authored-by: Glen Whitney <[email protected]> Co-authored-by: Jos de Jong <[email protected]> Co-authored-by: Vincent Tam <[email protected]> Co-authored-by: Vrushaket Chaudhari <[email protected]> Co-authored-by: Juan Pablo Alvarado <[email protected]> Co-authored-by: Brooks Smith <[email protected]> Co-authored-by: Alex Edgcomb <[email protected]> Co-authored-by: Carl Osterwisch <[email protected]> Co-authored-by: S.Y. Lee <[email protected]> Co-authored-by: David Contreras <[email protected]> Co-authored-by: David Contreras <[email protected]> Co-authored-by: Hudsxn <[email protected]> Co-authored-by: Rich Martinez <[email protected]> Co-authored-by: Rich Martinez <[email protected]> Co-authored-by: RandomGamingDev <[email protected]> Co-authored-by: Brian Fugate <[email protected]> Co-authored-by: Sukka <[email protected]> Co-authored-by: Rohil Shah <[email protected]> Co-authored-by: Laurent Gérin <[email protected]> Co-authored-by: Adam Jones <[email protected]> Co-authored-by: Lucas Eng <[email protected]> Co-authored-by: Orel Ben Neriah <[email protected]> Co-authored-by: Vistinum <[email protected]> Co-authored-by: Vas Sudanagunta <[email protected]> Co-authored-by: Brooks Smith <[email protected]> Co-authored-by: Jmar L. Pineda <[email protected]>
math.eigs
produces correct eigenvalues with incorrect eigenvectors in some cases. Note that the example in the documentation still seems to give the correct results.To Reproduce
Execute the following:
Result:
Expected:
Edit: It looks like the correct eigenvector is actually
[ -1, 1 ]
The text was updated successfully, but these errors were encountered: