Created
September 13, 2012 22:59
-
-
Save juandopazo/3718393 to your computer and use it in GitHub Desktop.
Why I want ES.next yesterday
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // some code I'm writing... | |
| class Matrix { | |
| /* ... */ | |
| transpose() { | |
| var [n, m] = this.size(), | |
| rows = this.rows, | |
| result = [], | |
| i = 0, j = 0; | |
| for (j = 0; j < m; j++) { | |
| result[j] = []; | |
| for (i = 0; i < n; i++) { | |
| result[j][i] = rows[i][j]; | |
| } | |
| } | |
| return new Matrix(...result); | |
| } | |
| svd() { | |
| let A = this.transpose().x(this), | |
| [n, m] = this.size(), | |
| S = Matrix.Zeros(n, m); | |
| A.eigenvalues() | |
| .sort((a, b) => b - a}) | |
| .map(Math.sqrt) | |
| .forEach((val, i) => S.rows[i][i] = val); | |
| /* ... */ |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've been avoiding
letbecause Traceur usestry...catchwhen you use it inside blocks and that's a performance killer. For example this:...turns into:
When you use
letin the top scope of a function it just turns it into avarso in this case it works ok.