move finalizeMatrixAssembly() into namespace MathLib

move finalizeMatrixAssembly() into namespace MathLib