Dot

Added dot function for sparse matrix.
Also, `if structured_grad` do non-structured code `else` do structured code

Does not make sense.