Why do C# multidimensional arrays not implement IEnumerable?

The CLR has two different kinds of arrays: vectors which are guaranteed to be one-dimensional with a lower bound of 0, and more general arrays which can have non-zero bounds and a rank other than 0. From section 8.9.1 of the CLI spec: Additionally, a created vector with element type T, implements the interface System.Collections.Generic.IList<U> … Read more

Why is numpy’s einsum faster than numpy’s built in functions?

First off, there’s been a lot of past discussion about this on the numpy list. For example, see: http://numpy-discussion.10968.n7.nabble.com/poor-performance-of-sum-with-sub-machine-word-integer-types-td41.html http://numpy-discussion.10968.n7.nabble.com/odd-performance-of-sum-td3332.html Some of boils down to the fact that einsum is new, and is presumably trying to be better about cache alignment and other memory access issues, while many of the older numpy functions focus on … Read more

Get first element in PHP stdObject

Both array() and the stdClass objects can be accessed using the current() key() next() prev() reset() end() functions. So, if your object looks like object(stdClass)#19 (3) { [0]=> object(stdClass)#20 (22) { [“id”]=> string(1) “123” etc… Then you can just do; $id = reset($obj)->id; //Gets the ‘id’ attr of the first entry in the object If … Read more

Initialising a multidimensional array in Java

Java doesn’t have “true” multidimensional arrays. For example, arr[i][j][k] is equivalent to ((arr[i])[j])[k]. In other words, arr is simply an array, of arrays, of arrays. So, if you know how arrays work, you know how multidimensional arrays work! Declaration: int[][][] threeDimArr = new int[4][5][6]; or, with initialization: int[][][] threeDimArr = { { { 1, 2 … Read more

numpy-like package for node [closed]

No, there are no technical reasons why a numpy-like package does not exist for Node.js and, more generally, JavaScript. There are two main obstacles preventing Node.js and JavaScript from achieving more mind share in the data science and numeric computing communities. The first obstacle is community. While the JavaScript community is huge, the subset of … Read more