Esempio n. 1
0
        public static MultiCycle <HyperEquation> GetEquation(Abc shift1, Abc shift2, bool flip = false)
        {
            Predicate <MonoCycle <MultiCycle <HyperEquation> > > pred = mono =>
                                                                        mono != null && mono.Data != null &&
                                                                        (mono.Data.Data[1].AbcShift == shift1 &&
                                                                         mono.Data.Data[2].AbcShift == shift2 ||
                                                                         (flip &&
                                                                          (mono.Data.Data[1].AbcShift == shift2 &&
                                                                           mono.Data.Data[2].AbcShift == shift1)));

            foreach (var gi in G)
            {
                foreach (var gij in gi)
                {
                    var v = gij.Link.Find(pred);
                    if (v != null && v.Data != null)
                    {
                        return(v.Data);
                    }
                }
            }
            var vp = Gplus.Link.Find(pred);

            if (vp != null && vp.Data != null)
            {
                return(vp.Data);
            }
            return(null);
        }
 public Coef this[Abc shift]
 {
     get
     {
         int i = GetIndex(shift);
         if (i < 0)
         {
             throw new ArgumentException("HyperEquation not contains coef where shift == " + shift, "shift");
         }
         return(this[i]);
         //foreach(var cf in (IEnumerable<Coef>)_cfs) if(cf.AbcShift == shift) return cf;
     }
 }
Esempio n. 3
0
        public Fraction(string s, Abc shift = default(Abc)) : this(Coef.One[shift], Coef.One[shift])
        {
            var sum = Expression.SplitSum(s);

            if (sum != null && sum.Link == null)
            {
                //if(sum.Data.Key == '-') Numerator = -Coef.One;
                foreach (var pair in (IEnumerable <KeyValuePair <char, string> >)Expression.SplitProduct(s))
                {
                    switch (pair.Key)
                    {
                    case '*': Numerator *= new Coef(pair.Value, shift); break;

                    case '/': Denominator *= new Coef(pair.Value, shift); break;
                    }
                }
            }
            else
            {
                Numerator = new Coef(s, shift);
            }
        }
 public ContinuedFractionA(Abc sum, MonoLinker <Coef> cfs = null)
 {
     SumAbc = sum; Coefs = cfs;
 }
Esempio n. 5
0
 //public string GetShiftedStr() { return GetShiftedStr(StrFunc, AbcShift, true); }
 //public Coef GetShiftedObj() { return new Coef(GetShiftedStr()); }
 //public Coef GetShiftedObj(Abc shift) { return this[shift - AbcShift].GetShiftedObj()[AbcShift - shift]; }
 //public Coef GetShiftedObj(Abc shift) { return this[-shift].GetShiftedObj()[shift]; }
 public Coef GetShiftedObj(Abc shift)
 {
     return(new Coef(GetShiftedStr(StrFunc, shift, true), AbcShift + shift));
 }
Esempio n. 6
0
 public static string GetShiftedStr(string s, Abc shift, bool brkt)
 {
     return(s.Replace("a", GetStr("a", shift.A, brkt))
            .Replace("b", GetStr("b", shift.B, brkt))
            .Replace("c", GetStr("c", shift.C, brkt)));
 }
Esempio n. 7
0
 //
 public Coef this[Abc shift] {
     get { return(new Coef(GetShiftedStr(StrFunc, shift, true), AbcShift + shift)); }
 }
Esempio n. 8
0
 public Coef(string s, Abc shift = new Abc()) : this()
 {
     StrFunc = ValidateString(s); AbcShift = shift;
 }
Esempio n. 9
0
        /// <exception cref="ArgumentException"></exception>
        public static HyperEquation GetEquation(Abc shift0, Abc shift1, Abc shift2)
        {
            if (shift0 == shift1 || shift1 == shift2 || shift2 == shift0)
            {
                throw new ArgumentException("shift0 == shift1 || shift1 == shift2 || shift2 == shift0");
            }
            var abc = new MonoCycle <Abc>(shift0)
            {
                shift1, shift2
            };
            MultiCycle <HyperEquation> r;
            HyperEquation h;
            Abc           sh1, sh2;

            foreach (var shift in abc)
            {
                sh1 = shift[1].Data - shift.Data;
                sh2 = shift[2].Data - shift.Data;
                if (System.Math.Abs(sh1.A) > 1 || System.Math.Abs(sh1.B) > 1 || System.Math.Abs(sh1.C) > 1 ||
                    System.Math.Abs(sh2.A) > 1 || System.Math.Abs(sh2.B) > 1 || System.Math.Abs(sh2.C) > 1)
                {
                    continue;
                }
                r = GetEquation(sh1, sh2, true);                 // ?? GetEquation(sh2, sh1);
                if (r == null)
                {
                    continue;
                }
                h = (r.Data + shift.Data).Simplify();
                if (h[0].AbcShift == shift0)
                {
                    if (h[1].AbcShift == shift1)
                    {
                        return(h);
                    }
                    if (h[1].AbcShift == shift2)
                    {
                        return(h.Reverse());
                    }
                }
                if (h[0].AbcShift == shift1)
                {
                    if (h[1].AbcShift == shift2)
                    {
                        return(h >> 1);
                    }
                    if (h[1].AbcShift == shift0)
                    {
                        return(new HyperEquation(h[1], h[0], h[2], h.FromEquations));                                            // h.Reverse() >> 1;
                    }
                }
                if (h[0].AbcShift == shift2)
                {
                    if (h[1].AbcShift == shift0)
                    {
                        return(h << 1);
                    }
                    if (h[1].AbcShift == shift1)
                    {
                        return(new HyperEquation(h[2], h[1], h[0], h.FromEquations));                                            // h.Reverse() << 1;
                    }
                }
            }
            return(default(HyperEquation));
        }
Esempio n. 10
0
 public int GetIndex(Abc shift)
 {
     return(GetIndex(c => c.AbcShift == shift));
 }
Esempio n. 11
0
 public               Fraction this[Abc shift] {
     get { return(new Fraction(Numerator[shift], Denominator[shift])); }
 }
Esempio n. 12
0
 public Fraction(Coef c, Abc shift = default(Abc)) : this(c.StrFunc, shift)
 {
 }