예제 #1
0
        /// <summary>
        /// Merges two tables by corresponding x-columns.
        /// </summary>
        /// <param name="masterTable">Master table. Values from the slave table will be recalculated to fit the x-values of the master table.</param>
        /// <param name="masterXColumn">The master x-column of the master table.</param>
        /// <param name="slaveTable">The table providing the data for merging into the master table.</param>
        /// <param name="slaveXColumn">The x column of the slave table.</param>
        /// <param name="columnsToMerge">Indices of that columns of the slave table that should be merged into the master table.</param>
        /// <param name="createNewTable">If true, a new table is created as a clone of the master table. The data from the slave table are then merged into that clone. If false,
        /// the data are directly merged into the master table.</param>
        /// <returns>If <c>createNewTable</c> is true, then the newly created table. If false, then the provided master table where the data are merge to.</returns>
        public static DataTable MergeTable(
            this DataTable masterTable, DataColumn masterXColumn,
            DataTable slaveTable, DataColumn slaveXColumn,
            Altaxo.Collections.IAscendingIntegerCollection columnsToMerge,
            bool createNewTable)
        {
            DataTable destinationTable;

            if (createNewTable)
            {
                destinationTable = (DataTable)masterTable.Clone();
            }
            else
            {
                destinationTable = masterTable;
            }

            // create a fractional index column with the same length than the master table
            // that points into the slave table

            DoubleColumn fractIndex = GetFractionalIndex(masterXColumn, slaveXColumn);

            MergeTable(masterTable, fractIndex, slaveTable, columnsToMerge);

            return(destinationTable);
        }
예제 #2
0
			/// <summary>
			/// Constructor
			/// </summary>
			/// <param name="collection">Collection of <see cref="DataColumn" />s. It is not cloned, so make sure it don't change during usage.</param>
			/// <param name="selectedColumns">Set set of indices into the collection that are part of the matrix.</param>
			/// <param name="selectedRows">The set of rows that are part of the matrix. This collection is not cloned here, therefore it must not be subsequently changed!</param>
			public DataColumnToColumnROMatrixWrapper(Altaxo.Data.INumericColumn[] collection, Altaxo.Collections.IAscendingIntegerCollection selectedColumns, Altaxo.Collections.IAscendingIntegerCollection selectedRows)
			{
				_columns = new Altaxo.Data.INumericColumn[selectedColumns.Count];
				for (int i = selectedColumns.Count - 1; i >= 0; i--)
					_columns[i] = (Altaxo.Data.INumericColumn)collection[selectedColumns[i]];
				_rows = selectedRows;
			}
예제 #3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="collection">Collection of <see cref="DataColumn" />s. It is not cloned, so make sure it don't change during usage.</param>
 /// <param name="selectedColumns">Set set of indices into the collection that are part of the matrix.</param>
 /// <param name="selectedRows">The set of rows that are part of the matrix. This collection is not cloned here, therefore it must not be subsequently changed!</param>
 public DataColumnToColumnROMatrixWrapper(Altaxo.Data.INumericColumn[] collection, Altaxo.Collections.IAscendingIntegerCollection selectedColumns, Altaxo.Collections.IAscendingIntegerCollection selectedRows)
 {
     _columns = new Altaxo.Data.INumericColumn[selectedColumns.Count];
     for (int i = selectedColumns.Count - 1; i >= 0; i--)
     {
         _columns[i] = collection[selectedColumns[i]];
     }
     _rows = selectedRows;
 }
예제 #4
0
 /// <summary>
 /// Plots selected data columns of a table.
 /// </summary>
 /// <param name="table">The source table.</param>
 /// <param name="selectedColumns">The data columns of the table that should be plotted.</param>
 /// <param name="bLine">If true, the line style is activated (the points are connected by lines).</param>
 /// <param name="bScatter">If true, the scatter style is activated (the points are plotted as symbols).</param>
 public static void PlotLine(DataTable table, Altaxo.Collections.IAscendingIntegerCollection selectedColumns, bool bLine, bool bScatter)
 {
     if (bLine && bScatter)
     {
         Plot(table, selectedColumns, PlotStyle_Line_Symbol, GroupStyle_Color_Line_Symbol);
     }
     else if (bLine)
     {
         Plot(table, selectedColumns, PlotStyle_Line, GroupStyle_Color_Line);
     }
     else
     {
         Plot(table, selectedColumns, PlotStyle_Symbol, GroupStyle_Color_Symbol);
     }
 }
예제 #5
0
        /// <summary>
        /// Plots selected data columns of a table.
        /// </summary>
        /// <param name="table">The source table.</param>
        /// <param name="selectedColumns">The data columns of the table that should be plotted.</param>
        /// <param name="bLine">If true, the line style is activated (the points are connected by lines).</param>
        /// <param name="bScatter">If true, the scatter style is activated (the points are plotted as symbols).</param>
        /// <param name="preferredGraphName">Preferred name of the graph. Can be null if you have no preference.</param>
        public static void PlotLine(DataTable table, Altaxo.Collections.IAscendingIntegerCollection selectedColumns, bool bLine, bool bScatter, string preferredGraphName)
        {
            var graph   = Altaxo.Graph.Gdi.GraphTemplates.TemplateWithXYPlotLayerWithG2DCartesicCoordinateSystem.CreateGraph(table.GetPropertyContext(), preferredGraphName, table.Name, true);
            var context = graph.GetPropertyContext();

            if (bLine && bScatter)
            {
                Plot(table, selectedColumns, graph, PlotStyle_Line_Symbol(context), GroupStyle_Color_Line_Symbol);
            }
            else if (bLine)
            {
                Plot(table, selectedColumns, graph, PlotStyle_Line(context), GroupStyle_Color_Line);
            }
            else
            {
                Plot(table, selectedColumns, graph, PlotStyle_Symbol(context), GroupStyle_Color_Symbol);
            }
        }
예제 #6
0
 /// <summary>
 /// Wrapps a set of <see cref="DataColumn" />s into a writeable matrix so that the matrix rows corresponds to the <see cref="DataColumn" />s.
 /// </summary>
 /// <param name="collection">DataColumnCollection from which to select the data columns that are part of the matrix by their indices.</param>
 /// <param name="selectedColumns">The indices of the data columns in the collection that are part of the matrix. You can subsequently change this parameter without affecting this wrapper.</param>
 /// <param name="nRows">Number of rows of the data table that participate in the matrix (starting from index 0). Remember that this are the columns of the wrapped matrix.</param>
 public static IMatrix ToRowMatrix(Altaxo.Data.DataColumnCollection collection, Altaxo.Collections.IAscendingIntegerCollection selectedColumns, int nRows)
 {
     return(new DataColumnToRowMatrixWrapper(collection, selectedColumns, new Altaxo.Collections.IntegerRangeAsCollection(0, nRows)));
 }
예제 #7
0
 /// <summary>
 /// Wraps a set of <see cref="DataColumn" />s into a readonly matrix so that the matrix columns corresponds to the <see cref="DataColumn" />s But the first column consists of elements with a numerical value of 1. The number of columns
 /// of the resulting matrix is therefore 1 greater than the number of data columns in the argument.
 /// </summary>
 /// <param name="collection">Collection of <see cref="DataColumn" />s.</param>
 /// <param name="selectedColumns">Set set of indices into the collection that are part of the matrix. You can subsequently change this parameter without affecting this wrapper.</param>
 /// <param name="selectedRows">The set of rows that are part of the matrix. This collection will be cloned here, i.e. you can subsequently change it without affecting this wrapper.</param>
 /// <returns>The wrapping read only matrix.</returns>
 /// <remarks>This type of wrapper is usefull for instance for fitting purposes, where an intercept is needed.</remarks>
 public static IROMatrix ToROColumnMatrixWithIntercept(Altaxo.Data.DataColumnCollection collection, Altaxo.Collections.IAscendingIntegerCollection selectedColumns, Altaxo.Collections.IAscendingIntegerCollection selectedRows)
 {
     return(new InterceptPlusDataColumnToColumnROMatrixWrapper(collection, selectedColumns, (IAscendingIntegerCollection)selectedRows.Clone()));
 }
예제 #8
0
 /// <summary>
 /// Wrapps a set of <see cref="DataColumn" />s into a writeable matrix so that the matrix rows corresponds to the <see cref="DataColumn" />s.
 /// </summary>
 /// <param name="collection">DataColumnCollection from which to select the data columns that are part of the matrix by their indices.</param>
 /// <param name="selectedColumns">The indices of the data columns in the collection that are part of the matrix. You can subsequently change this parameter without affecting this wrapper.</param>
 /// <param name="selectedRows">Selected rows of the data table that participate in the matrix. Remember that this are the columns of the wrapped matrix. This collection will be cloned here, i.e. you can subsequently change it without affecting this wrapper.</param>
 public static IMatrix ToRowMatrix(Altaxo.Data.DataColumnCollection collection, Altaxo.Collections.IAscendingIntegerCollection selectedColumns, Altaxo.Collections.IAscendingIntegerCollection selectedRows)
 {
     return(new DataColumnToRowMatrixWrapper(collection, selectedColumns, (IAscendingIntegerCollection)selectedRows.Clone()));
 }
예제 #9
0
 public DataColumnToColumnMatrixWrapper(Altaxo.Data.DataColumnCollection collection, Altaxo.Collections.IAscendingIntegerCollection selectedColumns, Altaxo.Collections.IAscendingIntegerCollection selectedRows)
     : base(collection, selectedColumns, selectedRows)
 {
     /*
      * // check the writeability
      * for(int i=selectedColumns.Count-1;i>=0;i--)
      * if(!(collection[selectedColumns[i]] is IWriteableColumn))
      *  throw new ArgumentException(string.Format("Column not writeable! Index in matrix: {0}, index in data column collection: {1}, column name: {2}",i,selectedColumns[i],collection[selectedColumns[i]].Name));
      */
 }
예제 #10
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="collection">DataColumnCollection from which to select the data columns that are part of the matrix by their indices.</param>
 /// <param name="selectedColumns">The indices of the data columns in the collection that are part of the matrix</param>
 /// <param name="selectedRows">Selected rows of the data table that participate in the matrix. Remember that this are the columns of the wrapped matrix. This collection is not cloned here, therefore it must not be subsequently changed!</param>
 public DataColumnToRowMatrixWrapper(Altaxo.Data.DataColumnCollection collection, Altaxo.Collections.IAscendingIntegerCollection selectedColumns, Altaxo.Collections.IAscendingIntegerCollection selectedRows)
     : base(collection, selectedColumns, selectedRows)
 {
 }
예제 #11
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="column">The <see cref="DataColumn" /> to wrap.</param>
 /// <param name="selectedRows">The set of rows that are part of the vector. This collection is not cloned here, therefore it must not be subsequently changed!</param>
 public DoubleColumnSelectedRowsToVectorWrapper(Altaxo.Data.DoubleColumn column, IAscendingIntegerCollection selectedRows)
 {
     _column = column;
     _rows   = selectedRows;
 }
예제 #12
0
 /// <summary>
 /// Moves the selected columns along with their corresponding property values to a new position.
 /// </summary>
 /// <param name="selectedIndices">The indices of the columns to move.</param>
 /// <param name="newPosition">The index of the new position where the columns are moved to.</param>
 public void ChangeColumnPosition(Altaxo.Collections.IAscendingIntegerCollection selectedIndices, int newPosition)
 {
     this._dataColumns.ChangeColumnPosition(selectedIndices, newPosition);
     this._propertyColumns.ChangeRowPosition(selectedIndices, newPosition);
 }
예제 #13
0
 /// <summary>
 /// Wrapps a set of <see cref="DataColumn" />s into a writeable matrix so that the matrix rows corresponds to the <see cref="DataColumn" />s.
 /// </summary>
 /// <param name="collection">DataColumnCollection from which to select the data columns that are part of the matrix by their indices.</param>
 /// <param name="selectedColumns">The indices of the data columns in the collection that are part of the matrix. You can subsequently change this parameter without affecting this wrapper.</param>
 /// <param name="nRows">Number of rows of the data table that participate in the matrix (starting from index 0). Remember that this are the columns of the wrapped matrix.</param>
 public static IMatrix <double> ToRowMatrix(Altaxo.Data.DataColumnCollection collection, Altaxo.Collections.IAscendingIntegerCollection selectedColumns, int nRows)
 {
     return(new DataColumnToRowMatrixWrapper(collection, selectedColumns, Altaxo.Collections.ContiguousIntegerRange.FromStartAndCount(0, nRows)));
 }
예제 #14
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="collection">Collection of <see cref="DataColumn" />s. It is not cloned, so make sure it don't change during usage.</param>
 /// <param name="selectedRows">The set of rows that are part of the matrix. This collection is not cloned here, therefore it must not be subsequently changed!</param>
 public DataColumnToColumnROMatrixWrapper(Altaxo.Data.INumericColumn[] collection, Altaxo.Collections.IAscendingIntegerCollection selectedRows)
 {
     _columns = collection;
     _rows    = selectedRows;
 }
예제 #15
0
			/// <summary>
			/// Constructor
			/// </summary>
			/// <param name="column">The <see cref="DataColumn" /> to wrap.</param>
			/// <param name="selectedRows">The set of rows that are part of the vector. This collection is not cloned here, therefore it must not be subsequently changed!</param>
			public NumericColumnSelectedRowsToROVectorWrapper(Altaxo.Data.INumericColumn column, IAscendingIntegerCollection selectedRows)
			{
				_column = column;
				_rows = selectedRows;
			}
예제 #16
0
			/// <summary>
			/// Constructor
			/// </summary>
			/// <param name="column">The <see cref="DataColumn" /> to wrap.</param>
			/// <param name="selectedRows">The set of rows that are part of the vector. This collection is not cloned here, therefore it must not be subsequently changed!</param>
			public DoubleColumnSelectedRowsToVectorWrapper(Altaxo.Data.DoubleColumn column, IAscendingIntegerCollection selectedRows)
			{
				_column = column;
				_rows = selectedRows;
			}
예제 #17
0
			/// <summary>
			/// Constructor
			/// </summary>
			/// <param name="collection">Collection of <see cref="DataColumn" />s. It is not cloned, so make sure it don't change during usage.</param>
			/// <param name="selectedRows">The set of rows that are part of the matrix. This collection is not cloned here, therefore it must not be subsequently changed!</param>
			public DataColumnToColumnROMatrixWrapper(Altaxo.Data.INumericColumn[] collection, Altaxo.Collections.IAscendingIntegerCollection selectedRows)
			{
				_columns = collection;
				_rows = selectedRows;
			}
예제 #18
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="column">The <see cref="DataColumn" /> to wrap.</param>
 /// <param name="selectedRows">The set of rows that are part of the vector. This collection is not cloned here, therefore it must not be subsequently changed!</param>
 public NumericColumnSelectedRowsToROVectorWrapper(Altaxo.Data.INumericColumn column, IAscendingIntegerCollection selectedRows)
 {
     _column = column;
     _rows   = selectedRows;
 }
예제 #19
0
 /// <summary>
 /// Wraps a set of <see cref="DataColumn" />s into a readonly matrix so that the matrix columns corresponds to the <see cref="DataColumn" />s.
 /// </summary>
 /// <param name="collection">Collection of <see cref="DataColumn" />s.</param>
 /// <param name="selectedRows">The set of rows that are part of the matrix. This collection will be cloned here, i.e. you can subsequently change it without affecting this wrapper.</param>
 /// <returns>The wrapping read only matrix.</returns>
 public static IROMatrix <double> ToROColumnMatrix(Altaxo.Data.INumericColumn[] collection, Altaxo.Collections.IAscendingIntegerCollection selectedRows)
 {
     return(new DataColumnToColumnROMatrixWrapper(collection, selectedRows));
 }