5

Do any browsers currently support or plan to support fast array math operations, similar to what NumPy provides for Python? Here is an example to demonstrate what I mean:

var a = new NumericArray('uint32', [1, 2, 3, 4]);
var b = new NumericArray('uint32', [2, 2, 2, 2]);
var c = a.add(b); // c == [3, 4, 5, 6]

In that example, add is not meant to represent a function implemented in JavaScript. That would be trivial to write. It is meant to represent a function that is written in C (or whatever language the JavaScript implementation is written in) and is optimized specifically for math operations over the array.

1
  • Javascript is a standard, so you really should be asking if the next javascript standard is going to support this functionality. Commented Jun 25, 2010 at 21:33

3 Answers 3

2

I don't think so, but Google are certainly interested in pushing the limits of what is possible in Javascript. If you are interested in safely running native code in the browser you might want to take a look at NaCl.

Sign up to request clarification or add additional context in comments.

1 Comment

That looks very interesting. I'll have to play around with that a bit.
1

I'm the original poster, but I figured I'd share something I ran across. WebGL (implementations are already in progress by Mozilla and WebKit, see Lesson 0 at learningwebgl.com) introduces something called "Typed Arrays", which is sort of what I was looking for. The specification is available at https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/doc/spec/TypedArray-spec.html.

Comments

0

You can use use the built-in JavaScript array.map method

var numbers = [1, 4, 9];
var roots = numbers.map(Math.sqrt);
// roots is now [1, 2, 3], numbers is still [1, 4, 9]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.