fixing compilation issues.  C++ block now agrees with matlab code