fixed bug in Thomas algorithm