added zig-zag matrix implementation