Git Product home page Git Product logo

numeric's People

Contributors

sloisel avatar yuzeh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

numeric's Issues

numeric.round fails in 1.2.6

Currently using numeric: version 1.2.4 extensively, throughout my application. Was trying to upgrade to 1.2.6 and received ReferenceError: round is not defined. Other functions seem to be miss behaving also.

Nothing changed other than the version increment change, my script load order is the same.

n = 1599055.556689

numeric.abs(n)
ReferenceError: abs is not defined
numeric.round(n)
ReferenceError: round is not defined
numeric.version
"1.2.6"

Thanks for your time and effort

Numeric can not find a particular solution

The library is unable to find solution to equation system:
[[-0.8,0.4,0.3],[0.4,-0.8,0.3],[0.4,0.4,-0.6]] [[x1][x2][x3]] = [[0],[0],[0]].
The system has solutions: {x1 = 0.75r, x2 = 0.75r, x3 = r}

Automatic differentiation

Should this be implemented using an AD object? Can this AD object handle linear algebra? How much of it is orthogonal to numeric?

numeric.T.exp does not work

Receive the following error when attempting to use the "exp" function on a complex array:

a = numeric.fft(0,1)
{x: 0, y: 1}
a.exp()
ReferenceError: exp is not defined
at Object.eval [as exp](eval at %28/Users/foo/math/node_modules/numeric/numeric-1.2.6.js:746:26%29, :2:34)
at eval (eval at Tunop (/Users/foo/projects/math/node_modules/numeric/numeric-1.2.6.js:1101:12), :3:18)
at repl:1:2
at REPLServer.self.eval (repl.js:110:21)
at Interface. (repl.js:239:12)
at Interface.EventEmitter.emit (events.js:95:17)
at Interface._onLine (readline.js:202:10)
at Interface. (readline.js:322:12)
at Array.forEach (native)
at Interface._normalWrite (readline.js:321:11)

numeric.xxxeq() on typed arrays

Can the numeric.xxxeq() functions be made to work on typed arrays? In many cases these functions don't need to allocate anything.

Internal error on eigenvalues of zero matrices.

I noticed some errors on computing the eigenvalues of zero matrices (matrices consisting of all zeros).

Test definitions:

IN> numeric.eig([0]) 
OUT> {lambda: {x: [0], y: [0]},
      E: {x: [1], y: [0]}}
IN> numeric.eig([[0, 0], [0, 0]]) 
OUT> {lambda: {x: [0, 0], y: [0, 0]}, 
      E: {x: [[1, 0], [0, 1]],
          y: [[0, 0], [0, 0]] }}
IN> numeric.eig([[0, 0, 0], [0, 0, 0], [0, 0, 0]]) 
OUT> {lambda: {x: [0, 0, 0], y: [0, 0, 0]}, 
      E: {x: [[1, 0, 0], [0, 1, 0], [0, 0, 1]],
          y: [[0, 0, 0], [0, 0, 0], [0, 0, 0]] }}

Results:

132 FAIL numeric.eig([0])==>Error:numeric:toUpperHessenberg()onlyworksonsquarematrices!=={lambda:{x:[0],y:[0]},E:{x:[1],y:[0]}}
133 FAIL numeric.eig([[0,0],[0,0]])==>{lambda:{x:[0,0],y:},E:{x:[[1,1],[0,0]],y:}}!=={lambda:{x:[0,0],y:[0,0]},E:{x:[[1,0],[0,1]],y:[[0,0],[0,0]]}}
134 FAIL numeric.eig([[0,0,0],[0,0,0],[0,0,0]])==>Error:eig:internalerror!=={lambda:{x:[0,0,0],y:[0,0,0]},E:{x:[[1,0,0],[0,1,0],[0,0,1]],y:[[0,0,0],[0,0,0],[0,0,0]]}}

The size 1 case is degenerate, but should still work. The size 2 case correctly identifies the eigenvalues as zero (multiplicity 2) but doesn't choose eigenvalues to span the space. The size 3 case fails on an error in the house function. All cases could probably be handled by checking if the matrix is a zero matrix and then just returning zeros as the eigenvalues and the identity matrix as the eigenvector generator.

Add numeric.toMathml() method

Have you considered adding a method like numeric.prettyPrint(), but to output numbers, vectors and matrices (including sparse matrices) in mathml? I think this would be nice for working in Workshop.

If you are concerned about browser support for mathml, you could consider pointing people to http://www.mathjax.org/

Problem? with numeric.inv()

Hello, I am new to both JavaScript and Numeric.js, so I hope this is a relevant question.

I have the 10x10 matrix

A = [[0.42905681456828765, 0, 0, 0, 0, 1, 0, 1, 1, 0],
[-0.9032775043542898, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, -0.612571665435814, 0.3803746509932104, 0, 1, -1, 0, 0, 0, 0],
[0, -0.7904150521752438, -0.9248324847678057, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, -1, -0.6277524511897817, 0, 0, 0, 0, 1],
[0, 0, 0, 0, -0.7784130394753294, 0, 0, 0, 0, 0],
[0, 0, -0.3803746509932104, 0.6277524511897817, 0, 0, -0.9996144206527183, 0, 0, 0],
[0, 0, 0.9248324847678057, 0.7784130394753294, 0, 0, 0.027767067240353285, 0, 0, 0],
[-0.42905681456828765, 0.612571665435814, 0, 0, 0, 0, 0.9996144206527183, 0, 0, 0],
[0.9032775043542898, 0.7904150521752438, 0, 0, 0, 0, -0.027767067240353285, 0, 0, 0]]

that I wish to invert, but when I call

Ainv = numeric.inv(A)

I receive an error like this:
Uncaught TypeError: Cannot read property '9' of undefined numeric
inv numeric-1.2.6. js:806
(anonymous function)

I am not certain that A is invertible, but for other certainly not invertible matrices I don't get this error. Is this a bug or something I am doing wrong?

Thanks,
Corbin

[enhancement] Add missing bower.json.

Hey, maintainer(s) of sloisel/numeric!

We at VersionEye are working hard to keep up the quality of the bower's registry.

We just finished our initial analysis of the quality of the Bower.io registry:

7530 - registered packages, 224 of them doesnt exists anymore;

We analysed 7306 existing packages and 1070 of them don't have bower.json on the master branch ( that's where a Bower client pulls a data ).

Sadly, your library sloisel/numeric is one of them.

Can you spare 15 minutes to help us to make Bower better?

Just add a new file bower.json and change attributes.

{
  "name": "sloisel/numeric",
  "version": "1.0.0",
  "main": "path/to/main.css",
  "description": "please add it",
  "license": "Eclipse",
  "ignore": [
    ".jshintrc",
    "**/*.txt"
  ],
  "dependencies": {
    "<dependency_name>": "<semantic_version>",
    "<dependency_name>": "<Local_folder>",
    "<dependency_name>": "<package>"
  },
  "devDependencies": {
    "<test-framework-name>": "<version>"
  }
}

Read more about bower.json on the official spefication and nodejs semver library has great examples of proper versioning.

NB! Please validate your bower.json with jsonlint before commiting your updates.

Thank you!

Timo,
twitter: @versioneye
email: [email protected]
VersionEye - no more legacy software!

Found a test case where numeric.svd returns an incorrect decomposition

//tested with numeric.js version 1.2.6

var countsMatrix = [[0,0,1,1,0,0,0,0,0],[0,0,0,0,0,1,0,0,1],[0,1,0,0,0,0,0,1,0],[0,0,0,0,0,0,1,0,1],[1,0,0,0,0,1,0,0,0],[1,1,1,1,1,1,1,1,1],[1,0,1,0,0,0,0,0,0],[0,0,0,0,0,0,1,0,1],[0,0,0,0,0,2,0,0,1],[1,0,1,0,0,0,0,1,0],[0,0,0,1,1,0,0,0,0]];

var svd = numeric.svd(countsMatrix);

var U = svd.U;
var UTranspose = numeric.transpose(U);

//U should be a unitary matrix, so transpose(U) * U should be the identity matrix:
//http://web.mit.edu/be.400/www/SVD/Singular_Value_Decomposition.htm

var shouldBeIdentity = numeric['*'](UTranspose, U);
//However, it isn't the identity matrix:
console.log(JSON.stringify(shouldBeIdentity));

numeric.ones & numeric.zeros

In matlab, numpy and many other linalg packages, there is a convenient constructor for a matrix of zeros or ones.

I understand these implementations are rather trivial given that rep is around but they are pretty convenient to have around for familiarity's sake with other packages.

numeric.ones = function identity(n) { return numeric.rep(n,1);}

numeric.zeros = function identity(n) {return numeric.rep(n,0);}

SVD to compute the k largest singular values

It would be useful to have the functionality to only return the k largest singular values when numeric.svd() is called.

Example: add a parameter the the svd function:
numeric.svd(A,k) where A is the matrix and k is number of singular values to compute.

node.js support

It would be nice, if numeric.js would have node.js support (require-style loading and npm package). I don't think it's a big deal, because it's browser-independent.

Least square solution

I wasn't sure where else to post this question. It's not technically a bug but more a missing feature.

I'm porting some code I originally wrote in python/numpy, into javascript/numeric.

I'm finding numeric very good so far, but I know need to find the least square solution for a non square matrix. In numpy this is achieved with numpy.linalg.lstsq, but there's no direct equivalent I could find in numeric.

Could you possibly offer me a short way of achieving this using numeric? I'm aware I can write my own least square solver, but as it's a common problem I thought maybe there's a way that I hadn't noticed by reading through the documentation.

Thank you for taking the time to help me.

Weighted Linear Regression

Hi Sébastien

I'm trying to find a javascript library for doing weighted linear regression, but so far haven't had any luck. Do you know where I could find a solution by any chance?

Thanks

Marcus

Numeric triggers many syntax warnings in Firefox 40

Firefox 40 is currently the alpha/aurora/developer edition release. Loading numeric prints many warnings to the console of the form

SyntaxError: unreachable code after return statement numeric-1.2.6.js:3:54
SyntaxError: unreachable code after return statement numeric-1.2.6.js:5:26
SyntaxError: unreachable code after return statement numeric-1.2.6.js:3:51
SyntaxError: unreachable code after return statement numeric-1.2.6.js:5:31
SyntaxError: unreachable code after return statement numeric-1.2.6.js:3:69
SyntaxError: unreachable code after return statement numeric-1.2.6.js:3:52
SyntaxError: unreachable code after return statement numeric-1.2.6.js:3:86
SyntaxError: unreachable code after return statement numeric-1.2.6.js:5:39
SyntaxError: unreachable code after return statement numeric-1.2.6.js:4:47
SyntaxError: unreachable code after return statement numeric-1.2.6.js:6:39
SyntaxError: unreachable code after return statement numeric-1.2.6.js:4:32

Here's a jsbin that does nothing but include Numeric—you can open it in firefox 40 and check the console.

http://output.jsbin.com/qubolo

These are unfortunately not very easy to debug, because the line and column numbers appear to refer to generated code rather than the actual source of numeric.

Constrained optimization

How to implement constrained optimization?

  • Which algorithm to use? Barrier method?
  • How much derivative information is needed for constraint function(s)? How to pass constraint function(s)? Is it an Array of functions, or a function returning an Array? (Latter case: is the gradient a Jacobian? Will it need an order 3 Hessian as well? Does not seem reasonable since the penalty function ends up being scalar-valued.)
  • How competitive should it be compared to numeric.solveLP, when used on a linear program?
  • What is a suitable battery of tests for this? This is important, untested optimization programs usually don't work.

Systematic benchmarking tool

I need a systematic benchmarking tool that I can run using d8 and node to compare two versions of numeric. I need to make sure that every function in numeric is benchmarked and that statistical "hypothesis testing" is used to prove which version of the library is faster, with p-values and everything. This needs to run fast enough for me to use regularly before I release new versions.

Reevaluate dopri for different events

I am trying to bin an intergration. So I have some complicated function that needs to be calulated effeciently. I run dopri on it to some big t. Now I need to slice it according to bins in small delta x. So that would be lots of tiny steps (small t). It seems ineffecient making thousands of tiny dopri stopping criterion. Rather, I would like to use the existing big solution to step from a point, to another based on a criteria. Something like sol.step(<start t>, <criteria>) => [t, x]. Can I do this already? Am I too dense to figure it out?

http://www.numericjs.com/ not responding

http://www.numericjs.com/ is not responding

Host does not appear to be up:

$ ping www.numericjs.com
PING numericjs.com (50.16.208.142): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
^C
--- numericjs.com ping statistics ---
4 packets transmitted, 0 packets received, 100.0% packet loss

Linear solve (Ax = b) support?

I noticed that numeric currently doesn't have a general linear solver (kind of like MATLAB's backslash operator). There is a cLU function, but it seems like that only takes matrices with up to 3 rows.

Is there any plan on supporting this? If there is, I've implemented a non-optimized version of LU factorization with pivoting for square matrices, which is a step in that direction.

numeric.T.eig looks suspicious

The numeric.T.eig function, as implemented in 610f250, looks suspicious: either it's an instance method, then it belongs into numeric.T.prototype.eig. But in that case I don't understand its semantics, since you can't reasonably compute eigenvalues of a single complex number. Or it's a class method, then it should not refer to this. And to make sense semantically, it should probably also take a complex-valued matrix as an argument. I see noone using this function at all, so unless there is actually a use case for this, you might also consider deleting it.

Add commands to workshop to access history of previous statements and results

I am only suggesting adding this to workshop and not numeric.js itself. I would like to be able to access the last statement or second last statement etc, without copy/paste in browser.

For example, maybe pressing the up/down keys would allow me to move through the history of previous statements so that I can execute them again, or edit them before executing them.

Another notation for referencing previous results would be nice too... but this would involve writing a parser (perhaps with http://pegjs.majda.cz/) or a simple substitution with a regex, that pre-processes a statement and substitutes prior results. For example !! could refer to the last result, !n could refer to statement from line n, and !-n could refer to the last nth statement.

Accessing prior results is not as important to me... but I think navigating prior statements would be useful.

nodejs support

Hello,
Is there any support for node.js in the current release. If not is it in the project roadmap?

Cheers,
Subho.

Test numeric.uncmin()

Implement many more of the benchmarks for numeric.uncmin() from Moré et al. (1981). These benchmarks were really important to get uncmin() to actually work, and I have the feeling that if more of them are implemented it will point to some shortcomings in uncmin().

Problems solving Ax=b

Hello there,

I am relatively new to linear algebra, but I think I may have spotted a bug. When using numeric.solve(A, b), it appears b can only be a column vector. Should it not also be allowed to be a rectangular matrix?

For instance:

A is 3x3 matrix
b is 3x1 vector
numeric.solve(A, b) returns the expected x vector

But:

A = 3x3 matrix
b = 3x2 matrix
numeric.solve(A, b) returns vector of NaN.

While one could just use numeric.dot(numeric.inv(A), b) to get the same result, I feel it should be part of the solve function. My apologies if I am incorrect here, I just thought it was worth mentioning.

Thanks for reading,
Richard.

QPsolve failure case

The following input to qpsolve:

Dmat:
[13,18,-6]
[18,27,-9]
[-6,-9,4]
dvec:
[-4,0,-100]
Amat:
[0]
[0]
[-1]
bvec:
[-25]

produces the solution vector:

[21:56:14.131] x:-3.999999999999967 y:-30.666666666666707 z:-100.00000000000006

which is incorrect as best I can ascertain. The problem above was arrived at by summing the energy

(2x + 3y - z)^2 + (x-4)^2 + (z-100)^2

with the additional constraint that

z <= 25

From that description it is clear that the answer should be x=4, z=25, and y set appropriately to zero out the first energy term

Test numeric.solveLP()

Test numeric.solveLP() against standard test problems. Right now, it's only tested against randomly generated L1 norm minimization problems.

The "column compressed" sparse matrices are actually "row compressed"

Not really an implementation issue, but really a question of terminology. According to wikipedia:

"...CSR is (val, col_ind, row_ptr), where val is an array of the (left-to-right, then top-to-bottom) non-zero values of the matrix; col_ind is the column indices corresponding to the values; and, row_ptr is the list of value indexes where each row starts"

Which is basically what numeric.js does (which makes sense, since it improves the speed of right hand vector multiplies). CSC is actually the transpose of this format.

Bug in 'numeric.inv()'

Computing
"numeric.inv([[8,9,8,9], [5,6,5,6], [8,9,8,9], [5,6,5,6]]);"
results in an error:
"TypeError: Aj is undefined"

More example applications

Example applications: I have small toy demos in the workshop but if there are larger applications outside the workshop, it would be nice to link to them.

Typed array matrices

How is a typed array matrix specified? Is it an Array of typed Arrays? Or is it a single flat typed array? Is it reasonable to take a flat Float64Array A which represents a matrix and create one Float64Array view per row of A? Can numeric.dot() be made to handle such Array[Float64Array] matrices? Would it be useful to have "flat" versions of numeric.dot()? What about numeric.svd() and numeric.eig()?

numeric.dopri

Integrator does not allow for backward propagation (x1 < x0)

Issue with numeric.echelonize

Hello, I want to say first of all what a nice library I think numeric is.

I am using numeric.echelonize and am running into a little problem.

numeric.echelonize([[1,2],[0,0]])

This returns:

{ I: [ [ Infinity, -Infinity ], [ -Infinity, Infinity ] ],
  A: [ [ NaN, NaN ], [ NaN, NaN ] ],
  P: [ 1, 0 ]
}

Looking at the code this seems to be due to divide-by-zero inside diveq.

I may be misunderstanding this function since I don't see documentation for it, but from its name my guess is that it is supposed to be calculating echelon form. In that case I would expect numeric.echelonize([[1,2],[0,0]]) to return numbers instead of Infinity and NaN for I (pseudoinverse?) and A (echelonized matrix?).

Bug in numeric.eig()

numeric.eig() on the identity returns funny results. This is because the handling of multiple eigenvalues is sort of weird right now. This is a bug and it should be fixed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.