General Purpose Matrix Operations



Get Row / Column of a Matrix

Get 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 getting a row or column of a real matrix of type double are called Get_Row() and Get_Column() respectively and the routines for getting a row or column of a complex matrix of type double complex are called Get_CRow() and Get_CColumn() respectively.

There are 4 versions of the Get_Row() routine and 2 versions of the Get_Column(). For the Get_Row() routine 3 versions are written in C, and 1 version is written in NASM assembly language. Of the 3 versions written 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 Get_Column() routine 1 version is written in C and 1 version is written in NASM assembly language.

There are 3 versions of the Get_CRow() routine and 1 version of the Get_CColumn() routine, all written in C. Of the 3 versions of Get_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 Get_Row(double v[ ], double *A, int row, int ncols)

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

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

    Given the matrix A with nrows rows and ncols columns, this routine copies the elements of A[*] [col] to the destination vector v, i.e. v[i] = A[i] [col], i = 0, ..., nrows - 1. The destination vector v should be dimensioned in the calling routine at least as large as nrows.

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

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

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

    Given the complex matrix A with nrows rows and ncols columns, this routine copies the elements of A[*] [col] to the destination complex vector v, i.e. v[i] = A[i] [col], i = 0, ..., nrows - 1. The destination vector v should be dimensioned in the calling routine at least as large as nrows.

C Source Code

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

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

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

  • The file, get_column.c, contains the version of Get_Column() written in C.

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

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

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

  • The file, get_ccolumn.c, contains the version of Get_CColumn() written in C.

NASM Source Code
For Linux gcc Users

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

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


C Test Code, Test Results, and Build Shell Script

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

  • The file, GetRowTest.txt, contains the results of the test program testgetrow.c.

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


  • The file, testcgetrow.c, contains a test program of Get_Row( ) in the file cget_row.c. This test program requires the file cget_row.c listed above.

  • The file, CGetRowTest.txt, contains the results of the test program testcgetrow.c.

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


  • The file, testgetrow_h.c, contains a test program of Get_Row( ) in the file get_row.h. This test program requires the file get_row.h listed above.

  • The file, GetRow_hTest.txt, contains the results of the test program testgetrow_h.c.

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


  • The file, testgetcolumn.c, contains a test program of Get_Column( ) in the file get_column.c. This test program requires the file get_column.c listed above.

  • The file, GetColumnTest.txt, contains the results of the test program testgetcolumn.c.

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


  • The file, testgetcrow.c, contains a test program of Get_CRow( ) in the file get_crow.c. This test program requires the file get_crow.c listed above.

  • The file, GetCRowTest.txt, contains the results of the test program testgetcrow.c.

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


  • The file, testcgetcrow.c, contains a test program of Get_CRow( ) in the file cget_crow.c. This test program requires the file cget_crow.c listed above.

  • The file, CGetCRowTest.txt, contains the results of the test program testcgetcrow.c.

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


  • The file, testgetcrow_h.c, contains a test program of Get_CRow( ) in the file get_crow.h. This test program requires the file get_crow.h listed above.

  • The file, GetCRow_hTest.txt, contains the results of the test program testgetcrow_h.c.

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


  • The file, testgetccolumn.c, contains a test program of Get_CColumn( ) in the file get_ccolumn.c. This test program requires the file get_ccolumn.c listed above.

  • The file, GetCColumnTest.txt, contains the results of the test program testgetccolumn.c.

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