Math primitives 4 (WinRunner, TSL)
Service Functions – Math / WinRunner
Add new column to a matrix
public function mx_add_col_value(inout mxTable[], in col_value) {
auto rc, i;
auto col_count, row_count;
col_count = mxTable[0, "sys", "colCount"];
row_count = mxTable[0, "sys", "rowCount"];
# create new col index
col_count++;
for (i=1;i<=row_count;i++)
mxTable[i,col_count] = col_value;
mxTable[0, "sys", "colCount"] = col_count;
return(E_OK);
}
Add new vector (column) to a matrix
public function mx_add_col_vector(inout mxTable[], inout mxVector[]) {
auto rc, i;
auto col_count, row_count;
auto vrow_count;
col_count = mxTable[0, "sys", "colCount"];
row_count = mxTable[0, "sys", "rowCount"];
vrow_count = mxVector[0];
if (vrow_count != row_count)
return(E_OUT_OF_RANGE);
# create new col index
col_count++;
for (i=1;i<=row_count;i++)
mxTable[i,col_count] = mxVector[i];
mxTable[0, "sys", "colCount"] = col_count;
return(E_OK);
}
Retrieve vector (row or column) from a matrix
public function mx_get_vector(inout mxTable[], inout mxVector[], in direction, in number) {
auto i;
auto col_count, row_count;
col_count = mxTable[0, "sys", "colCount"];
row_count = mxTable[0, "sys", "rowCount"];
delete mxVector[];
direction = tolower(direction);
if (direction != "row") direction = "col";
if (direction == "row") {
if (number > row_count) return(E_GENERAL_ERROR);
for (i=1;i<=col_count;i++)
mxVector[i] = mxTable[number, i];
mxVector[0] = col_count;
}
if (direction == "col") {
if (number > col_count) return(E_GENERAL_ERROR);
for (i=1;i<=row_count;i++)
mxVector[i] = mxTable[i, number];
mxVector[0] = row_count;
}
return(E_OK);
}
Retrieve subrange (matrix) from a matrix
public function mx_subrange(inout mxTable[], inout mxRange[], in start_row, in end_row) {
auto rc, i, j, row_index;
auto col_count, row_count;
auto flFound;
col_count = mxTable[0, "sys", "colCount"];
row_count = mxTable[0, "sys", "rowCount"];
if (start_row == "") start_row = 1;
if (end_row == "") end_row = row_count;
if (start_row > row_count) start_row = row_count;
if (end_row > row_count) end_row = row_count;
if (start_row > end_row) start_row = end_row;
# Copy sub range
row_index = 0;
delete mxRange[];
for (i=start_row;i<=end_row;i++) {
row_index++;
for (j=1;j<=col_count;j++) {
mxRange[row_index, j] = mxTable[i,j];
}
}
mxRange[0, "sys", "colCount"] = col_count;
mxRange[0, "sys", "rowCount"] = row_index;
return(E_OK);
}

