matrix operations
linear functions
working (?) version for linear functions