Linear and quadratic programming in oriented matroids