Rank (computer programming)

Rank (computer programming)

In computer programming, rank with no further specifications is usually a synonym for (or refers to) "number of dimensions"; thus, for instance, a bi-dimensional array has rank "two", a three-dimensional array has rank "three" and so on.Strictly, no formal definition can be provided which applies to every programming language, since each of them has its own concepts, semantics and terminology; the term may not even be applicable or, to the contrary, applied with a very specific meaning in the context of a given language.

In the case of APL the notion applies to every operand; and dyads ("binary functions") have a "left rank" and a "right rank".

The box below instead shows how "rank of a type" and "rank of an array expression" could be defined (in a semi-formal style) for C++ and illustrates a simple way to calculate them at compile time.


#include /* Rank of a type * ------------- * * Let the rank of a type T be the number of its dimensions if * it is an array; zero otherwise (which is the usual convention) */template struct rank{ static const std::size_t value = 0; };

templatestruct rank{ static const std::size_t value = 1 + rank::value; };

/* Rank of an expression * * Let the rank of an expression be the rank of its type */template char(&rankof(t(&) [n] )) [n] ; Given the code above the rank of a type T can be calculated at compile time by :rank::value and the rank of an array-expression "expr" by :sizeof(rankof(expr))

ee also

*Rank (linear algebra), for a definition of "rank" as applied to matrices
*Rank (J programming language), a concept of the same name in the J programming language


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать курсовую

Look at other dictionaries:

  • Rank — is a very broad term with several meanings. As a noun it is usually related to a relative position or to some kind of ordering (see also ranking). As an adjective it is used to mean profuse, conspicuous, absolute, or unpleasant, especially in… …   Wikipedia

  • Computer shogi — is a field of artificial intelligence concerned with the creation of computer programs which can play shogi. The research and development of shogi software has been carried out mainly by freelance programmers, university research groups and… …   Wikipedia

  • Computer Go — Part of a series of articles on Go (board game) Game specifics Go rules Go handicaps Go proverbs Go terms Go strategy and tactics Fuseki (whole board openings) Joseki (corner based openings) Life and death Tsumego …   Wikipedia

  • Computer chess — 1990s Pressure sensory chess computer with LCD screen Chess+ For the iPad …   Wikipedia

  • Dynamic programming — For the programming paradigm, see Dynamic programming language. In mathematics and computer science, dynamic programming is a method for solving complex problems by breaking them down into simpler subproblems. It is applicable to problems… …   Wikipedia

  • ACM International Collegiate Programming Contest — (abbreviated as ACM ICPC or just ICPC) is an annual multi tiered computer programming competition among the universities of the world. The contest is sponsored by IBM. Headquartered at Baylor University, with autonomous regions on six continents …   Wikipedia

  • MAD (programming language) — MAD Paradigm(s) Imperative Appeared in 1959 Developer Galler, Arden, and Graham Major implementations IBM 704, IBM 7090, UNIVAC 1108, Philco 210 211, IBM S/360, and IBM S/370 …   Wikipedia

  • Linear programming — (LP, or linear optimization) is a mathematical method for determining a way to achieve the best outcome (such as maximum profit or lowest cost) in a given mathematical model for some list of requirements represented as linear relationships.… …   Wikipedia

  • Criticism of the APL programming language — The APL programming language has been used since the mid 1960s on mainframe computers and has itself evolved in step with computers and the computing market. APL is not widely used, but minimalistic and high level by design, at several points in… …   Wikipedia

  • Array programming — In computer science, array programming languages (also known as vector or multidimensional languages) generalize operations on scalars to apply transparently to vectors, matrices, and higher dimensional arrays.Array programming primitives… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”