Does Go have multidimensional arrays/slices at all, or these are just lists of lists? I mean, lf I have a slice a[][]float64, pointing to an underlying array a0[3][4]float64, will it be a continuous memory, in say row-major order, like in C, or an [3] array of pointers to [4]float64 arrays like in Java?
Next question, is there a way to ravel/resize arrays/slices the way Python's Numpy does? Basicallym I want to be able to make a[x][y] to be aflat[x*y], and vice versa.
How does one get dimensions of a multi-dimensional slice? Simple len(a) returns only first dimension. How does one determine how many are there, and their values?
Next question, is there a way to ravel/resize arrays/slices the way Python's Numpy does? Basicallym I want to be able to make a[x][y] to be aflat[x*y], and vice versa.
On Wed, Dec 19, 2012 at 1:35 AM, Ali Ali <alj...@gmail.com> wrote:Does Go have multidimensional arrays/slices at all, or these are just lists of lists? I mean, lf I have a slice a[][]float64, pointing to an underlying array a0[3][4]float64, will it be a continuous memory, in say row-major order, like in C, or an [3] array of pointers to [4]float64 arrays like in Java?
it seems you confused array with slice in Go's sense.
Next question, is there a way to ravel/resize arrays/slices the way Python's Numpy does? Basicallym I want to be able to make a[x][y] to be aflat[x*y], and vice versa.no, you can't. are you sure you want to multiply the two indices?
Of course I meant dimensions, not indexes. But so far it seems that the answer is "No, Go doesnt have multidimentional arrays (called slices) but has lists of lists like Java" . Which is kind of, limiting.
On Tuesday, December 18, 2012 11:43:57 AM UTC-6, minux wrote:On Wed, Dec 19, 2012 at 1:35 AM, Ali Ali <alj...@gmail.com> wrote:
Does Go have multidimensional arrays/slices at all, or these are just lists of lists? I mean, lf I have a slice a[][]float64, pointing to an underlying array a0[3][4]float64, will it be a continuous memory, in say row-major order, like in C, or an [3] array of pointers to [4]float64 arrays like in Java?
it seems you confused array with slice in Go's sense.
It suddenly seems that Go's design has a confusing implications for multidimension arrays/slices. Which are not clearly thought about or documented.
Next question, is there a way to ravel/resize arrays/slices the way Python's Numpy does? Basicallym I want to be able to make a[x][y] to be aflat[x*y], and vice versa.no, you can't. are you sure you want to multiply the two indices?
I am sure that I want to multiply two dimensions, not indexes.
On Wed, Dec 19, 2012 at 1:35 AM, Ali Ali <alj...@gmail.com> wrote:Does Go have multidimensional arrays/slices at all, or these are just lists of lists? I mean, lf I have a slice a[][]float64, pointing to an underlying array a0[3][4]float64, will it be a continuous memory, in say row-major order, like in C, or an [3] array of pointers to [4]float64 arrays like in Java?
it seems you confused array with slice in Go's sense.
http://play.golang.org/p/sSFonPTvxl
Maybe you can do what NumPy does, which is a flat array and a flexible indexing scheme (stride ...)