added functions in SGNDArray

@iglesias @hushell
Could you help me to check this patch? Thanks!
Are you sure for any other types, such as int8, this will not overflow?