PsiLAB Help Manual Page

Section: Basic Matrix functions

Name: matrix_sub

Copy a submatrix from a matrix to another matrix.
The target matrix must hold the submatrix. Both matrices must have the same dimension, and the target matrix must be already allocated.
a:('a, 'b, 'c) Matrix.t
b:('a, 'b, 'c) Matrix.t
range:(int * int) list
offset:int list

The source matrix is a , and the target matrix is b .
The subrange for each dimension is put in a (int*int) list . Keep a dimension unchanged with the (--) operator. The offset list determines the offsets for each dimension in the target matrix b . An empty list indicates no offsets.
[] let a = fmatrix ~dim:[5;3] ~rand:[1.0] () ;; 
val a : (float, '_a, '_b) Matrix.t = <abstr> 
[] let b = fmatrix ~dim:[5;3] ~fill:[0.0] () ;; 
val b : (float, '_a, '_b) Matrix.t = <abstr> 
[] matrix_sub a b [(1,2);(--)] [];; 
- : unit = () 

Printed by PsiLAB