コード例 #1
0
ファイル: SquareMatrix.cs プロジェクト: zyzhu/metanumerics
 /// <summary>
 /// Computes a QR decomposition of the matrix.
 /// </summary>
 /// <returns>A QR decomposition of the matrix.</returns>
 /// <seealso cref="Matrices.QRDecomposition"/>
 public SquareQRDecomposition QRDecomposition()
 {
     double[] rStore  = MatrixAlgorithms.Copy(store, offset, rowStride, colStride, dimension, dimension);
     double[] qtStore = SquareMatrixAlgorithms.CreateUnitMatrix(dimension);
     MatrixAlgorithms.QRDecompose(rStore, qtStore, dimension, dimension);
     return(new SquareQRDecomposition(qtStore, rStore, dimension));
 }
コード例 #2
0
        // complicated specific operations

        /// <summary>
        /// Computes the QR decomposition of the matrix.
        /// </summary>
        /// <returns>The QR decomposition of the matrix.</returns>
        /// <remarks>
        /// <para>Only matrices with a number of rows greater than or equal to the number of columns can be QR decomposed. If your
        /// matrix has more columns than rows, you can QR decompose its transpose.</para>
        /// </remarks>
        /// <seealso cref="QRDecomposition"/>
        public QRDecomposition QRDecomposition()
        {
            if (rows < cols)
            {
                throw new InvalidOperationException();
            }

            double[] rStore = MatrixAlgorithms.Copy(store, offset, rowStride, colStride, rows, cols);

            double[] qtStore = SquareMatrixAlgorithms.CreateUnitMatrix(rows);

            MatrixAlgorithms.QRDecompose(rStore, qtStore, rows, cols);

            return(new QRDecomposition(qtStore, rStore, rows, cols));
        }