2. Arrays#
In mathematics, vectors can be expressed as either a row or column of elements and matrices are a rectangular array of elements. An individual element in the vector \(\mathbf{a}\) is identified by an index denoted using a subscript, e.g., \(a_i\). The index is the position of the element in the vector starting at 1 for the first element. An individual element in a matrix is identified by two indices denoted in a subscript, e.g., \([A]_{ij}\), the first number corresponding to the row number and the second number corresponding to the column number.
In computer programming, a vector or matrix is represented using an array. Arrays can be one-dimensional (1D) where they contain a single row or column of elements, similar to a vector, or two-dimensional (2D) similar to a matrix. It is possible to have higher dimensional arrays but this is not recommended as it can over complicate a program.