/// <summary> /// Sets tolerance of n - th element /// </summary> /// <param name="n">Element number</param> /// <param name="tolerance">Tolerance to set</param> public void SetTolerance(int n, int tolerance) { int m; IStructuredSelection s = chooseSelection(n, out m); s.SetTolerance(m, tolerance); }
/// <summary> /// Aprior weight of n - th element /// </summary> /// <param name="n">Element number</param> /// <returns>The weight</returns> public double GetApriorWeight(int n) { int m; IStructuredSelection s = chooseSelection(n, out m); return(s.GetApriorWeight(m)); }
/// <summary> /// Tolerance of it - th element /// </summary> /// <param name="n">Element number</param> /// <returns>Tolerance</returns> public int GetTolerance(int n) { int m; IStructuredSelection s = chooseSelection(n, out m); return(s.GetTolerance(m)); }
/// <summary> /// Access to n - th element /// </summary> public double?this[int n] { get { int m; IStructuredSelection s = chooseSelection(n, out m); return(s[m]); } }
/// <summary> /// Constructor /// </summary> /// <param name="selection">Selection</param> /// <param name="calculator">Calculation</param> public StructuredGLM(IStructuredSelection selection, IStructuredCalculation calculator) { this.selection = selection; this.calculator = calculator; n = calculator.Dimension; l = selection.DataDimension; z = new double[n]; y = new double?[l]; y1 = new double?[l]; a = new double[n, n]; indx = new int[n]; h = new double?[n, l]; residuals = new double?[l]; }
private void fill(Panel p, bool b) { int k = b ? 0 : 1; int[,] num = selection.Numbers; int n = num[k, 0]; int m = num[k, 1]; IList <IStructuredSelectionCollection> l = selection.Selections; int y = 0; for (int i = 0; i < l.Count; i++) { IStructuredSelectionCollection coll = l[i]; CategoryTheory.IAssociatedObject ao = coll as CategoryTheory.IAssociatedObject; IObjectLabel lab = ao.Object as IObjectLabel; UserControlObject op = new UserControlObject(null, lab); op.Left = 0; op.Top = y; p.Controls.Add(op); y = op.Bottom + 5; int nSel = coll.Count; for (int j = 0; j < nSel; j++) { IStructuredSelection sel = coll[j]; RadioButton rb = new RadioButton(); rb.CheckedChanged += radioButtonSel_CheckedChanged; rb.Text = sel.Name; rb.Tag = new object[] { coll, j, b }; if (n == i & m == j) { rb.Checked = true; } rb.Left = 5; rb.Top = y; p.Controls.Add(rb); y = rb.Bottom + 5; } Panel bl = new Panel(); bl.BackColor = Color.Black; bl.Width = p.Width - 10; bl.Left = 0; bl.Top = y; bl.Height = 2; p.Controls.Add(bl); y = bl.Bottom + 5; } }
private void post() { if (num[0, 0] < selections.Count) { if (num[0, 1] < selections[num[0, 0]].Count) { selection = selections[num[0, 0]][num[0, 1]]; } } if (num[1, 0] < selections.Count) { if (num[1, 1] < selections[num[1, 0]].Count) { weights = selections[num[1, 0]][num[1, 1]]; } } }
/// <summary> /// Calculates parameters /// </summary> /// <param name="x">Input</param> /// <param name="selection">Selection</param> /// <param name="y">Output</param> public void Calculate(double[] x, IStructuredSelection selection, double?[] y) { double a = 0; for (int i = 0; i < x.Length; i++) { aliases[i].Value = x[i]; } /*!!!/// TEMP ==================== * * UpdateChildrenData(); * if (DataPerformer.Portable.StaticExtensionDataPerformerPortable.Factory != null) * { * runtime.UpdateAll(); * } * this.FullReset(); * UpdateChildrenData(); * * ///=============*/ // runtime.StartAll(0); runtime.UpdateAll(); int n = 0; for (int i = 0; i < measurementsDitcionary.Count; i++) { IMeasurement m = measurementsDitcionary[i] as IMeasurement; object t = m.Type; if (t.Equals(a)) { y[n] = (double)m.Parameter(); ++n; continue; } else { Array ar = m.Parameter() as Array; for (int j = 0; j < ar.GetLength(0); j++) { y[n] = (double)ar.GetValue(j); ++n; } } } }
private IStructuredSelection chooseSelection(int n, out int m) { int k = 0; for (int i = 0; i < selections.Count; i++) { IStructuredSelection s = selections[i]; int d = s.DataDimension; if (n < k + d) { m = n - k; return(s); } k += d; } m = -1; return(null); }
/// <summary> /// Calculates parameters /// </summary> /// <param name="x">Input</param> /// <param name="selection">Selection</param> /// <param name="y">Output</param> public void Calculate(double[] x, IStructuredSelection selection, double?[] y) { for (int i = 0; i < parameters.Count; i++) { string s = parameters[i] as string; formula[s] = x[i]; } for (int i = 0; i < this.selection.PointsCount; i++) { int k = i * vectorDimension; foreach (string s in variables) { formula[s] = this.selection[i, s]; } formula.Reset(); (formula as IMeasurements).UpdateMeasurements(); for (int j = 0; j < measurements.Count; j++) { y[k + j] = (double)measurements[j].Parameter(); } } }
/// <summary> /// Costructor /// </summary> /// <param name="reg">Regression component</param> /// <param name="s">Selection</param> public RegressionSelectionUserControl(AliasRegression reg, IStructuredSelectionCollection s) : this() { this.s = s; this.reg = reg; IAssociatedObject ao = s as IAssociatedObject; IObjectLabel label = ao.Object as IObjectLabel; name = label.RootName;//NamedComponent.GetText(label); Control c = new UserControlObject(null, label); c.Left = 0; c.Top = 0; Controls.Add(c); int y = c.Height; for (int i = 0; i < s.Count; i++) { IStructuredSelection sel = s[i]; Label l = new Label(); l.Text = sel.Name; l.Top = y + 10; l.Left = 10; Controls.Add(l); y = l.Top + l.Height; NumericUpDown n = new NumericUpDown(); n.Minimum = -1; n.Value = -1; n.Left = 10; n.Top = y + 10; y = n.Top + n.Height + 20; Controls.Add(n); controls[n] = reg.GetRelativeName(s as IAssociatedObject) + "." + sel.Name; } Height = y; }
/// <summary> /// Calculates parameters /// </summary> /// <param name="x">Input</param> /// <param name="selection">Selection</param> /// <param name="y">Output</param> public void Calculate(double[] x, IStructuredSelection selection, double?[] y) { calculator.Calculate(x, selection, y); }