Function for one iteration(changed matrices to vectors)

Changed all matrix operations into vector operations.