Esempio n. 1
0
 /// <summary>
 /// Creates a new view in which the rows of the matrix (but not the row keys) are permuted.
 /// 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="rowIndexSequence">The indexes of the rows in their new order. Every row index must be mentioned exactly once.</param>
 /// <remarks>If the permutation puts every row back in the same place, the parent matrix is returned.</remarks>
 /// <returns>A new matrix with permuted rows.</returns>
 static public Matrix <TRowKey, TColKey, TValue> PermuteRowValuesForEachColView <TRowKey, TColKey, TValue>(this Matrix <TRowKey, TColKey, TValue> parentMatrix, IEnumerable <int> rowIndexSequence)
 {
     return(parentMatrix.TransposeView().PermuteColValuesForEachRowView(rowIndexSequence).TransposeView());
 }
Esempio n. 2
0
 /// <summary>
 /// Create a new view of the parent matrix in which the rows are renamed.
 /// 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="newKeyAndOldKeySequence">A sequence of pair mapping from new keys to the old keys, for example, a dictionary
 /// More than one new key can map to an old key.
 /// or a list of KeyValuePair's. Any parent row with a rowKey that isn't mentioned will be inaccessable.
 /// The new rows will be in the order of given in the sequence.</param>
 /// <remarks>If newKeyAndOldKeySequence maps every key to itself, in the same order, the parent matrix will be returned.</remarks>
 /// <returns>A matrix with renamed rows.</returns>
 static public Matrix <TRowKey, TColKey, TValue> RenameRowsView <TRowKey, TColKey, TValue>(
     this Matrix <TRowKey, TColKey, TValue> parentMatrix, IEnumerable <KeyValuePair <TRowKey, TRowKey> > newKeyAndOldKeySequence)
 {
     return(parentMatrix.TransposeView().RenameColsView(newKeyAndOldKeySequence).TransposeView());
 }