General Purpose Matrix Operations



Set Row / Column of a Matrix

Set a row or column of a matrix.

Given an m×n matrix A = (aij) each row and column of A can be considered to be a vector, the rows of A are n-dimensional vectors and the columns of A are m-dimensional vectors.

The routines for replacing a row or column of a real matrix of type double are called Set_Row() and Set_Column() respectively and the routines for replacing a row or column of a complex matrix of type double complex are called Set_CRow() and Set_CColumn() respectively.

There are 4 versions of the Set_Row() routine and 2 versions of the Set_Column() routine. For the Set_Row() routine 3 are written in C, and 1 is written in NASM assembly language. Of the 3 versions in C, one is a macro which calls the C library function memcpy(), one is a C function which calls the C library function memcpy(), and one is a function which does not call memcpy(). For the Set_Column() routine 1 version is written in C and 1 is written in NASM assembly language.

There are 3 versions of the Set_CRow() routine and 1 version of the Set_CColumn() routine, all written in C. Of the 3 versions of Set_CRow(), one is a macro which calls the C library function memcpy(), one is a C function which calls the C library function memcpy(), and one is a function which does not call memcpy().

When you build a library, only one of each of the functions should be included unless you change the names.

Function List

  • void Set_Row(double *A, double v[ ], int row, int ncols)

    Given the vector v of dimension ncols, this routine copies the elements of v to the destination matrix A[row][*], i.e. A[row] [i]=v[i], i = 0, ..., ncols - 1. The destination matrix A should be dimensioned in the calling routine at least as large as
    (row+1)× ncols.

  • void Set_Column(double *A, double v[ ], int col, int nrows, int ncols)

    Given the vector v of dimension nrows, this routine copies the elements of v to the destination matrix A[*][col], i.e. A[i] [col]=v[i], i = 0, ..., nrows - 1. The destination matrix A should be dimensioned in the calling routine as nrows × ncols.

  • void Set_CRow(double complex *A, double complex v[ ], int row, int ncols)

    Given the complex vector v of dimension ncols, this routine copies the elements of v to the destination complex matrix A[row][*], i.e. A[row] [i]=v[i], i = 0, ..., ncols - 1. The destination matrix A should be dimensioned in the calling routine at least as large as
    (row+1)× ncols.

  • void Set_CColumn(double complex *A, double complex v[ ], int col, int nrows, int ncols)

    Given the complex vector v of dimension nrows, this routine copies the elements of v to the destination complex matrix A[*][col], i.e. A[i] [col]=v[i], i = 0, ..., nrows - 1. The destination matrix A should be dimensioned in the calling routine as nrows × ncols.

C Source Code

  • The file, set_row.c, contains the version of Set_Row() written in C using the C library function memcpy.

  • The file, set_row.h, contains the version of Set_Row() written as a macro.

  • The file, cset_row.c, contains the version of Set_Row() written in C not using the C library function memcpy.

  • The file, set_column.c, contains the version of Set_Column() written in C.

  • The file, set_crow.c, contains the version of Set_CRow() written in C using the C library function memcpy.

  • The file, set_crow.h, contains the version of Set_CRow() written as a macro.

  • The file, cset_crow.c, contains the version of Set_CRow() written in C not using the C library function memcpy.

  • The file, set_ccolumn.c, contains the version of Set_CColumn() written in C.

NASM Source Code
For Linux gcc Users

  • The file, set_row.asm, contains the version of Set_Row() written in NASM assembly language.

  • The file, set_column.asm, contains the version of Set_Column() written in NASM assembly language.

C Test Code, Test Results, and Build Shell Script

  • The file, testsetrow.c, contains a test program of Set_Row( ) in the file set_row.c. This test program requires the file get_row.c listed above.

  • The file, SetRowTest.txt, contains the results of the test program testsetrow.c.

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


  • The file, testcsetrow.c, contains a test program of Set_Row( ) in the file cset_row.c. This test program requires the file cset_row.c listed above.

  • The file, CSetRowTest.txt, contains the results of the test program testcsetrow.c.

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


  • The file, testsetrow_h.c, contains a test program of Set_Row( ) in the file set_row.h. This test program requires the file set_row.h listed above.

  • The file, SetRow_hTest.txt, contains the results of the test program testsetrow_h.c.

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


  • The file, testsetcolumn.c, contains a test program of Set_Column( ) in the file set_column.c. This test program requires the file set_column.c listed above.

  • The file, SetColumnTest.txt, contains the results of the test program testsetcolumn.c.

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


  • The file, testsetcrow.c, contains a test program of Set_CRow( ) in the file set_crow.c. This test program requires the file set_crow.c listed above.

  • The file, SetCRowTest.txt, contains the results of the test program testsetcrow.c.

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


  • The file, testcsetcrow.c, contains a test program of Set_CRow( ) in the file cset_crow.c. This test program requires the file cset_crow.c listed above.

  • The file, CSetCRowTest.txt, contains the results of the test program testcsetcrow.c.

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


  • The file, testsetcrow_h.c, contains a test program of Set_CRow( ) in the file set_crow.h. This test program requires the file set_crow.h listed above.

  • The file, SetCRow_hTest.txt, contains the results of the test program testsetcrow_h.c.

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


  • The file, testsetccolumn.c, contains a test program of Set_CColumn( ) in the file set_ccolumn.c. This test program requires the file set_ccolumn.c listed above.

  • The file, SetCColumnTest.txt, contains the results of the test program testsetccolumn.c.

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