Pass matrix size to Matrix though parameters instead of static ref

Signed-off-by: plysan <plysab@gmail.com>