### Finding centraliser algebras of a finite set of matrices

Let $S$ be a finite set of $n \times n$-matrices over a field $K$ (lets say finite or the real or complex field).

Is it possible to obtain the $K$-algebra (or at least its vector space dimension) of $n \times n$-matrices X in Sage with $XY=YX$ for all $Y \in S$?