/// <summary> /// A low-Performance method to permute some operator Matrix according to the GlobalID-permutation; /// </summary> /// <param name="M"></param> /// <param name="grd"></param> /// <param name="RowMap"></param> /// <param name="ColMap"></param> /// <returns></returns> /// <remarks> /// Low-Performance implementation, only for debugging purposes. /// </remarks> public static MsrMatrix ResortMatrix(this MsrMatrix M, GridData grd, UnsetteledCoordinateMapping RowMap, UnsetteledCoordinateMapping ColMap) { if (!M.RowPartitioning.Equals(RowMap)) { throw new ArgumentException(); } if (!M.ColPartition.Equals(ColMap)) { throw new ArgumentException(); } int[] RowPerm = ComputePermutation(RowMap, grd); int[] ColPerm = ComputePermutation(ColMap, grd); // permute columns MsrMatrix M2 = ColumnPermute(M, ColPerm); // permute rows MsrMatrix M3 = ColumnPermute(M2.Transpose(), RowPerm).Transpose(); // return return(M3); }