This paper provides versions of classical results from linear algebra, real analysis and convex analysis in a free module of finite rank over the ring $L^0$ of measurable functions on a $\sigma$-finite measure space. We study the question whether a submodule is finitely generated and introduce the more general concepts of $L^0$-affine sets, $L^0$-convex sets, $L^0$-convex cones, $L^0$-hyperplanes, $L^0$-half-spaces and $L^0$-convex polyhedral sets. We investigate orthogonal complements, orthogonal decompositions and the existence of orthonormal bases. We also study $L^0$-linear, $L^0$-affine, $L^0$-convex and $L^0$-sublinear functions and introduce notions of continuity, differentiability, directional derivatives and subgradients. We use a conditional version of the Bolzano-Weierstrass theorem to show that conditional Cauchy sequences converge and give conditions under which conditional optimization problems have optimal solutions. We prove results on the separation of $L^0$-convex sets by $L^0$-hyperplanes and study $L^0$-convex conjugate functions. We provide a result on the existence of $L^0$-subgradients of $L^0$-convex functions, prove a conditional version of the Fenchel-Moreau theorem and study conditional inf-convolutions.