Index notation

In mathematics and computer programming, index notation is used to specify the elements of an array of numbers. The formalism of how indices are used varies according to the subject. In particular, there are different methods for referring to the elements of a list, a vector, or a matrix, depending on whether one is writing a formal mathematical paper for publication, or when one is writing a computer program.

In mathematics

It is frequently helpful in mathematics to refer to the elements of an array using subscripts. The subscripts can be integers or variables. The array takes the form of tensors in general, since these can be treated as multi-dimensional arrays. Special (and more familiar) cases are vectors (1d arrays) and matrices (2d arrays).

The following is only an introduction to the concept: index notation is used in more detail in mathematics (particularly in the representation and manipulation of tensor operations). See the main article for further details.

One-dimensional arrays (vectors)

A vector treated as an array of numbers by writing as a row vector or column vector (whichever is used depends on convenience or context):

Index notation allows indication of the elements of the array by simply writing ai, where the index i is known to run from 1 to n, because of n-dimensions.[1] For example, given the vector:

then some entries are

.

The notation can be applied to vectors in mathematics and physics. The following vector equation

can also be written in terms of the elements of the vector (aka components), that is

where the indices take a given range of values. This expression represents a set of equations, one for each index. If the vectors each have n elements, meaning i = 1,2,…n, then the equations are explicitly

Hence, index notation serves as an efficient shorthand for

  1. representing the general structure to an equation,
  2. while applicable to individual components.

Two-dimensional arrays

Elements of matrix A are described with two subscripts or indices.

More than one index is used to describe arrays of numbers, in two or more dimensions, such as the elements of a matrix, (see also image to right);

The entry of a matrix A is written using two indices, say i and j, with or without commas to separate the indices: aij or ai,j, where the first subscript is the row number and the second is the column number. Juxtaposition is also used as notation for multiplication; this may be a source of confusion. For example, if

then some entries are

.

For indices larger than 9, the comma-based notation may be preferable (e.g., a3,12 instead of a312).

Matrix equations are written similarly to vector equations, such as

in terms of the elements of the matrices (aka components)

for all values of i and j. Again this expression represents a set of equations, one for each index. If the matrices each have m rows and n columns, meaning i = 1, 2, …, m and j = 1, 2, …, n, then there are mn equations.

Multi-dimensional arrays

The notation allows a clear generalization to multi-dimensional arrays of elements: tensors. For example,

representing a set of many equations.

In tensor analysis, superscripts are used instead of subscripts to distinguish covariant from contravariant entities, see covariance and contravariance of vectors and raising and lowering indices.

In computing

In several programming languages, index notation is a way of addressing elements of an array. This method is used since it is closest to how it is implemented in assembly language whereby the address of the first element is used as a base, and a multiple (the index) of the element size is used to address inside the array.

For example, if an array of integers is stored in a region of the computer's memory starting at the memory cell with address 3000 (the base address), and each integer occupies four cells (bytes), then the elements of this array are at memory locations 0x3000, 0x3004, 0x3008, …, 0x3000 + 4(n − 1) (note the zero-based numbering). In general, the address of the ith element of an array with base address b and element size s is b + is.

Implementation details

In the C programming language, we can write the above as *(base + i) (pointer form) or base[i] (array indexing form), which is exactly equivalent because the C standard defines the array indexing form as a transformation to pointer form. Coincidentally, since pointer addition is commutative, this allows for obscure expressions such as 3[base] which is equivalent to base[3].[2]

Multidimensional arrays

Things become more interesting when we consider arrays with more than one index, for example, a two-dimensional table. We have three possibilities:

  • make the two-dimensional array one-dimensional by computing a single index from the two
  • consider a one-dimensional array where each element is another one-dimensional array, i.e. an array of arrays
  • use additional storage to hold the array of addresses of each row of the original array, and store the rows of the original array as separate one-dimensional arrays

In C, all three methods can be used. When the first method is used, the programmer decides how the elements of the array are laid out in the computer's memory, and provides the formulas to compute the location of each element. The second method is used when the number of elements in each row is the same and known at the time the program is written. The programmer declares the array to have, say, three columns by writing e.g. elementtype tablename[][3];. One then refers to a particular element of the array by writing tablename[first index][second index]. The compiler computes the total number of memory cells occupied by each row, uses the first index to find the address of the desired row, and then uses the second index to find the address of the desired element in the row. When the third method is used, the programmer declares the table to be an array of pointers, like in elementtype *tablename[];. When the programmer subsequently specifies a particular element tablename[first index][second index], the compiler generates instructions to look up the address of the row specified by the first index, and use this address as the base when computing the address of the element specified by the second index.

void mult3x3f(float result[][3], const float A[][3], const float B[][3])
{
  int i, j, k;
  for (i = 0; i < 3; ++i) {
    for (j = 0; j < 3; ++j) {
      result[i][j] = 0;
      for (k = 0; k < 3; ++k)
        result[i][j] += A[i][k] * B[k][j];
    }
  }
}

In other languages

In other programming languages such as Pascal, indices may start at 1, so indexing in a block of memory can be changed to fit a start-at-1 addressing scheme by a simple linear transformation – in this scheme, the memory location of the ith element with base address b and element size s is b + (i − 1)s.

References

  1. ^ An introduction to Tensor Analysis: For Engineers and Applied Scientists, J.R. Tyldesley, Longman, 1975, ISBN 0-582-44355-5
  2. ^ Programming with C++, J. Hubbard, Schaum's Outlines, McGraw Hill (USA), 1996, ISBN 0-07-114328-9
  • Programming with C++, J. Hubbard, Schaum's Outlines, McGraw Hill (USA), 1996, ISBN 0-07-114328-9
  • Tensor Calculus, D.C. Kay, Schaum's Outlines, McGraw Hill (USA), 1988, ISBN 0-07-033484-6
  • Mathematical methods for physics and engineering, K.F. Riley, M.P. Hobson, S.J. Bence, Cambridge University Press, 2010, ISBN 978-0-521-86153-3

Read other articles:

Jonathan MajorsMajors pada 2018Lahir7 September 1989 (umur 34)Lompoc, California, USAPendidikanUniversity of North Carolina School of the Arts (Sarjana)Universitas Yale (Magistrat)PekerjaanPemeranTahun aktif2017 - sekarangTinggi183 cm (6 ft 0 in)Anak1 Jonathan Majors (lahir 7 September 1989)[1][2] adalah seorang pemeran asal Amerika Serikat. Ia meraih ketenaran usai membintangi film fitur independen The Last Black Man in San Francisco (2019). Pada 2020, i…

Dixit memfilmkan Dance Deewane pada 2018 Madhuri Dixit adalah seorang pemeran India yang dikenal atas karyanya dalam perfilman Bollywood. Ia memulai debutnya dengan berperan sebagai seorang mempelai muda dalam film 1984 Abodh.[1] Dixit tampil dalam beberapa film sepanjang dua tahun berikutnya, meliputi film drama Awara Baap (1985) dan Swati (1986), walaupun tak ada yang meraih sambutan besar.[1] Peran terobosannya datang pada 1988 dengan film cerita seru garapan N. Chandra Tezaab…

Koningsberger Jacob Christiaan Koningsberger (Hazerswoude, 17 Januari 1867 - 's-Gravenhage, 19 Maret 1951) adalah seorang dosen dan politikus berkebangsaan Belanda. Koningsberger merupakan Menteri Jajahan Belanda di kabinet sementara De Geer. Segera setelah lulus ia pindah ke Hindia Belanda dan di sana menduduki jabatan yang berbeda-beda di bidang ilmu pengetahuan. Di Buitenzorg (sekarang Kota Bogor) ia menjabat sebagai Direktur Kebun Raya Bogor antara tahun 1911-1917. Selepasnya dari jabatan di…

Yana's FriendsSutradaraArik KaplunProduserAnat BikelMoshe LevinsonMarek RozenbaumUri SabagDitulis olehArik KaplunSimon VinokurPemeranEvelyn KaplunNir LevyShmil Ben AriMosko AlkalaiDalia FriedlandPenata musikAvi BenjaminSinematograferValentin BelonogovPenyuntingEinat Glaser-ZarhinDistributorFriends of Film (A.S.)Tanggal rilis4 November 1999 (Israel)Durasi90 menitNegaraIsraelBahasaIbraniRusia Yana's Friends ([החברים של יאנה, HaHaverim shel Yana] Error: {{Lang-xx}}: text has itali…

Departemen Perencanaan New South Wales (bahasa Inggris: New South Wales Department of Planning, disingkat DOP) adalah sebuah departemen Pemerintah New South Wales dengan tugas administrasi sistem tata negara bagian dan penetapan sejumlah penerapan pembangunan. Departemen ini juga bertugas mengatur pelepasan tanah untuk perumahan baru tunduknya pemerintah lokal pada hukum tata negara bagian dalam penerapan pembangunan dan penzonaan. Kekuasaan Departemen sesuai dengan NSW Environmental Planning an…

3rd episode of the 2nd season of Seinfeld The JacketSeinfeld episodeEpisode no.Season 2Episode 3Directed byTom CheronesWritten byLarry David and Jerry SeinfeldProduction code205Original air dateFebruary 6, 1991 (1991-02-06)Guest appearances Lawrence Tierney as Alton Benes Frantz Turner as Salesman Suanne Spoke as Customer Harry Hart-Browne as Manager Episode chronology ← PreviousThe Pony Remark Next →The Phone Message Seinfeld season 2List of episodes The Jacket…

Pertempuran Teluk ManilaBagian dari Perang Spanyol-AmerikaCetak berwarna kontemporer, menunjukkan USS Olympia di latar depan kiri, memimpin Skuadron Asiatik Amerika Serikat melawan armada kapal Spanyol dekat Cavite. Sebuah potret sketsa dari Laksamana George Dewey ditampilkan di bagian kiri bawah.Tanggal1 Mei 1898LokasiDekat Manila, FilipinaHasil Kemenangan mutlak Amerika SerikatPihak terlibat  Amerika Serikat Kerajaan SpanyolTokoh dan pemimpin George Dewey Patricio MontojoKekuatan Kek…

العلاقات الإستونية الصربية إستونيا صربيا   إستونيا   صربيا تعديل مصدري - تعديل   العلاقات الإستونية الصربية هي العلاقات الثنائية التي تجمع بين إستونيا وصربيا.[1][2][3][4][5] مقارنة بين البلدين هذه مقارنة عامة ومرجعية للدولتين: وجه المقارنة إستون…

Ongoing COVID-19 viral pandemic in Wyoming, United States This article needs to be updated. Please help update this article to reflect recent events or newly available information. (September 2021) COVID-19 pandemic in WyomingDiseaseCOVID-19Virus strainSARS-CoV-2LocationWyoming, U.S.First outbreakCalifornia, U.S.Index caseSheridan CountyArrival dateMarch 11, 2020Confirmed cases196,100[1]Deaths2,125[1]Government websitecovid19.wyo.govPart of a series on theCOVID-19 pandemicScienti…

Число китайцев в Казахстане менялось с течением времени. В XIX и начале XX веков имели место различные миграции этнических меньшинств из Китая  (англ.) (рус. в Казахстан, например, дунгане (хуэй), бежавшие от вооружённых сил династии Цин после неудавшегося восстания 1862-1…

العلاقات الإسواتينية الغرينادية إسواتيني غرينادا   إسواتيني   غرينادا تعديل مصدري - تعديل   العلاقات الإسواتينية الغرينادية هي العلاقات الثنائية التي تجمع بين إسواتيني وغرينادا.[1][2][3][4][5] مقارنة بين البلدين هذه مقارنة عامة ومرجعية للدولتي…

У этого термина существуют и другие значения, см. Истребитель танков (значения). Советское лёгкое самоходное орудие СУ-76.Боевая машина 2П26 в Военно-историческом музее артиллерии, инженерных войск и войск связи.Польские танкисты на учениях, ПТУРСы на 2П27 или «Шмеле».ИТ-1 в экс…

Type of marketing strategy A billboard for Sanford Health placed on the exterior of the Target Center, adjacent to Target Field, so that it is visible from within to compete with a sponsorship held by a competitor. Ambush marketing or ambush advertising is a marketing strategy in which an advertiser ambushes an event to compete for exposure against other advertisers. The term was coined by marketing strategist Jerry Welsh, while he was working as the manager of global marketing efforts for Ameri…

هذه المقالة يتيمة إذ تصل إليها مقالات أخرى قليلة جدًا. فضلًا، ساعد بإضافة وصلة إليها في مقالات متعلقة بها. (مارس 2019) بيترو لونجو (بالإيطالية: Pietro Longo)‏    معلومات شخصية الميلاد 29 أكتوبر 1935 (89 سنة)  روما  مواطنة إيطاليا  عضو في البروباغاندا الثانية  [لغات أخرى]̴…

1974–1979 national anthem of Rhodesia Rise, O Voices of RhodesiaA page from Beethoven's original manuscriptFormer national anthem of Rhodesia and Zimbabwe-RhodesiaAlso known asVoices of Rhodesia[1]LyricsMary Bloom, 1974[1]MusicLudwig van Beethoven, 1824[2] (arranged by Ken MacDonald, 1974)AdoptedAugust 1974 (1974-08)[1]RelinquishedDecember 1979 (1979-12)Preceded byGod Save the QueenSucceeded byIshe Komborera Africa (As national anthem of Zimb…

Borough in Estonia Place in Lääne County, EstoniaTaeblaUus Street in TaeblaTaeblaCoordinates: 58°57′2″N 23°43′31″E / 58.95056°N 23.72528°E / 58.95056; 23.72528Country EstoniaCounty Lääne CountyParish Lääne-Nigula ParishPopulation (01.01.2010) • Total929 Taebla is a small borough (alevik) in Lääne County, Estonia,[1] the administrative centre of Lääne-Nigula Parish. It has a population of 929 (as of 1 January 2010).[2]…

American pizzeria chain Patxi's Chicago PizzaIndustryDiningFounded2004; 20 years ago (2004)FounderWilliam Freeman and Francisco “Patxi” AzpirozHeadquartersSausalito, California, USAProductsPizzaParentKarpReilly LLCWebsitehttps://www.patxispizza.com/ Patxi's (pronounced pah-cheese)[1] is a small pizzeria chain based in Sausalito, California.[2] History Patxi's was founded by William Freeman and Francisco “Patxi” Azpiroz.[3] The restaurant chain sp…

Villeneuve-le-Roi Photo panoramique de la façade de la mairie. Blason Logo Administration Pays France Région Île-de-France Département Val-de-Marne Arrondissement L'Haÿ-les-Roses Intercommunalité Métropole du Grand Paris Maire Mandat Didier Gonzales 2020-2026 Code postal 94290 Code commune 94077 Démographie Gentilé Villeneuvois Populationmunicipale 21 129 hab. (2021 ) Densité 2 515 hab./km2 Géographie Coordonnées 48° 44′ 00″ nord, 2° 25…

See also: List of historic places in Greater Vancouver Regional District, List of historic places in Greater Vancouver North Shore, List of historic places in Surrey, and List of historic places in Vancouver Map all coordinates using OpenStreetMap Download coordinates as: KML GPX (all coordinates) GPX (primary coordinates) GPX (secondary coordinates) The following list includes all of the Canadian Register of Historic Places listings in New Westminster, British Columbia. Name Address Coordinates…

This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Rugby union in England – news · newspapers · books · scholar · JSTOR (July 2012) (Learn how and when to remove this message) Rugby union in EnglandCelebrations in Trafalgar Square after England won the 2003 Rugby World Cup.CountryEnglandGoverning bodyRugby Footbal…

Kembali kehalaman sebelumnya