/// <summary> /// Create a view of a parent matrix with a subset of the rows (perhaps in a different order). /// If the subsets happen to include all rows in the same order, the parent matrix is returned. /// This is a 'view' in the sense that changes to the values in either matrix will be reflected in both. /// </summary> /// <typeparam name="TRowKey">The type of the row key. Usually "String"</typeparam> /// <typeparam name="TColKey">The type of the col key. Usually "String"</typeparam> /// <typeparam name="TValue">The type of the value, for example, double, int, char, etc.</typeparam> /// <param name="parentMatrix">The matrix to wrap.</param> /// <param name="rowIndexEnumerable">A sequence of row indexes that specifies the subset of rows to include and their desired order.</param> /// <returns>A matrix with the desired rows and cols in their desired order.</returns> static public Matrix <TRowKey, TColKey, TValue> SelectRowsView <TRowKey, TColKey, TValue>( this Matrix <TRowKey, TColKey, TValue> parentMatrix, IEnumerable <int> rowIndexEnumerable) { return(parentMatrix.SelectRowsAndColsView( rowIndexEnumerable.Select(rowIndex => parentMatrix.RowKeys[rowIndex]), parentMatrix.ColKeys)); }
/// <summary> /// Create a view of a parent matrix with a subset of the cols (perhaps in a different order). /// If the subsets happen to include all cols in the same order, the parent matrix is returned. /// This is a 'view' in the sense that changes to the values in either matrix will be reflected in both. /// </summary> /// <typeparam name="TRowKey">The type of the row key. Usually "String"</typeparam> /// <typeparam name="TColKey">The type of the col key. Usually "String"</typeparam> /// <typeparam name="TValue">The type of the value, for example, double, int, char, etc.</typeparam> /// <param name="parentMatrix">The matrix to wrap.</param> /// <param name="colIndexSequence">A sequence of col indexes that specifies the subset of cols to include and their desired order.</param> /// <returns>A matrix with the desired cols in their desired order.</returns> static public Matrix <TRowKey, TColKey, TValue> SelectColsView <TRowKey, TColKey, TValue>( this Matrix <TRowKey, TColKey, TValue> parentMatrix, IEnumerable <int> colIndexSequence) { return(parentMatrix.SelectRowsAndColsView( parentMatrix.RowKeys, colIndexSequence.Select(colIndex => parentMatrix.ColKeys[colIndex]))); }
/// <summary> /// Create a view of a parent matrix with a subset of the cols (perhaps in a different order). /// If the subset happens to include all /// cols in the same order, the parent matrix is returned. /// This is a 'view' in the sense that changes to the values in either matrix will be reflected in both. /// </summary> /// <typeparam name="TRowKey">The type of the row key. Usually "String"</typeparam> /// <typeparam name="TColKey">The type of the col key. Usually "String"</typeparam> /// <typeparam name="TValue">The type of the value, for example, double, int, char, etc.</typeparam> /// <param name="parentMatrix">The matrix to wrap.</param> /// <param name="colKeySequence">A sequence of colKeys that specifies the subset of cols to include and their desired order.</param> /// <returns>A matrix with the desired cols in their desired order.</returns> static public Matrix <TRowKey, TColKey, TValue> SelectColsView <TRowKey, TColKey, TValue>(this Matrix <TRowKey, TColKey, TValue> parentMatrix, IEnumerable <TColKey> colKeySequence) { return(parentMatrix.SelectRowsAndColsView(parentMatrix.RowKeys, colKeySequence)); }
/// <summary> /// Create a view of a parent matrix with a subset of the rows (perhaps in a different order). /// If the subset happens to include all rows in the same order, the parent matrix is returned. /// This is a 'view' in the sense that changes to the values in either matrix will be reflected in both. /// </summary> /// <typeparam name="TRowKey">The type of the row key. Usually "String"</typeparam> /// <typeparam name="TColKey">The type of the col key. Usually "String"</typeparam> /// <typeparam name="TValue">The type of the value, for example, double, int, char, etc.</typeparam> /// <param name="parentMatrix">The matrix to wrap.</param> /// <param name="rowKeySequence">A sequence of rowKeys that specifies the subset of rows to include and their desired order.</param> /// <returns>A matrix with the desired rows in their desired order.</returns> static public Matrix<TRowKey, TColKey, TValue> SelectRowsView<TRowKey, TColKey, TValue>(this Matrix<TRowKey, TColKey, TValue> parentMatrix, IEnumerable<TRowKey> rowKeySequence) { return parentMatrix.SelectRowsAndColsView(rowKeySequence, parentMatrix.ColKeys); }