General Purpose Matrix Operations



Fill Matrix with Scalar

Fill Matrix with a Scalar.

Given an m×n matrix A = (aij), the function Fill_Matrix_with_Scalar() sets each element of a real matrix A of type double to a user-specified scalar of type double and the function Fill_CMatrix_with_Scalar() sets each element of a complex matrix A of type double complex to a user-specified scalar of type double complex.

There are 2 versions of the Fill_Matrix_with_Scalar() routine, 1 version is written in C and 1 version is written in NASM assembly language.

There is 1 version of the Fill_CMatrix_with_Scalar() routine written in C.

Function List

  • void Fill_Matrix_with_Scalar( double *A, double x, int nrows, int ncols)

    Set each element of the nrows × ncols matrix A to the scalar x i.e. A[i][j]=x for all i, j.

  • void Fill_CMatrix_with_Scalar( double complex *A, double complex x, int nrows, int ncols)

    Set each element of the nrows × ncols complex matrix A to the complex scalar x i.e. A[i][j]=x for all i, j.

C Source Code


NASM Source Code
For Linux gcc Users


C Test Code, Test Results, and Build Shell Script

  • The file, testfillmatrixwithscalar.c, contains a test program of Fill_Matrix_with_Scalar( ). This test program requires the file fill_matrix_with_scalar.c listed above.

  • The file, FillMatrixWithScalarTest.txt, contains the results of the test program testfillmatrixwithscalar.c.

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

  • The file, testfillcmatrixwithscalar.c, contains a test program of Fill_CMatrix_with_Scalar( ). This test program requires the file fill_cmatrix_with_scalar.c listed above.

  • The file, FillCMatrixWithScalarTest.txt, contains the results of the test program testfillcmatrixwithscalar.c.

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


Nasm Test Code, Test Results, and Build Shell Script

  • The file, testfillmatrixwithx_A.c, contains a test program of Fill_Matrix_with_Scalar( ). This test program requires the file fill_matrix_with_scalar.asm listed above.

  • The file, FillMatrixWithScalarTests_A.txt, contains the results of the test program testfillmatrixwithx_A.c.

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