implemented matrix free.