ComputerScientist
174 subscribers
14 photos
3 files
206 links
▜ The Inventor

Stuff that inspire you to create.

See also: ▙ @LitMind
Download Telegram
#Programming_paradigms : #Array_programming (also vector or multidimensional)

Generalizes operations on scalars to apply transparently to vectors, matrices, and higher-dimensional arrays.

Is used in scientific and engineering settings.

e.g. APL, J, Fortran, #Ada, #MATLAB, #Perl Data Language (PDL) and the NumPy extension to #Python.

Vectorized operation
Operations applied at once to an entire set of values like arrays; regardless of whether it is executed on a vector processor or not.

Function rank
Analogous to tensor rank in mathematics
Functions that operate on data may be classified by the number of dimensions they act on.

• Ordinary multiplication, for example, is a scalar ranked function because it operates on zero-dimensional data (individual numbers).

• The cross product operation is an example of a vector rank function because it operates on vectors, not scalars.

• Matrix multiplication is an example of a 2-rank function, because it operates on 2-dimensional objects (matrices).

Collapse operators reduce the dimensionality of an input data array by one or more dimensions. For example, summing over elements collapses the input array by 1 dimension.
Data layout
- is how multidimensional arrays are stored in a linear storage such as RAM. It is critical for:
• correctly passing arrays between programs written in different programming languages
• performance when traversing an array because modern CPUs, due to caching, process sequential data more efficiently than non-sequential data
• contiguous access makes it possible to use SIMD instructions that operate on vectors of data

Row-major versus column-major order
The difference between the orders lies in which elements of an array are contiguous in memory. In a row-major order, the consecutive elements of a row reside next to each other, whereas the same holds true for consecutive elements of a column in a column-major order. While the terms allude to the rows and columns of a two-dimensional array, the orders can be generalized to arrays of any dimension.

Transposition
As exchanging the indices of an array is the essence of array transposition, an array stored as row-major but read as column-major (or vice versa) will appear transposed. As actually performing this rearrangement in memory is typically an expensive operation, some systems provide options to specify individual matrices as being stored transposed.

Languages support
• Row-major: #C/C++/Objective-C (for C-style arrays), PL/I, #Pascal, Speakeasy, SAS, and Rasdaman
• Column-major: #Fortran, #MATLAB, GNU Octave, S-Plus, #R, #Julia, and Scilab.
• Neither (for less dense arrays):
• Iliffe vectors: #Java, #Scala, #Swift. #Ruby, #Perl, #PHP, #JavaScript, Visual Basic .NET
• Lists of lists: #Python, Wolfram Language of Wolfram Mathematica
• Tables of tables: #Lua