Beispiel #1
0
        public Number(BigInteger r)
        {
            real = new BigInteger[2];

            real[0] = r;
            real[1] = BigInteger.ONE;
        }
Beispiel #2
0
        public Number(long nom, long den)
        {
            real = new BigInteger[2];

            real[0] = BigInteger.valueOf(nom);
            real[1] = BigInteger.valueOf(den);
        }
Beispiel #3
0
        public override Symbol Abs()
        {
            if (IsComplex())
            {
                return(ToFloat().Abs());
            }

            var r = new BigInteger[2];

            r[0] = real[0].compareTo(BigInteger.ZERO) < 0 ? real[0].negate() : real[0];
            r[1] = real[1];

            return(new Number(r));
        }
Beispiel #4
0
        private BigInteger[] sub(BigInteger[] x, BigInteger[] y)
        {
            if (y == null)
            {
                return(x);
            }

            var r = new BigInteger[2];

            r[0] = -y[0];
            r[1] = y[1];

            return(add(x, r));
        }
Beispiel #5
0
        private BigInteger[] add(BigInteger[] x, BigInteger[] y)
        {
            if (x == null)
            {
                return(y);
            }

            if (y == null)
            {
                return(x);
            }

            var r = new BigInteger[2];

            r[0] = x[0] * y[1] + y[0] * x[1];
            r[1] = x[1] * y[1];

            return(r);
        }
Beispiel #6
0
        private BigInteger[] cfs(ArrayList a)
        {
            var i = a.Count - 1;

            BigInteger N = ( BigInteger )a[i], Z = BigInteger.ONE, N1;

            i--;

            while (i >= 0)
            {
                N1 = ( BigInteger )a[i] * N + Z;
                Z  = N;
                N  = N1;
                i--;
            }

            var r = new[] { N, Z };

            return(r);
        }
Beispiel #7
0
        internal virtual BigInteger double2big(double x)
        {
            int exp = 0;

            while (x > 1e15)
            {
                x /= 10.0;
                exp++;
            }

            var y = BigInteger.valueOf(Math.round(x));

            if (exp > 0)
            {
                var ten = BigInteger.valueOf(10L);

                y = y * ten ^ exp;
            }

            return(y);
        }
Beispiel #8
0
        private BigInteger[] reducev(BigInteger[] y)
        {
            var x = new BigInteger[2];

            x[0] = y[0];
            x[1] = y[1];

            var gcd = x[0].gcd(x[1]);

            if (!gcd.Equals(BigInteger.ONE))
            {
                x[0] = x[0] / gcd;
                x[1] = x[1] / gcd;
            }

            if (x[1].compareTo(BigInteger.ZERO) < 0)
            {
                x[0] = -x[0];
                x[1] = -x[1];
            }

            return(x);
        }
Beispiel #9
0
 private BigInteger lsm(BigInteger x, BigInteger y)
 {
     return((x * y) / x.gcd(y));
 }