Top Qs
Timeline
Chat
Perspective

Comparison of programming languages (array)

List of programming language comparisons From Wikipedia, the free encyclopedia

Remove ads

This comparison of programming languages (array) compares the features of array data structures or matrix processing for various computer programming languages.

Syntax

Summarize
Perspective

Array dimensions

The following list contains syntax examples of how to determine the dimensions (index of the first element, the last element or the size in elements).

Some languages index from zero. Some index from one. Some carry no such restriction, or even allow indexing by any enumerated type, not only integers.

More information Languages, Size ...

Indexing

The following list contains syntax examples of how to access a single element of an array.

More information Format, Languages ...

Slicing

The following list contains syntax examples of how a range of element of an array can be accessed.

In the following table:

  • first – the index of the first element in the slice
  • last – the index of the last element in the slice
  • end – one more than the index of last element in the slice
  • len – the length of the slice (= end - first)
  • step – the number of array elements in each (default 1)
More information Format, Languages ...
Remove ads

Array system cross-reference list

More information Language, Defaultbase index ...
Remove ads

Vectorized array operations

Summarize
Perspective

Some compiled languages such as Ada and Fortran, and some scripting languages such as IDL, MATLAB, and S-Lang, have native support for vectorized operations on arrays. For example, to perform an element by element sum of two arrays, a and b to produce a third c, it is only necessary to write

c = a + b

In addition to support for vectorized arithmetic and relational operations, these languages also vectorize common mathematical functions such as sine. For example, if x is an array, then

y = sin (x)

will result in an array y whose elements are sine of the corresponding elements of the array x.

Vectorized index operations are also supported. As an example,

even = x(2::2);
odd = x(::2);

is how one would use Fortran to create arrays from the even and odd entries of an array. Another common use of vectorized indices is a filtering operation. Consider a clipping operation of a sine wave where amplitudes larger than 0.5 are to be set to 0.5. Using S-Lang, this can be done by

y = sin(x);
y[where(abs(y)>0.5)] = 0.5;

Mathematical matrix operations

More information Language/ Library, Create ...
Remove ads

References

Loading content...
Loading related searches...

Wikiwand - on

Seamless Wikipedia browsing. On steroids.

Remove ads