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); }
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); }
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); }
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); }
public int DoMathWithPoint(MFunction g) { return(g(X, Y)); }
public void minus(int pirmas) { this.pirmas = pirmas; // saugom - operacija = (x, y) => x - y; }
public void plus(int pirmas) { this.pirmas = pirmas; // saugom + operacija = (x, y) => x + y; }