An efficient method to calculate optimal pulse patterns for multi-level converters