adding my versions of some of the Matlab routines