Completed code except for forward transform functions.