## Sum over a Row(s) / Column(s) / Diagonal of a Matrix.

The functionality of matrix routines in this collection are routines which could be implemented for matrices defined over an arbitrary commutative semigroup but the routines below are implemented for the Abelian group of Reals under addition for which the matrices are declared as*double A[M][N]*or for dynamically defined matrices declared as

*double* A*and for the Abelian group of complex numbers under addition for which the complex matrices are declared as

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

*double complex *A*.

The function for summing over a particular row of a real matrix is called

*Sum_over_Row( )*and the function for summing over all the rows of a real matrix the function is called

*Sum_over_Rows( )*. The function for summing over a particular row of a complex matrix is called

*Sum_over_CMatrix_Row( )*and the function for summing over all the rows of a complex matrix the function is called

*Sum_over_CMatrix_Rows( )*.

The function for summing over a particular column of a real matrix is called

*Sum_over_Column( )*and for summing over all the columns of a real matrix the function is called

*Sum_over_Columns( )*. The function for summing over a particular column of a complex matrix is called

*Sum_over_CMatrix_Column( )*and for summing over all the columns of a complex matrix the function is called

*Sum_over_CMatrix_Columns( )*.

The function for summing over the diagonal of a square real matrix is called

*Trace_of_Matrix( )*. The function for summing over the diagonal of a square complex matrix is called

*Trace_of_CMatrix( )*. There are special versions of the

*Trace_of_Matrix( )*routine and the for

*Trace_of_CMatrix( )*routine for the cases of the ubiquitous

*2*×

*2*and

*3*×

*3*matrices.

### Function List

- double Sum_over_Row( double *A, int ncols, int row )

Return the sum over row*row*of the*nrows×ncols*matrix*A*.

- void Sum_over_Rows( double v[ ], double *A, int nrows, int ncols )

The array element*v[i]*is set to the sum over row*i*of the*nrows×ncols*matrix*A*.

- double Sum_over_Column( double *A, int nrows, int ncols, int col )

Return the sum over column*col*of the*nrows×ncols*matrix*A*.

- void Sum_over_Columns( double v[ ], double *A, int nrows, int ncols )

The array element*v[i]*is set to the sum over column*i*of the*nrows×ncols*matrix*A*.

- double Trace_of_Matrix( double *A, int n )

Return the trace of the*n×n*matrix*A*.

- double Trace_of_Matrix_2x2( double *A )

Return the trace of the*2×2*matrix*A*.

- double Trace_of_Matrix_3x3( double *A )

Return the trace of the*3×3*matrix*A*.

- double complex Sum_over_CMatrix_Row( double complex *A, int ncols, int row )

Return the sum over row*row*of the*nrows×ncols*complex matrix*A*.

- void Sum_over_CMatrix_Rows( double complex v[ ], double complex *A, int nrows, int ncols )

The array element*v[i]*is set to the sum over row*i*of the*nrows×ncols*complex matrix*A*.

- double complex Sum_over_CMatrix_Column( double complex *A, int nrows, int ncols, int col )

Return the sum over column*col*of the*nrows×ncols*matrix*A*.

- void Sum_over_CMatrix_Columns( double complex v[ ], double complex *A, int nrows, int ncols )

The array element*v[i]*is set to the sum over column*i*of the*nrows×ncols*matrix*A*.

- double complex Trace_of_CMatrix( double complex *A, int n )

Return the trace of the*n×n*complex matrix*A*.

- double complex Trace_of_CMatrix_2x2( double complex *A )

Return the trace of the*2×2*complex matrix*A*.

- double complex Trace_of_CMatrix_3x3( double complex *A )

Return the trace of the*3×3*complex matrix*A*.

*C* Source Code

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

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

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

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

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

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

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

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

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

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

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

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

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

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

*NASM* Source Code

For Linux gcc Users

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

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

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

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

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

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

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

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

- The file, testsumoverrow.c, contains a test program of Sum_over_Row( ) in the file
*sum_over_row.c*. This test program requires the file*sum_over_row.c*listed above.

- The file, SumOverRowTests.txt, contains the results of the test program testsumoverrow.c.

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

- The file, testsumoverrows.c, contains a test program of Sum_over_Rows( ) in the file
*sum_over_rows.c*. This test program requires the file*sum_over_rows.c*listed above.

- The file, SumOverRowsTests.txt, contains the results of the test program testsumoverrows.c.

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

- The file, testsumovercol.c, contains a test program of Sum_over_Column( ) in the file
*sum_over_col.c*. This test program requires the file*sum_over_col.c*listed above.

- The file, SumOverColTests.txt, contains the results of the test program testsumovercol.c.

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

- The file, testsumovercols.c, contains a test program of Sum_over_Columns( ) in the file
*sum_over_cols.c*. This test program requires the file*sum_over_cols.c*listed above.

- The file, SumOverColsTests.txt, contains the results of the test program ttestsumovercols.c.

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

- The file, testtrace.c, contains a test program of Trace_of_Matrix( ) in the file
*trace_of_matrix.c*. This test program requires the file*trace_of_matrix.c*listed above.

- The file, TraceTests.txt, contains the results of the test program testtrace.c.

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

- The file, testtrace2x2.c, contains a test program of Trace_of_Matrix_2x2( ) in the file
*trace_of_matrix_2x2.c*. This test program requires the file*trace_of_matrix_2x2.c*listed above.

- The file, Trace2x2Tests.txt, contains the results of the test program testtrace2x2.c.

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

- The file, testtrace3x3.c, contains a test program of Trace_of_Matrix_3x3( ) in the file
*trace_of_matrix_3x3.c*. This test program requires the file*trace_of_matrix_3x3.c*listed above.

- The file, Trace3x3Tests.txt, contains the results of the test program testtrace3x3.c.

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

- The file, testsumovercmatrixrow.c, contains a test program of Sum_over_CMatrix_Row( ) in the file
*sum_over_cmatrix_row.c*. This test program requires the file*sum_over_cmatrix_row.c*listed above.

- The file, SumOverCMatrixRowTests.txt, contains the results of the test program testsumovercmatrixrow.c.

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

- The file, testsumovercmatrixrows.c, contains a test program of Sum_over_CMatrix_Rows( ) in the file
*sum_over_cmatrix_rows.c*. This test program requires the file*sum_over_cmatrix_rows.c*listed above.

- The file, SumOverCMatrixRowsTests.txt, contains the results of the test program testsumovercmatrixrows.c

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

- The file, testsumovercmatrixcol.c, contains a test program of Sum_over_CMatrix_Column( ) in the file
*sum_over_cmatrix_col.c*. This test program requires the file*sum_over_cmatrix_col.c*listed above.

- The file, SumOverCMatrixColTests.txt, contains the results of the test program testsumovercmatrixcol.c.

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

- The file, testsumovercmatrixcols.c, contains a test program of Sum_over_CMatrix_Columns( ) in the file
*sum_over_cmatrix_cols.c*. This test program requires the file*sum_over_cmatrix_cols.c*listed above.

- The file, SumOverCMatrixColsTests.txt, contains the results of the test program testsumovercmatrixcols.c.

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

- The file, testtracecmatrix.c, contains a test program of Trace_of_CMatrix( ) in the file
*trace_of_cmatrix.c*. This test program requires the file*trace_of_cmatrix.c*listed above.

- The file, TraceCMatrixTests.txt, contains the results of the test program testtracecmatrix.c.

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

- The file, testtracecmatrix2x2.c, contains a test program of Trace_of_CMatrix_2x2( ) in the file
*trace_of_cmatrix_2x2.c*. This test program requires the file*trace_of_cmatrix_2x2.c*listed above.

- The file, TraceCMatrix2x2Tests.txt, contains the results of the test program testtracecmatrix2x2.c.

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

- The file, testtracecmatrix3x3.c, contains a test program of Trace_of_CMatrix_3x3( ) in the file
*trace_of_cmatrix_3x3.c*. This test program requires the file*trace_of_cmatrix_3x3.c*listed above.

- The file, TraceCMatrix3x3Tests.txt, contains the results of the test program testtracecmatrix3x3.c.

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