/// <summary>
        /// Transposes a given lower triangular matrix in place.
        /// </summary>
        /// <param name="L">Matrix to transpose.  Contents are corrupted on exit.</param>
        /// <returns>An upper triangular wrapper of L's source array.</returns>
        /// <remarks>L is no longer a valid lower triangular matrix.</remarks>
        public static UpperTriangularMatrix TransposeInPlace(LowerTriangularMatrix L)
        {
            L.CheckLowerTriangular();
            UpperTriangularMatrix U = new UpperTriangularMatrix(L.Cols, L.Rows,
                                                                L.SourceArray);

            Assert.IsTrue(U.Rows == U.Cols);
            for (int i = 0; i < U.Rows; ++i)
            {
                for (int j = i + 1; j < U.Cols; ++j)
                {
                    U[i, j] = U[j, i];
                    U[j, i] = 0;
                }
            }
            U.CheckUpperTriangular();
            return(U);
        }
        /// <remarks>U is no longer a valid upper triangular matrix.</remarks>
        public static LowerTriangularMatrix TransposeInPlace(UpperTriangularMatrix U)
        {
            U.CheckUpperTriangular();
            LowerTriangularMatrix L = new LowerTriangularMatrix(U.Cols, U.Rows,
                                                                U.SourceArray, U.Start);

            Assert.IsTrue(L.Rows == L.Cols);
            for (int i = 0; i < L.Rows; ++i)
            {
                for (int j = 0; j < i; ++j)
                {
                    L[i, j] = L[j, i];
                    L[j, i] = 0;
                }
            }
            L.CheckLowerTriangular();
            return(L);
        }
 public UpperTriangularMatrix GetsTranspose(LowerTriangularMatrix L)
 {
     if (rows != L.Cols || cols != L.Rows)
     {
         throw new ArgumentException("Output matrix is not compatible with the transpose", "that");
     }
     L.CheckLowerTriangular();
     // lower triangle of this is assumed to be zero
     for (int i = 0; i < rows; ++i)
     {
         for (int j = i; j < cols; ++j)
         {
             this[i, j] = L[j, i];
         }
     }
     CheckUpperTriangular();
     return(this);
 }