Translate nsltools from matlab to C language