Beispiel #1
0
        /// <summary>
        /// A low-Performance method to permute the affine part of some operator according to the GlobalID-permutation;
        /// </summary>
        /// <param name="Affine"></param>
        /// <param name="grd"></param>
        /// <param name="RowMap"></param>
        /// <returns></returns>
        ///  <remarks>
        /// Low-Performance implementation, only for debugging purposes.
        /// </remarks>
        public static IList <double> ResortAffine(this IList <double> Affine, GridData grd, UnsetteledCoordinateMapping RowMap)
        {
            if (RowMap.LocalLength != Affine.Count)
            {
                throw new ArgumentException();
            }

            // Copy values of Affine to diagonal matrix
            MsrMatrix Matrix = new MsrMatrix(RowMap, RowMap);
            int       i0     = RowMap.i0;

            for (int row = 0; row < RowMap.LocalLength; row++)
            {
                Matrix[i0 + row, i0 + row] = Affine[row];
            }

            // Permute matrix
            MsrMatrix MatrixPermuted = Matrix.ResortMatrix(grd, RowMap, RowMap);

            // Copy values from permuted matrix to permuted affine
            IList <double> AffinePermuted = new double[Affine.Count];

            for (int row = 0; row < RowMap.LocalLength; row++)
            {
                AffinePermuted[row] = MatrixPermuted[i0 + row, i0 + row];
            }

            return(AffinePermuted);
        }