Reimplement global alignment

reimplement global alignment. Run alignmenttests.m for verification.