コード例 #1
0
        private bool DoWork()
        {
            Stream stream  = null;
            string charset = null;
            bool   isgzip  = false;

            SendRequest(TempUrl, out stream, out charset, out isgzip);
            if (stream == null)
            {
                return(false);
            }
            string html = null;

            ProcessStream(stream, isgzip, charset, out html);
            if (string.IsNullOrEmpty(html))
            {
                return(false);
            }
            string tempurl, data;

            MFunction.Invoke(html, out tempurl, out data);
            DataStore.SaveFile(data);
            if (tempurl == null)
            {
                return(false);
            }
            TempUrl = tempurl;
            return(true);
        }
コード例 #2
0
        private static MatrixR Jacobian(MFunction f, VectorR x)
        {
            double  h        = 0.0001;
            int     n        = x.GetSize();
            MatrixR jacobian = new MatrixR(n, n);
            VectorR x1       = x.Clone();

            for (int j = 0; j < n; j++)
            {
                x1[j] = x[j] + h;
                for (int i = 0; i < n; i++)
                {
                    jacobian[i, j] = (f(x1)[i] - f(x)[i]) / h;
                }
            }
            return(jacobian);
        }
コード例 #3
0
        public static VectorR NewtonMultiEquations(MFunction f, VectorR x0, double tolerance)
        {
            LinearSystem ls = new LinearSystem();
            VectorR      dx = new VectorR(x0.GetSize());

            do
            {
                MatrixR A = Jacobian(f, x0);
                if (Math.Sqrt(VectorR.DotProduct(f(x0), f(x0)) / x0.GetSize()) < tolerance)
                {
                    return(x0);
                }
                dx = ls.GaussJordan(A, -f(x0));
                x0 = x0 + dx;
            }while (Math.Sqrt(VectorR.DotProduct(dx, dx)) > tolerance);
            return(x0);
        }
コード例 #4
0
        private bool DoWork()
        {
            Stream stream  = null;
            string charset = null;
            bool   isgzip  = false;

            SendRequest(TempUrl, out stream, out charset, out isgzip);
            if (stream == null)
            {
                return(false);
            }
            string html = null;

            if (isgzip)
            {
                Stream st;
                EncodeAndCompress.DecompressStream(stream, out st);
                byte[] buff = new byte[st.Length];
                st.Read(buff, 0, buff.Length);
                html = Encoding.GetEncoding(charset).GetString(buff);
                st.Close();
            }
            else
            {
                var reader = new StreamReader(stream, true);
                html = reader.ReadToEnd();
                reader.Close();
            }
            if (string.IsNullOrEmpty(html))
            {
                return(false);
            }
            string tempurl, data;

            MFunction.Invoke(html, out tempurl, out data);
            DataStore.SaveFile(data);
            if (tempurl == null)
            {
                return(false);
            }
            TempUrl = tempurl;
            return(true);
        }
コード例 #5
0
 public int DoMathWithPoint(MFunction g)
 {
     return(g(X, Y));
 }
コード例 #6
0
 public void minus(int pirmas)
 {
     this.pirmas = pirmas;
     // saugom -
     operacija = (x, y) => x - y;
 }
コード例 #7
0
 public void plus(int pirmas)
 {
     this.pirmas = pirmas;
     // saugom +
     operacija = (x, y) => x + y;
 }