Invariance with respect to linear or affine transformations