Ejemplo n.º 1
0
 /// <summary>
 /// Transpose the CVS instance in place.
 /// </summary>
 public void Transpose()
 {
     (int rows, int columns)size = (Size.columns, Size.rows);
     Parallel.ForEach(LinearIndex, (lis) =>
     {
         for (int i = 0; i < lis.Count; i++)
         {
             lis[i] = MatrixCoordinates.TransposeLinearIndex(Size, lis[i], LinearIndexMode).linearIndex;
         }
         lis.Sort();
     });
     Size = size;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Transpose the matrix to a new CVS instance.
        /// </summary>
        /// <param name="cvs">The matrix as CVS.</param>
        /// <returns>The transposed matrix as CVS.</returns>
        public CVS <T> TransposeToNewCVS()
        {
            (List <T> value, List <List <int> > linearIndex, MatrixLinearIndexMode linearIndexMode, (int rows, int columns)size) = this;
            List <T>           newValue       = new List <T>();
            List <List <int> > newLinearIndex = new List <List <int> >();
            List <int>         lis;

            for (int i = 0; i < value.Count; i++)
            {
                newValue.Add(value[i]);
                lis = new List <int>();
                foreach (var li in linearIndex[i])
                {
                    lis.Add(MatrixCoordinates.TransposeLinearIndex(size, li, linearIndexMode).linearIndex);
                }
                lis.Sort();
                newLinearIndex.Add(lis);
            }
            return(new CVS <T>(newValue, newLinearIndex, linearIndexMode, (size.columns, size.rows)));
        }