/// <summary> /// Creates a new view in which the columns of the matrix (but not the column 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="colKeySequence">The colKeys of the columns in their new order. Every colKey must be mentioned exactly once.</param> /// <remarks>If the permutation puts every column back in the same place, the parent matrix is returned.</remarks> /// <returns>A new matrix with permuted columns.</returns> static public Matrix <TRowKey, TColKey, TValue> PermuteColValuesForEachRowView <TRowKey, TColKey, TValue>(this Matrix <TRowKey, TColKey, TValue> parentMatrix, IEnumerable <TColKey> colKeySequence) { return(parentMatrix.PermuteColValuesForEachRowView( colKeySequence.Select(colKey => parentMatrix.IndexOfColKey[colKey]))); }