## Row / Column Transformations.

For matrices defined over a commutative ring,*(R,+,·)*, with additive binary operator + and multiplicative operator · it is possible to multiply each component of a row and add it to the corresponding component of another row and similarly it is possible to multiply each component of a column and add it to the corresponding component of another column.

An elementary row transformation on an

*m*×

*n*matrix

**A**= (

*a*) is a transformation

_{ij}**T**

^{R}_{k,l,x}where

**T**

^{R}_{k,l,x}

**A**is the

*m*×

*n*matrix given by (

*a'*) where for all

_{ij}*j*,

*a'*=

_{ij}*a*for

_{ij}*i ≠ k*and

*a'*=

_{kj}*a*+

_{kj}*x · a*.

_{lj}Similarly an elementary column transformation on an

*m*×

*n*matrix

**A**= (

*a*) is a transformation

_{ij}**T**

^{C}_{k,l,x}where

**T**

^{C}_{k,l,x}

**A**is the

*m*×

*n*matrix given by (

*a'*) where for all

_{ij}*i*,

*a'*=

_{ij}*a*for

_{ij}*j ≠ k*and

*a'*=

_{ik}*a*+

_{ik}*x · a*.

_{il}The functionality of matrix routines in this collection are routines which could be implemented for matrices defined over an arbitrary commutative ring but the implementation presented here is for real matrices declared as

*double A[M][N]*or for dynamically defined matrices declared as

*double* A*and for complex matrices declared as

*double complex A[M][N]*or for dynamically defined matrices declared as

*double complex *A*.

Besides the elementary row and column transformations on a matrix, the transformations which multiply each matrix element of a given row or a given column by a fixed scalar are programmed.

The function for performing a row transformation on a real matrix is called *Row_Transformation* and the function for performing a column transformation on a real matrix is called *Column_Transformation* while the function for performing a row transformation on a complex matrix is called *CMatrix_Row_Transformation* and the function for performing a column transformation on a complex matrix is called *CMatrix_Column_Transformation*.

The function for multiplying each matrix element of a row of a real matrix is called *Multiply_Row_by_Scalar* and the function for multiplying each matrix element of a column of a real matrix is called *Multiply_Column_by_Scalar* while the function for multiplying each matrix element of a row of a complex matrix is called *Mult_CMatrix_Row_by_Scalar* and the function for multiplying each matrix element of a column of a complex matrix is called *Mult_CMatrix_Column_by_Scalar*.

### Function List

- void Row_Transformation( double *A, double x, int row1, int row2, int ncols )

For the*nrows × ncols*matrix*A*multiply row*row1*by*x*and add to row*row2*, i.e. for all*j*,*A[row2][j] ← A[row2][j] + x * A[row1][j]*.

The possible values for the arguments*row1*and*row2*are*0, ..., nrows - 1*.

Note that*nrows*is not in the argument list.

- void Column_Transformation( double *A, double x, int col1, int col2, int nrows, int ncols )

For the*nrows × ncols*matrix*A*multiply the column*col1*by*x*and add to column*col2*, i.e. for all*i*,*A[i][col2] ← A[i][col2] + x * A[i][col1]*.

The possible values for the arguments*col1*and*col2*are*0, ..., ncols - 1*.

- void Multiply_Row_by_Scalar(double *A, double x, int row, int ncols)

For the*nrows × ncols*matrix*A*multiply each element the row,*row*, by*x*, i.e. for all*i*,*A[row][i] ← x * A[row][i]*.

Note that the number of rows of the matrix*A*,*nrows*, is not needed.

- void void Multiply_Column_by_Scalar(double *A, double x, int col, int nrows, int ncols)

For the*nrows × ncols*matrix*A*multiply each element the column,*col*, by*x*, i.e. for all*i*,*A[i][col] ← x * A[i][col]*.

- void CMatrix_Row_Transformation( double complex *A, double complex x, int row1, int row2, int ncols )

For the*nrows × ncols*complex matrix*A*multiply row*row1*by*x*and add to row*row2*, i.e. for all*j*,*A[row2][j] ← A[row2][j] + x * A[row1][j]*.

The possible values for the arguments*row1*and*row2*are*0, ..., nrows - 1*.

Note that*nrows*is not in the argument list.

- void CMatrix_Column_Transformation( double complex *A, double complex x, int col1, int col2, int nrows, int ncols )

For the*nrows × ncols*complex matrix*A*multiply the column*col1*by*x*and add to column*col2*, i.e. for all*i*,*A[i][col2] ← A[i][col2] + x * A[i][col1]*.

The possible values for the arguments*col1*and*col2*are*0, ..., ncols - 1*.

- void Mult_CMatrix_Row_by_Scalar(double complex *A, double complex x, int row, int ncols)

For the*nrows × ncols*complex matrix*A*multiply each element the row,*row*, by*x*, i.e. for all*i*,*A[row][i] ← x * A[row][i]*.

Note that the number of rows of the matrix*A*,*nrows*, is not needed.

- void void Mult_CMatrix_Column_by_Scalar(double matrix *A, double matrix x, int col, int nrows, int ncols)

For the*nrows × ncols*complex matrix*A*multiply each element the column,*col*, by*x*, i.e. for all*i*,*A[i][col] ← x * A[i][col]*.

*C* Source Code

- The file, row_transformation.c, contains the version of Row_Transformation( ) written in
*C*.

- The file, col_transformation.c, contains the version of Column_Transformation( ) written in
*C*.

- The file, mul_matrix_row_by_scalar.c, contains the version of Multiply_Row_by_Scalar( ) written in
*C*.

- The file, mul_matrix_col_by_scalar.c, contains the version of Multiply_Column_by_Scalar( ) written in
*C*.

- The file, cmatrix_row_transformation.c, contains the version of CMatrix_Row_Transformation( ) written in
*C*.

- The file, cmatrix_col_transformation.c, contains the version of CMatrix_Column_Transformation( ) written in
*C*.

- The file, mult_cmatrix_row_by_scalar.c, contains the version of Mult_CMatrix_Row_by_Scalar( ) written in
*C*.

- The file, mult_cmatrix_col_by_scalar.c, contains the version of Mult_CMatrix_Column_by_Scalar( ) written in
*C*.

*NASM* Source Code

For Linux gcc Users

- The file, row_transformation.asm, contains the version of Row_Transformation( ) written in
*NASM*.

- The file, col_transformation.asm, contains the version of Column_Transformation( ) written in
*NASM*.

- The file, mul_matrix_row_by_scalar.asm, contains the version of Multiply_Row_by_Scalar( ) written in
*NASM*.

- The file, mul_matrix_col_by_scalar.asm, contains the version of Multiply_Column_by_Scalar( ) written in
*NASM*.

*C* Test Code, Test Results, and Build Shell Script

- The file, testrowtransformation.c, contains a test program of Row_Transformation( ) in the file
*row_transformation.c*. This test program requires the file*row_transformation.c*listed above.

- The file, RowTransformationTest.txt, contains the results of the test program testrowtransformation.c.

- The file, testrowtransformation.sh, contains the shell script used to compile, link, and execute the test program testrowtransformation.c.

- The file, testcoltransformation.c, contains a test program of Column_Transformation( ) in the file
*col_transformation.c*. This test program requires the file*col_transformation.c*listed above.

- The file, ColumnTransformationTest.txt, contains the results of the test program testcoltransformation.c.

- The file, testcoltransformation.sh, contains the shell script used to compile, link, and execute the test program testcoltransformation.c.

- The file, testmulrowbyscalar.c, contains a test program of Multiply_Row_by_Scalar( ) in the file
*mul_matrix_row_by_scalar*. This test program requires the file*mul_matrix_row_by_scalar*listed above.

- The file, MultiplyRowByScalarTest.txt, contains the results of the test program testmulrowbyscalar.c.

- The file, testmulrowbyscalar.sh, contains the shell script used to compile, link, and execute the test program testmulrowbyscalar.c.

- The file, testmulcolbyscalar.c, contains a test program of Multiply_Column_by_Scalar( ) in the file
*mul_matrix_col_by_scalar.c*. This test program requires the file*mul_matrix_col_by_scalar.c*listed above.

- The file, MultiplyColumnByScalarTest.txt, contains the results of the test program testmulcolbyscalar.c.

- The file, testmulcolbyscalar.sh, contains the shell script used to compile, link, and execute the test program testmulcolbyscalar.c.

- The file, testcmatrixrowtransformation.c, contains a test program of CMatrix_Row_Transformation( ) in the file
*cmatrix_row_transformation.c*. This test program requires the file*cmatrix_row_transformation.c*listed above.

- The file, CMatrixRowTransformationTest.txt, contains the results of the test program testcmatrixrowtransformation.c.

- The file, testcmatrixrowtransformation.sh, contains the shell script used to compile, link, and execute the test program testcmatrixrowtransformation.c.

- The file, testcmatrixcoltransformation.c, contains a test program of CMatrix_Column_Transformation( ) in the file
*cmatrix_col_transformation.c*. This test program requires the file*cmatrix_col_transformation.c*listed above.

- The file, CMatrixColumnTransformationTest.txt, contains the results of the test program testcmatrixcoltransformation.c.

- The file, testcmatrixcoltransformation.sh, contains the shell script used to compile, link, and execute the test program testcmatrixcoltransformation.c.

- The file, testmulcmatrixrowbyscalar.c, contains a test program of Mult_CMatrix_Row_by_Scalar( ) in the file
*mult_cmatrix_row_by_scalar.c*. This test program requires the file*mult_cmatrix_row_by_scalar.c*listed above.

- The file, MultiplyCMatrixRowByScalarTest.txt, contains the results of the test program testmulcmatrixrowbyscalar.c.

- The file, testmulcmatrixrowbyscalar.sh, contains the shell script used to compile, link, and execute the test program testmulcmatrixrowbyscalar.c.

- The file, testmulcmatrixcolbyscalar.c, contains a test program of Mult_CMatrix_Column_by_Scalar( ) in the file
*mult_cmatrix_col_by_scalar.c*. This test program requires the file*mult_cmatrix_col_by_scalar.c*listed above.

- The file, MultiplyCMatrixColumnByScalarTest.txt, contains the results of the test program testmulcmatrixcolbyscalar.c.

- The file, testmulcmatrixcolbyscalar.sh, contains the shell script used to compile, link, and execute the test program testmulcmatrixcolbyscalar.c.