G2 does not support a matrix class. However, you can assemble data structures that serve as matrixes in your KB by creating item arrays and quantity arrays.
A sparse array is an alternate way of expressing a dense array. A sparse array consists of two separate arrays:
(4.0, 0.0, 7.0, 0.0, 9.2, 0.0, 0.0, 0.0, 0.0)
(4.0, 7.0, 9.2)
(0, 2, 4)
For information about how to create arrays and matrixes, see the G2 Reference Manual.