Constructors

XXXMatrix()

Example: IntMatrix A;
Create an uninitialized matrix. The number of rows and columns are set to zero and no memory is allocated for the storage of data.

XXXMatrix(int numRows, int numCols)

Example: FloatMatrix A(3,2);
Create a matrix with dimensions numRows by numCols. Memory is allocated for the data storage but the entries are uninitialized.

XXXMatrix(int numRows, int numCols, PortHole& portHole)

Example: ComplexMatrix(3,3,myPortHole);
Create a matrix of the given dimensions and initialize the entries by assigning to them values taken from the port portHole. The entries are assigned in a rasterized sequence so that the value of the first particle removed from the porthole is assigned to entry (0, 0), the second particle’s value to entry (0, 1), etc. It is assumed that the port has enough particles in its buffer to fill all the entries of the new matrix.

XXXMatrix(int numRows, int numCols, XXXArrayState& dataArray)

Example: IntMatrix A(2,2,myIntArrayState);
Create a matrix with the given dimensions and initialize the entries to the values in the given ArrayState. The values of the ArrayState fill the matrix in rasterized sequence so that entry (0, 0) of the matrix is the first entry of the ArrayState, entry (0, 1) of the matrix is the second, etc. An error is generated if the ArrayState does not have enough values to initialize the whole matrix.

XXXMatrix(const XXXMatrix& src)

Example: FixMatrix A(B);
This is the copy constructor. A new matrix is formed with the same dimensions as the source matrix and the data values are copied from the source.

XXXMatrix(const XXXMatrix& src, int startRow
                              , int startCol
                              , int numRows
                              , int numCols)

Example: IntMatrix A(B,2,2,3,3);
This special ”submatrix” constructor creates a new matrix whose values came from a submatrix of the source. The arguments startRow and startCol specify the starting row and column of the source matrix. The values numRows and numCols specify the dimensions of the new matrix. The sum startRow + numRows must not be greater than the maximum number of rows in the source matrix; similarly, startCol + numCols must not be greater than the maximum number of columns in the source. For example,
if B is a matrix with dimension (4, 4), then A(B,1,1,2,2) would create a new matrix A that is a (2, 2) matrix with data values from the center quadrant of matrix B, so that
A[0][0]
== B[1][1],
A[0][1] == B[1][2]
,
A[1][0] == B[2][1]
, and
A[1][1] == B[2][2]
.

The following are special constructors for the FixMatrix class that allow the programmer to specify the precision of the entries of the FixMatrix.

FixMatrix(int numRows, int numCols, int length, int intBits)

Example: FixMatrix A(2,2,14,4);
Create a FixMatrix with the given dimensions such that each entry is a fixed-point number with precision as given by the length and intBits arguments.

FixMatrix(int numRows, int numCols,
          int length, int intBits, PortHole& portHole)

Example: FixMatrix A(2,2,14,4);
Create a FixMatrix with the given dimensions such that each entry is a fixed-point number with precision as given by the length and intBits arguments and initialized with the values that are read from the particles contained in the porthole portHole.

FixMatrix(int numRows, int numCols,
          int length, int intBits, FixArrayState& dataArray)

Example: FixMatrix A(2,2,14,4);
Create a FixMatrix with the given dimensions such that each entry is a fixed-point number with precision as given by the length and intBits arguments and initialized with the values in the given FixArrayState.

There are also special copy constructors for the FixMatrix class that allow the programmer to specify the precision of the entries of the FixMatrix as they are copied from the sources. These copy constructors are usually used for easy conversion between the other matrix types. The last argument specifies the type of masking function (truncate, rounding, etc.) to be used when doing the conversion.

FixMatrix(const XXXMatrix& src, int length, int intBits, int round)

Example: FixMatrix A(CxMatrix,4,14,TRUE);
Create a FixMatrix with the given dimensions such that each entry is a fixed-point number with precision as given by the length and intBits arguments. Each entry of the new matrix is copied from the corresponding entry of the src matrix and converted as specified by the round argument.