set_matrix_with_padding_truncting

 

Description

This function will take a matrix and set the result matrix according to the parameter values. In other words, it will do the neccessory padding with zero or truncting.

Syntax

int set_matrix_with_padding_truncting( matrix & matSource, matrix & matResult, int nRowProcess, int nColProcess )

Parameters

matSource
[input]The source matrix
matResult
[output]The result matrix
nRowProcess
[input]The number of rows, which will be processed, where is result matrix row number
nColProcess
[input]The number of cols, which will be processed, where is result matrix colum number

Return

Returns 0 on successful exit

Examples

EX1

int set_matrix_with_padding_truncting_ex1()
{
   matrix matSource = {{1,2,3},{5,6,7},{9,10,11}};
   printf("The source matrix:\n");
   int ii, jj;
   int nNumCols = matSource.GetNumCols();
   int nNumRows = matSource.GetNumRows();
   for(ii = 0; ii < nNumRows; ii++)
   {
       for(jj = 0; jj < nNumCols; jj++)
           printf("%f  ",matSource[ii][jj]);
       printf("\n");    
   }
   int nRowProcess = nNumRows + 3;
   int nColProcess = nNumCols - 1;
   matrix matResult; 
   int nRet = set_matrix_with_padding_truncting(matSource, matResult, nRowProcess, nColProcess);
   if(nRet != 0)
   {
       printf("set_matrix_with_padding_truncting failed!");
       return -1;
   }
   printf("The result matrix:\n");
   for(ii = 0; ii < nRowProcess; ii++)
   {
       for(jj = 0; jj < nColProcess; jj++)
           printf("%f  ",matResult[ii][jj]);
       printf("\n");    
   }
   
   return 0;    
}

Remark

See Also

header to Include

origin.h

Reference