Talk:Array programming
This is the talk page for discussing improvements to the Array programming article. This is not a forum for general discussion of the article's subject. |
Article policies
|
Find sources: Google (books · news · scholar · free images · WP refs) · FENS · JSTOR · TWL |
This article is rated C-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | ||||||||||||||||||||||||||||
|
What makes array programming array programming?
[edit]The overview gives the example of operators functioning as expected when applied to arrays as the characteristic of array programming languages. C++ can do this too, but it's not listed as an array language, so I deduce that there's rather more to the paradigm than the operations on arrays that the article mentions. Might it be worth covering this, maybe by expanding the overview to mention things C++ can't do?
- Turing says C++ can do everything another lanuaguage can do. But I do understand your question, as I was about to ask the same on the talk page. What feature does this paradigm offer, aside from syntactic sugar, which can be mimicked with operator overloading? Also, sign talk page posts! --Wouter Lievens 13:09, 25 May 2005 (UTC)
- C++ can certainly emulate the array paradigm -- but it does not by default. A set of C++ classes to do automatic threading/looping could be called an "array programming extension" to the language. The key element of the array paradigm seems to be the inclusion of vector space and/or ring concepts in the supported data types. --zowie 4 July 2005 17:39 (UTC)
The phrase "Jack of all trades, master of none" comes to mind.
Although operator overloading gets you at least part of that sweetened syntax we all crave, today's C++ compilers have a long way to go in producing anything approaching truly efficient array code. Mostly there is no loop fusion.
Consider something like
r = sum(a + b * c + d)
where everything is a "vector" of numbers. Let's not worry about data type for now. The unoptimized code from an object oriented solution would probably resemble the following:
t1 = b * c // these would all be separate loops t2 = a + t1 t3 = t2 + d r = sum(t3)
Loop fusion might have got us one loop to combine t1, t2, and t3. But for an OO compiler, sum() is nothing more than a function - here, match the overload which has a vector argument and returns a scalar. However, an array compiler would see that sum is a rank-reducing operation and could compile appropriately.
Problem is that we have done a fair amount of very costly memory allocation to store temporary results. True, depending on the datatypes involved, we could free and reuse temporaries. But the problem is that we should not have to do any of this at all.
A more array-oriented compiler might produce something more like this:
r = 0 do i = 1 to length(a) r = r + (a[i] + b[i] * c[i] + d[i]) // look ma no memory allocation next i
Looping and branching are also not exactly free, though better value than excess temporary allocation and usage.
If you know how long the argument is, say it's 8, you can eliminate the do loop and unroll the loop. Even if you don't know, you can still get away with unrolling blocks of the loop.
r = (a[1] + b[1] * c[1] + d[1]) r = r + (a[2] + b[2] * c[2] + d[2]) ... r = r + (a[8] + b[8] * c[8] + d[8])
We could do better. Considering that most of the CPUs out there are Pentiums and up, equipped with MMX, SSE, and all sort of other acronmyms which mean that the chip can do some arithmetic operations 2, 4, or 8 operands at a time, it may be possible to do this operation in groups of, let's say four 16-bit quantities.
r = 0 do i = 1 to length(a) by 4 // edge condition conveniently ignored r = r + sum4(a[i + 0 1 2 3] + b[i + 0 1 2 3] * c[i + 0 1 2 3] + d[i + 0 1 2 3]) next i
Then we can combine the two approaches
r = 0 do i = 1 to length(a) by 16 // edge condition conveniently ignored r = r + sum4(a[i + 0 1 2 3] + b[i + 0 1 2 3] * c[i + 0 1 2 3] + d[i + 0 1 2 3]) r = r + sum4(a[i + 4 5 6 7] + b[i + 4 5 6 7] * c[i + 4 5 6 7] + d[i + 4 5 6 7]) ... r = r + sum4(a[i + 12 13 14 15] + b[i + 12 13 14 15] * c[i + 12 13 14 15] + d[i + 12 13 14 15]) next i
This is just the tip of the iceberg as to what a compiled array language could be reasonably expected to do. This description is further oriented toward a specific class of machine - mostly scalar with a little bit of 4-element at a time vector math thrown in, for marketing reasons. Also well known was the IBM 3090 Vector Processor. Released in the mid to late 1980s, it at least momentarily popularized Vectorized Fortran and APL.
Object orientation supplies a very generalized form of problem solving where arrays in an OO context are merely containers of some kind. Arrays are more a function of what the hardware has to offer and the host language's ability to formulate these sorts of problems succintly. In a sense, an array is more like a base type.
--Cowznofski 17 Dec 2006
- Thank's Cowznofski, that's a very nice description. Maybe you polish it a bit and and and == Array programming vs Operator Overloading == chapter. I think it would be appropriate as anyone coming from an language with operator overloading (note that there are languages which are not OO which still offer operator overloading) would ask. --Krischik T 10:51, 15 June 2009 (UTC)
Function Rank
[edit]I expanded the section on function rank to give some examples; also removed the point that it is a "recently discovered concept" -- function rank (by analogy to operator rank) goes back to the days of APL, and is frequently rediscovered by development teams on different array languages. Also added a few more current examples (I know, there's a comperehensive list in the category listing; but it's nice to have an indicator of the richness of the field). --zowie 4 July 2005 17:39 (UTC)
Self-reference
[edit]The link to Category:Array programming languages is inappropriate. Perhaps someone could write a list article and include the names in that? Wikipedia is supposed to keep self-references to a minimum, and certainly providing a link to text in Wikipedia (non-article) space is a big no-no in the main body of an article. See WP:SELF. Zyxoas (talk to me - I'll listen) 16:15, 11 June 2006 (UTC)
- Yup, a nice little argument for why list articles should be kept... but then others say list articles shouldn't exist!! lol Ah well, such is life/wikipedia. Mathmo Talk 02:43, 11 September 2007 (UTC)
Why this topic is so low classified?
[edit]I read the low classification scores of this page and I was completely surprised. Array programming could be described as one of the essential achievements in artificial programming languages. If you look to the number of applications, this should appear pretty clear (e.g. scientific modeling with Matlab, R or GNU Octave). Not to mention the influence of APL in tens of major languages. Scientific bibliography on current research applications seems to be missing in the page. I hope this lack will be filled. 82.56.71.148 (talk) 06:35, 21 August 2011 (UTC)
Logical/boolean indexing
[edit]An important part of array programming, in my opinion, is what is called "boolean indexing" in Numpy or "logical indexing" in Matlab (or R, or Julia). Does anyone disagree with this? — Preceding unsigned comment added by Tkova474 (talk • contribs) 12:10, 15 June 2016 (UTC)
External links modified
[edit]Hello fellow Wikipedians,
I have just modified one external link on Array programming. Please take a moment to review my edit. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit this simple FaQ for additional information. I made the following changes:
- Added archive https://web.archive.org/web/20150217154926/http://lispnyc.org/meeting-assets/2007-02-13_pinku/SuranaThesis.pdf to ftp://lispnyc.org/meeting-assets/2007-02-13_pinku/SuranaThesis.pdf
When you have finished reviewing my changes, please set the checked parameter below to true or failed to let others know (documentation at {{Sourcecheck}}
).
This message was posted before February 2018. After February 2018, "External links modified" talk page sections are no longer generated or monitored by InternetArchiveBot. No special action is required regarding these talk page notices, other than regular verification using the archive tool instructions below. Editors have permission to delete these "External links modified" talk page sections if they want to de-clutter talk pages, but see the RfC before doing mass systematic removals. This message is updated dynamically through the template {{source check}}
(last update: 5 June 2024).
- If you have discovered URLs which were erroneously considered dead by the bot, you can report them with this tool.
- If you found an error with any archives or the URLs themselves, you can fix them with this tool.
Cheers.—InternetArchiveBot (Report bug) 14:06, 18 October 2016 (UTC)
External Links Canceled
[edit]As you hope so, the readers here have allowed for quite some time to read and reread their favorite posts. This one is exceptional. The topics here and the article itself. To be honest, programing is done when there is enough time on the cpu. When it is finished with compiling what you have done in a most speedy fashion I hope, then perhaps you had time to understand that programming would be more suitable if their where better citations within this article itself. — Preceding unsigned comment added by 2605:A000:DFC0:6:1AC:F16E:D50:4942 (talk) 17:05, 7 September 2018 (UTC)