예제 #1
0
        public void Reset(float[,] covar)
        {
            int x, y, n = covar.GetLength(0), m = covar.GetLength(1);

            grid.RowsCount    = m + 1;
            grid.ColumnsCount = n + 1;
            grid[0, 0]        = new SourceGrid2.Cells.Real.Header();
            for (x = 0; x < n; x++)
            {
                grid[0, x + 1] = new  SourceGrid2.Cells.Real.ColumnHeader(x + 1);
            }
            for (y = 0; y < m; y++)
            {
                grid[y + 1, 0] = new SourceGrid2.Cells.Real.RowHeader(y + 1);
            }
            for (x = 0; x < n; x++)
            {
                for (y = 0; y < m; y++)
                {
                    grid[x + 1, y + 1] = new SourceGrid2.Cells.Real.Cell(covar[x, y], typeof(double));
                    grid[x + 1, y + 1].DataModel.EnableEdit = false;
                }
            }
            grid.AutoSize();
        }
예제 #2
0
        void ResetGrid()
        {
            lock (this) {
                if (f != null)
                {
                    if (f != oldf || f.Modified)
                    {
                        grid.ColumnsCount = 4;
                        grid.RowsCount    = f.p.Length + 1;
                        grid[0, 0]        = new SourceGrid2.Cells.Real.ColumnHeader("n");
                        grid[0, 1]        = new SourceGrid2.Cells.Real.ColumnHeader("fit");
                        grid[0, 2]        = new SourceGrid2.Cells.Real.ColumnHeader("p[n]");
                        grid[0, 3]        = new SourceGrid2.Cells.Real.ColumnHeader("±Δp[n]");
                        for (int i = 0; i < f.p.Length; i++)
                        {
                            grid[i + 1, 0] = new SourceGrid2.Cells.Real.RowHeader(i.ToString());
                            grid[i + 1, 1] = new SourceGrid2.Cells.Real.CheckBox(Fitp[i]);
                            grid[i + 1, 2] = new FpCell(f, i, model);
                            if (CovarianceMatrix == null)
                            {
                                grid[i + 1, 3] = new SourceGrid2.Cells.Real.Cell("", typeof(string));
                            }
                            else
                            {
                                grid[i + 1, 3] = new SourceGrid2.Cells.Real.Cell(Math.Sqrt(CovarianceMatrix[i, i]), typeof(double));
                            }
                            grid[i + 1, 3].DataModel.EnableEdit = false;
                        }
                    }

                    plength = f.p.Length;
                }
                if (f == null)
                {
                    grid.RowsCount    = 1;
                    grid.ColumnsCount = 4;
                    grid[0, 0]        = new SourceGrid2.Cells.Real.ColumnHeader("n");
                    grid[0, 1]        = new SourceGrid2.Cells.Real.ColumnHeader("fit");
                    grid[0, 2]        = new SourceGrid2.Cells.Real.ColumnHeader("p[n]");
                    grid[0, 3]        = new SourceGrid2.Cells.Real.ColumnHeader("±Δp[n]");
                    Fitp = new bool[0];
                }
                grid.AutoSize();
            }
        }
예제 #3
0
        public void Reset(FunctionItem item)
        {
            this.item = item;


            grid.ColumnsCount = 2;
            grid.RowsCount    = item.p.Length + 1;
            grid[0, 0]        = new SourceGrid2.Cells.Real.Header("n");
            grid[0, 1]        = new SourceGrid2.Cells.Real.ColumnHeader("p[n]");
            for (int r = 0; r < item.p.Length; r++)
            {
                grid[r + 1, 0] = new SourceGrid2.Cells.Real.RowHeader(r);
                grid[r + 1, 1] = new SourceGrid2.Cells.Real.Cell(item.p[r], typeof(double));
            }

            grid.Columns[0].AutoSizeMode = SourceGrid2.AutoSizeMode.MinimumSize;
            grid.Columns[1].AutoSizeMode = SourceGrid2.AutoSizeMode.MinimumSize;
            grid.AutoSize();
        }
예제 #4
0
        public void ResetPar()
        {
            bool fitpok = true;

            lock (this) {
                GraphModel model = graph.Model;
                string     name;
                int        i;
                name = (string)function.Text;
                f    = null;
                for (i = 0; i < model.Items.Count; i++)
                {
                    if ((model.Items[i].name == name) && (model.Items[i] is Function1D) &&
                        (((Function1D)model.Items[i]).Fitable()))
                    {
                        f = (Function1D)model.Items[i];
                    }
                }
                name     = (string)data.Text;
                dataItem = null;
                for (i = 0; i < model.Items.Count; i++)
                {
                    if ((model.Items[i].name == name) && (model.Items[i] is DataItem))
                    {
                        dataItem = (DataItem)model.Items[i];
                    }
                }
                if (f != null)
                {
                    if (f != oldf || f.Modified)
                    {
                        if (f != oldf)
                        {
                            fitp = new bool[f.p.Length];
                            for (i = 0; i < f.p.Length; i++)
                            {
                                fitp[i] = true;
                            }
                        }
                        grid.ColumnsCount = 4;
                        grid.RowsCount    = f.p.Length + 1;
                        grid[0, 0]        = new SourceGrid2.Cells.Real.ColumnHeader("n");
                        grid[0, 1]        = new SourceGrid2.Cells.Real.ColumnHeader("fit");
                        grid[0, 2]        = new SourceGrid2.Cells.Real.ColumnHeader("p[n]");
                        grid[0, 3]        = new SourceGrid2.Cells.Real.ColumnHeader("±Δp[n]");
                        for (i = 0; i < f.p.Length; i++)
                        {
                            grid[i + 1, 0] = new SourceGrid2.Cells.Real.RowHeader(i.ToString());
                            grid[i + 1, 1] = new SourceGrid2.Cells.Real.CheckBox(fitp[i]);
                            grid[i + 1, 2] = new SourceGrid2.Cells.Real.Cell(f.p[i], typeof(double));
                            if (covar == null)
                            {
                                grid[i + 1, 3] = new SourceGrid2.Cells.Real.Cell("", typeof(string));
                            }
                            else
                            {
                                grid[i + 1, 3] = new SourceGrid2.Cells.Real.Cell(Math.Sqrt(covar[i, i]), typeof(double));
                            }
                            grid[i + 1, 3].DataModel.EnableEdit = false;
                        }
                        covar = null;
                    }

                    plength = f.p.Length;
                }
                if (f == null)
                {
                    grid.RowsCount    = 4;
                    grid.ColumnsCount = 1;
                    grid[0, 0]        = new SourceGrid2.Cells.Real.ColumnHeader("n");
                    grid[0, 1]        = new SourceGrid2.Cells.Real.ColumnHeader("fit");
                    grid[0, 2]        = new SourceGrid2.Cells.Real.ColumnHeader("p[n]");
                    grid[0, 3]        = new SourceGrid2.Cells.Real.ColumnHeader("±Δp[n]");
                }
                grid.AutoSize();
                oldf               = f;
                Q.Text             = "";
                chisq.Text         = "";
                covariance.Enabled = covar != null;
                fitpok             = false;
                for (i = 0; i < fitp.Length; i++)
                {
                    if (fitp[i])
                    {
                        fitpok = true;
                    }
                }
                start.Enabled = (f != null && data != null && fitpok);
                neval.Text    = "";
            }
        }