Abstract For an arbitrary irreducible set of nonnegative d×d-matrices, we consider the following problem: does there exist a strictly positive product (with repetitions permitted) of those matrices? Under some general assumptions, we prove that if it does not exist, then there is a partition of the set of basis vectors of Rd, on which all given matrices act as permutations. Moreover, there always exists a unique maximal partition (with the maximal number of parts) possessing this property, and the number of parts is expressed by eigenvalues of matrices. This generalizes well-known results of Perron–Frobenius theory on primitivity of one matrix to families of matrices. We present a polynomial algorithm to decide the existence of a positive product for a given finite set of matrices and to build the maximal partition. Similar results are obtained for scrambling products. Applications to the study of Lyapunov exponents, inhomogeneous Markov chains, etc. are discussed.