translated linear.jl, still 2-3 to go