Some C++ code is here for memorandum.