public static Pow[] GetNarrowPowers(this Rational r, Rational[] narrows = null) { if (narrows == null) { narrows = NarrowUtils.GetDefault(r.GetInvolvedPowerCount()); } int len = r.GetInvolvedPowerCount(); if (len > narrows.Length) { return(null); } Pow[] res = new Pow[len]; r = r.Clone(); for (int i = len - 1; i >= 0; --i) { Pow e = r.GetPrimePower(i); res[i] = e; if (e != 0) { r /= narrows[i].Power(e); } } return(res); }
public static string FormatNarrowPowers(this Rational r, Rational[] narrows = null) { if (narrows == null) { narrows = NarrowUtils.GetDefault(r.GetInvolvedPowerCount()); } Pow[] pows = GetNarrowPowers(r, narrows); if (pows == null) { return(null); //!!! where invalid narrowPrimes from? } return(Powers.ToString(pows, "|}")); }