public static void Interpolation(IWorksheetController ctrl, InterpolationParameters parameters) { var _columnToGroupNumber = new Dictionary <DataColumn, int>(); for (int nSel = 0; nSel < ctrl.SelectedDataColumns.Count; nSel++) { Altaxo.Data.DataColumn yCol = ctrl.DataTable.DataColumns[ctrl.SelectedDataColumns[nSel]]; Altaxo.Data.DataColumn xCol = ctrl.DataTable.DataColumns.FindXColumnOf(yCol); if (!(yCol is INumericColumn)) { Current.Gui.ErrorMessageBox("The selected column is not numeric!"); return; } if (!(xCol is INumericColumn)) { Current.Gui.ErrorMessageBox("The x-column of the selected column is not numeric!"); return; } var xRes = new DoubleColumn(); var yRes = new DoubleColumn(); if (!_columnToGroupNumber.TryGetValue(xCol, out var newgroup)) { newgroup = ctrl.DataTable.DataColumns.GetUnusedColumnGroupNumber(); ctrl.DataTable.DataColumns.Add(xRes, xCol.Name + ".I", ColumnKind.X, newgroup); _columnToGroupNumber.Add(xCol, newgroup); } ctrl.DataTable.DataColumns.Add(yRes, yCol.Name + ".I", ColumnKind.V, newgroup); Interpolation(xCol, yCol, parameters, xRes, yRes); } }
public static void Interpolation(Altaxo.Data.DataColumn xCol, Altaxo.Data.DataColumn yCol, InterpolationParameters parameters, Altaxo.Data.DataColumn xRes, Altaxo.Data.DataColumn yRes) { Interpolation( xCol, yCol, parameters.InterpolationInstance, VectorMath.CreateEquidistantSequenceByStartEndLength(parameters.XOrg, parameters.XEnd, parameters.NumberOfPoints), xRes, yRes); }
public static void Interpolation(WorksheetController ctrl) { if (ctrl.SelectedDataColumns.Count == 0) { return; } object paramobject = new InterpolationParameters(); if (!Current.Gui.ShowDialog(ref paramobject, "Interpolation")) { return; } InterpolationParameters parameters = (InterpolationParameters)paramobject; Altaxo.Data.DataColumn yCol = ctrl.Doc.DataColumns[ctrl.SelectedDataColumns[0]]; Altaxo.Data.DataColumn xCol = ctrl.Doc.DataColumns.FindXColumnOf(yCol); if (!(yCol is INumericColumn)) { Current.Gui.ErrorMessageBox("The selected column is not numeric!"); return; } if (!(xCol is INumericColumn)) { Current.Gui.ErrorMessageBox("The x-column of the selected column is not numeric!"); return; } int rows = Math.Min(xCol.Count, yCol.Count); IROVector yVec = DataColumnWrapper.ToROVector((INumericColumn)yCol, rows); IROVector xVec = DataColumnWrapper.ToROVector((INumericColumn)xCol, rows); parameters.InterpolationInstance.Interpolate(xVec, yVec); DoubleColumn xRes = new DoubleColumn(); DoubleColumn yRes = new DoubleColumn(); for (int i = 0; i < parameters.NumberOfPoints; i++) { double r = i / (double)(parameters.NumberOfPoints - 1); double x = parameters.XOrg * (1 - r) + parameters.XEnd * (r); double y = ((IInterpolationFunction)parameters.InterpolationInstance).GetYOfX(x); xRes[i] = x; yRes[i] = y; } int newgroup = ctrl.DataTable.DataColumns.GetUnusedColumnGroupNumber(); ctrl.DataTable.DataColumns.Add(xRes, xCol.Name + ".I", ColumnKind.X, newgroup); ctrl.DataTable.DataColumns.Add(yRes, yCol.Name + ".I", ColumnKind.V, newgroup); }
public static void Interpolation(IWorksheetController ctrl) { if (ctrl.SelectedDataColumns.Count == 0) { return; } object paramobject = new InterpolationParameters(); if (!Current.Gui.ShowDialog(ref paramobject, "Interpolation")) { return; } var parameters = (InterpolationParameters)paramobject; Interpolation(ctrl, parameters); }