// Function: TestMatrixAddRow
// Returns: LPXLOPER
// Description: Add a row to a matrix
//{{XLP_SRC(TestMatrixAddRow)
// NOTE - the FunctionWizard will add and remove mapping code here.
// DO NOT EDIT what you see in these blocks of generated code!
IMPLEMENT_XLLFN2(TestMatrixAddRow, "RJ", "TestMatrixAddRow",
"RowsToAdd", "Example", "Add a row to a matrix", "Number of r"
"ows to add\000", "\0", 1)
extern "C" __declspec( dllexport )
LPXLOPER TestMatrixAddRow(long lRowsToAdd)
{
CXlOper xloResult;
//}}XLP_SRC
if ( lRowsToAdd <= 0 )
xloResult = xlerrNA;
else
{
// Construct a matrix with 3 columns and no rows
xlp::matrix<double> mat;
mat.resize(0, 3);
// An array of data to be added
double adNew[3] = { 1.0, 2.0, 3.0 };
// Add the new row lRowsToAdd times
for ( long i = 0; i < lRowsToAdd; i++ )
mat.add_row(adNew);
// Copy the results to output
xloResult = mat;
}
return xloResult.Ret();
}
Uses
matrix<T>::add_row