3D sparse matrix implementation in ANSI C