Is there any progress on multidimensional arrays for Go? Not
arrays of arrays, but real multidimensional arrays and slices
as part of the language.
John Nagle
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
The general idea is to support at least the basics:
var arr [4,4]float64;
I cannot agree with this point of view. IMO it represents a valid opinion, but not the state of the affairs. Sorry.
-j
right. but, at least if we were to follow python's lead, the advantage
is that you can then have multiple views of that piece of memory, w/o
having to copy anything.
[Replying to the list]
On 28 Aug 2013 01:50, "John Nagle" <na...@animats.com> wrote:
> It looks like Go is dead in the water for number-crunching. If
> numerics had been taken seriously in the design phase, it might have
> been different. But Go has clearly been rejected by the numerical
> community. It's too late for this language. Sorry.
The original subject of your mail is "It's time." But now you say it is too late? Please stop wasting everyone's time with this nonsense. We all have better things to do.
Andrew
Hi Brendan,
It's not too late for backward-compatible language changes, or additions to the standard library. Such changes need to mesh well with the current state of things and the design goals of Go.
Not being a number crunching person myself, I'm in a poor position to suggest what form this should take. I suspect the authors of the various scientific computing packages would have thoughts about how the language could have helped them better solve their problems. Collecting those thoughts in a coherent document would be a good place to start.
Andrew
--
On 8/27/2013 1:03 PM, Jsor wrote:
> Arrays of arrays are contiguous, but not slices of slices.
That's true in C, and it's probably true in Go implementations,
but the language reference for Go does not guarantee it.
I'm sorry for trying to help you get the features you want into the language. I certainly won't do so again.
But since I *am* compelled to read golang-nuts — it is my mailing list, after all — I must ask you to please stop posting to this thread. You have sufficiently expressed your opinions.
Andrew
Perhaps that is inevitable, given that the designers don't have much
interest in number-crunching, and are quite protective of their
language. When one doesn't have much interest, one is unable to do a
really good job of evaluating proposals; one ends up either rejecting
too many of them or accepting too many of them. (Or, as a middle
ground, doing some of each.)
There's still a way to get stuff like multidimensional arrays into the
language, which is to demonstrate, by writing the code to add them to
the compiler, that it doesn't mess things up -- that it can be
implemented cleanly and with minimal adverse consequences.
That's
also a way to take oneself out of the category of mere supplicant who
should be told to "go tell it to the issue tracker", and into the
category of people worth having a conversation with.
In some circles
one just doesn't get respect unless one can write compiler code. (Not
that that attitude is really appropriate, but it's understandable.)
That's
also a way to take oneself out of the category of mere supplicant who
should be told to "go tell it to the issue tracker", and into the
category of people worth having a conversation with.Actually, the way to take oneself out of that category is to file the issue on the issue tracker (which still nobody has done yet, BTW). If you don't care enough about the feature to file a request for it, then why on earth would anyone take you seriously?!
On Wed, Aug 28, 2013 at 10:56:21AM +1000, Andrew Gerrand wrote:It was posted a while ago, and wasn't explicitly referenced in the
>On 28 August 2013 10:31, Norman Yarvin <yar...@yarchive.net> wrote:
>
>> Perhaps that is inevitable, given that the designers don't have much
>> interest in number-crunching, and are quite protective of their
>> language. When one doesn't have much interest, one is unable to do a
>> really good job of evaluating proposals; one ends up either rejecting
>> too many of them or accepting too many of them. (Or, as a middle
>> ground, doing some of each.)
>>
>
>There have been no proposals to evaluate.
current thread, but this is my idea of what multidimensional slices
would be like:
http://groups.google.com/group/golang-nuts/msg/2ba08fe85b97f441
>> There's still a way to get stuff like multidimensional arrays into theYeah, but what do you do when an idea has been discussed yet ignored
>> language, which is to demonstrate, by writing the code to add them to
>> the compiler, that it doesn't mess things up -- that it can be
>> implemented cleanly and with minimal adverse consequences.
>
>Please do not try to change the language by first implementing the language
>change. It will likely be a waste of your time.
>
>Earlier in this thread I described the right way to get features added to
>the language.
>
>Once a proposal has been circulated and generally considered a reasonable
>idea, then it makes sense to start hacking and explore the broader
>ramifications of the change.
by Go's designers? Putting it on the issue tracker isn't going to
change the level of interest of the Go team, and entries in the issue
tracker aren't any harder to ignore than posts are here -- that's what
"Status: WontFix" is for.
And if one actually writes the code, at least one can use it oneself
and share it with others who want it. The size of that audience then
can serve as an indication to the Go team of how much interest there
really is in the feature.
Having a discussion on golang-nuts is not the same as making a serious language proposal. That's what I was saying earlier in this thread.
Assessing all the angles on language changes takes much careful thought. Who would have time to consider all the feature proposals on this mailing list? We would never get anything done.
I repeat: the best way to have a feature seriously considered is to file an issue with a detailed proposal. Yes, it might get marked WontFix, but at least then you know where you stand.
Andrew
On Wed, Aug 28, 2013 at 12:07:12PM -0700, Kyle Lemons wrote:
>On Wed, Aug 28, 2013 at 11:56 AM, Norman Yarvin <yar...@yarchive.net> wrote:
>> It was posted a while ago, and wasn't explicitly referenced in theWell, it does talk somewhat about implementation, in that it specifies
>> current thread, but this is my idea of what multidimensional slices
>> would be like:
>>
>> http://groups.google.com/group/golang-nuts/msg/2ba08fe85b97f441
>
>
>Unfortunately that only proposes syntax, and it doesn't cover a lot of the
>questions that we'll have about the proposal and its implementation.
> That's why the suggestion was to create a doc to discuss it, so that it
>isn't strung out throughout a giant thread.
the data structure that would constitute a multidimensional slice. As
for questions, are there any particular ones that it raises in your
mind? My impression is that the implementation would be pretty
straightforward.
As for creating 'a doc', that sounds like something different from the
'filing an issue' that was suggested by others. In either case,
though, it's not clear what additional details might be called for.
You might look through the Fortran 90 spec/tutorials to have a look at their multidimensional array capabilities and simply list which of these you would need and why, as well as which you don't need, and why. That would be a great start. (Since Fortran 90 is implicitly a superset of "enough")
--
Do you think that some of developers would be interested in helping out with the proposal?
It seems to me that most people who are interested in multi-dimensional arrays want to use go as low-level substitute for languages like matlab or python/numpy. At least that is what I am looking for in go. But the problem we face is that we have little or no idea of language implementation.
Also it seems that the go team has a very good grasp of the problems that arise with software that comes with a large number of lines of code.
It would be really interesting to get the opinion of the people who designed go on the subject of introducing multi-dimensional arrays in go both as a language implementation task and the implications of introducing them in the language definition.
Actually, I think it would be very educational to get the opinion of go designers/developers on scientific programming in general. What are the benefits and drawbacks of using go for scientific computing and what do you think should/could change in order to make go a contender (next to matlab, python/numpy etc.) in that category?
--
On Wed, Aug 28, 2013 at 6:29 PM, gex <gexa...@gmail.com> wrote:
Do you think that some of developers would be interested in helping out with the proposal?
It seems to me that most people who are interested in multi-dimensional arrays want to use go as low-level substitute for languages like matlab or python/numpy. At least that is what I am looking for in go. But the problem we face is that we have little or no idea of language implementation.
I'm sure the community as a whole would love to dive in and provide suggestions once there's a coherent proposal on the table. In particular, you want to be able to describe the changes required to the spec to accommodate your proposal. The feedback you get from the community may well be "That's too many changes!" or "That's too difficult to understand." but if not, we'll be able to help think about how the low level implementation could be done and whether it's feasible, and how to tweak the proposal to make it feasible.
On Thu, Aug 29, 2013 at 12:37:17PM +1000, Andrew Gerrand wrote:They might have been intended to be rhetorical, but it's a pretty poor
>Norman,
>
>Your last couple of emails demonstrate that mailing lists are a poor
>medium mailing for doing this.
>
>I am sure that Kyle's questions were rhetorical in this case; his bigger
>point was that you don't have a complete proposal. Replying to his
>questions in this thread does not bring you closer to that point.
rhetorical device to ask questions that were already answered in the
document being questioned. As a way to demonstrate that a proposal
was incomplete, it rather accomplishes the reverse of what was
intended. (Not that I am trying to assert that the proposal is
complete, or that it even really reaches the level of being
describable as a "proposal"; the question as to what was lacking was
meant as a real question, and to be answered rhetorically is
disappointing.)
This would be a great provocation for discussion. What Go approach would allow [3,3] and [100,100] as an argument? Right now, only an interface. In Fortran, you'd have "invert(a(m,n), m, n)" where the dimensions come in as arguments. In go, you might come up with "invert(float64 a[int m, int n])" or perhaps "invert(float64 a[?][?])" where you could then do "len(a[0])" and "len(a[1])" or have len return a slice of cardinalities so "len(a)[0]" and "len(a)[1]"group resolution: "We need subroutines that work for arrays of various sizes" (clearly! For example, a float64 matrix inversion routine that works for N x N arrays of any N >= 1.)
Your tone makes it sound critical, but there isn't even an issue on
the tracker about this as far as I can detect. Please add an issue so
it's on our radar.
-rob
Is there any progress on multidimensional arrays for Go? Not
arrays of arrays, but real multidimensional arrays and slices
as part of the language.
This has been discussed in the number-crunching community,
back to 2009. The arguments for language level multidimensional
arrays are:
1) Multiple packages with different array representations result in
a huge headache when the same program pulls in multiple packages.
Conversion code has to be written and called. This is a headache
in Python, C, and C++, but not FORTRAN or Matlab. This is one
of the reasons so much number crunching still takes place in
FORTRAN and Matlab. It's more compatible if there's one way to
do it, built into the language.
Go is currently headed towards a diverse set of representations:
Compare:
https://github.com/Jragonmiris/mathgl/blob/master/matrixd.go
https://github.com/skelterjohn/go.matrix
https://github.com/eadf/math3d/blob/master/math3d64/matrix3.go
https://github.com/spate/vectormath/blob/master/mat_aos.go
each of which represents 2D matrices in its own way. Code
built on top of those libraries will not interoperate properly.
This discourages the use of Go for numeric work.
2) All the subscript checking for FOR loops can be lifted out
of inner loops. Performance can reach or exceed the levels
of languages that don't have subscript checking. Also, if
you allocate a real multidimensional array as one allocation,
it's contiguous for caching purposes. Not so an array of arrays.
John Nagle
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
It looks like Go is dead in the water for number-crunching. If
numerics had been taken seriously in the design phase, it might have
been different. But Go has clearly been rejected by the numerical
community. It's too late for this language. Sorry.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
At the language level, dense matrices are probably enough. Sparse
matrix representations are complex and problem-dependent, and more
suited to a library.
The main argument for slices is that standard math libraries work on
arrays of different sizes. You don't want to have a different copy
of "invert matrix" for each array size. In Go, slicing is tied to
passing a variable-sized array as a parameter. We need the latter,
and are thus forced to support the former.
My 2 cent,since there is still not a well defined proposal, and a lot of emails and documents have been spent, why not start again smaller.I read some of the discussions and documents and the impression that I got from them is: let's try to include all the features we can think of.Would someone be interested in a much smaller proposal?
[...]
Does this make any sense at all? Am I barking mad?
If we have a multidimensional slice representation
which has the same representation as at present for
1D arrays and has a length and stride for each higher
dimension, that implicitly defines what subarray
and reslice operations are possible. That
means "arr[n,:]" is OK and returns a 1D slice,
but "arr[:,n]" is not allowed.
Operator overloading is controversial. Numpy uses a
> Everything else goes into some package. I.e. no operator
> overloading for multidimensional data but a package matrix
> with matrix.Add.
>
> This is also a smaller proposal with slightly different focus
> than yours (higher dimensions, less operator overloading).
"dot()" function for matrix multiply. "*" is an element by element
multiply. One argument for matrix multiply at the language level
is that it is both very common, and very optimizable when you have
size information available. What's thinking about this from
the implementers?
John Nagle
I would be really disappointed if we had an implementation that couldn't stride the densest dimension. The final stride should be able to be optimized away in some cases.
--
I'm interested to know what the use cases would be for appending to a multidimensional slice. I feel that capacity in a regular slice is a beneficial and simple artifact of the most sensible slice implementation. Capacity in a multidimensional slice is not simple, and for the typical use-cases of nd-slices that I can think of (e.g. matrix math), appending wouldn't even be useful. Reallocation would have comparatively bizarre semantics, since the shape of the new backing array would often be very distinct from the shape of the original backing array. Take for example:
m0 := [3,3]int{{1,2,3},{4,5,6},{7,8,9}}m1 := m0[:, 1:2] // produces [,]int{{2}, {5}, {8}}m1 = append(m1, [1,1]int{11}) // er, how do we even specify this?would, from a sensible implementation perspective, result in a new backing array of [4,1]int, rather than what some people, viewing it from a sensible semantic perspective, would expect to be a backing array of [4,3]int. The semantic perspective would be useful since you could immediately perform a single column append to m1 without triggering a second reallocation, based on the assumption that you have the space for it if, semantically, the shape were maintained in as many dimensions as possible when any shape changing operation occurred -- if you did the column append before the row append, it'd certainly work from either perspective in this example, since only the row append in this case would then result in the reallocation.Speaking of column appends (and other appends of lower dimensional data), what would the append expression for that look like?The copy builtin implementation would have to gain odd semantics as well, since the behavior for normal slices will never panic, but what if you're trying to copy from a [15]int into a [4,4]int? Or a [17]int into a [4,4]int?
On Wednesday, September 4, 2013 6:26:35 PM UTC-6, kortschak wrote:Yes, you really want an ndslice being defined as something like:
struct {
data *T
cap int
dims [n]int
strides [n]int
}
where prod(dims) and prod(strides) <= cap and n is the dimensionality of
the ndslice, coming from a [m][o][p]...nT (which is already part of the
language).
Just having that would make much of the rest of the desires relatively
easy to implement in libraries and would give a significant performance
boost on ranging over 2nd and subsequent dimensions (I really don't see
adding all the operators to types like this as being a good thing).
Dan
On Wed, 2013-09-04 at 16:03 -0700, Kyle Lemons wrote:
> I would be really disappointed if we had an implementation that
> couldn't stride the densest dimension. The final stride should be
> able to be optimized away in some cases.
I wouldn't allow appends. While we call them slices here, I think they would rightly have a better name (matrix view?) because they're actually rather different.
I'd similarly only allow copying between slices with identical dimensions.
I'm not convinced an append is meaningful here, but that doesn't
preclude the inclusion of a cap. It would take the implementation
towards something like what slices were before append was added; it
would allow resizing by reslicing (reshaping?) but the details would be
left up to the user.
I think it's O(kN) in all cases, but k is a lot smaller when both input and output are contiguous and thus can be memcpy'd, right?
copy([3e10,1]int{}[:], [3e10,3e10]int{}[:,0:1])
On Wed, 2013-09-04 at 18:56 -0700, Kevin Gillette wrote:
> Unlike slices of slices, it would seem reasonable that there is no
> intermediate level element type -- you specify [2,2]int{1,2,3,4}
> instead of [2,2]int{{1,2},{3,4}}.
I think this would be a bad idea for safety.
len() returns an int though. Either a new builtin or a variadic len().
len([3,2]int, 0) // returns 3
len([3,2]int, 1) // returns 2
my vague idea would be for a dim() builtin that returns a [...]int, so that dim(a)[0] can be compile-time bounds-checked
Quite the contrary. The compiler must know the number of dimensions in the type, so the type of the array (eg [4]int) returned by dim(a) is known at compile time. The contents, of course, are only known at runtime and thus the == cannot be compiled out, but arrays are comparable so that statement is not only valid but probably incredibly useful.