Download QCMatPack Matrix and Numerical Analysis Software - Quinn
Transcript
Matrix Classes 35 1..n]. Matrices of this type use base-1 indexing. In contrast, C, C++, C#, and Java all use base-0 indexing, where the index range of an array with the dimensions [m x n] is [0..m1][ 0..n-1]. Algorithms written for base-1 indexing will not work, and will generally crash programs written using compilers that require base-0 indexing. This software assumes base-0 indexing. All matrices dimensioned to the size (m x n) use array indexing in the range [0..m-1][ 0..n-1]. The software includes routines that will convert a base-0 matrix into a base-1 matrix. In that case, the base-0 matrix dimensioned to size (m x n), with array indexing of [0..m-1][ 0..n-1], is converted to a matrix size (m + 1) x (n + 1) that can be used with 1-based indexing in the range [1..m][ 1..n]. All of the data in the original matrix is shifted one column and one row so that all data fits in the new index range of [1..m][ 1..n]. While the 0 row and column indices in these converted matrices are still useable, in a true base-1 algorithm, they would never be accessed, because they are considered out of range. A base-1 matrix can be converted back to a base-0 matrix. In that case the base-1 matrix, dimension (m + 1) x (n + 1) is converted back to a matrix of with the dimensions (m x n). The data is shifted back one row and one column, so that the data starts in the 0th row and column. Matrix Constructors Define a matrix with the dimensions (rows x columns). DDMat DDMat(int rows, int columns) DXMat DXMat(int rows, int columns) Construct a matrix as a copy of the source matrix. DDMat DDMat(DMatBase source) DXMat DXMat(XMatBase source) Construct vector as the column or row (rcflag = V_ROW or VCOL) of the source matrix. The index of the column or row to copy is rcnum. DDMat