Mathematical operations of matrix classes and least squares algorithm