MxCopy
- copy rectangular block from one matrix to another

Matrix functions
(AmiBroker 6.40)


SYNTAX MxCopy( & dstmatrix, src_matrix, dst_start_row, dst_endrow, dst_start_col, dst_end_col, src_matrix, src_start_row = -1, src_end_row = -1, src_start_col = -1, src_end_col = -1 )
RETURNS NOTHING
FUNCTION Copy rectangular block from one matrix to the other (copy portions of one matrix to the other matrix)

The function works in-place (ie. no allocation occurs - first argument is a reference to existing array and that array content would be overwritten)

Parameters:

  • dstmatrix - destination matrix (must be passed as reference using & operator)
  • src_matrix - source matrix
  • dst_start_row, dst_endrow - start and ending rows in the destination matrix
  • dst_start_col, dst_end_col - start and ending columns in the destination matrix
  • src_start_row, src_end_row - start and ending rows in the source matrix
  • src_start_col, src_end_col - start and ending columns in the destination matrix

src_start/src_end values equal to -1 mean "same value as corresponding dst_start/dst_end value"

As you noticed shape of source and destination "rectangles" does not need to be the same - for example you can copy vertical column into horizontal row, but the number of elements to be copied must be matching. So, to perform a copy the number of columns multiplied by number of rows in source and destination "rectangles" must be the same. In other words:

(dst_end_row-dst_start_row+1)*(dst_end_col-dst_start_col+1) == (src_end_row-src_start_row+1)*(src_end_col-src_start_col+1)

EXAMPLE
SEE ALSO

References:

The MxCopy function is used in the following formulas in AFL on-line library:

More information:

See updated/extended version on-line.