Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public VectorXD Solve(VectorXD other, DenseSolverType denseSolverType = DenseSolverType.ColPivHouseholderQR)
        {
            double[] vout = new double[Rows];
            switch (denseSolverType)
            {
            case DenseSolverType.PartialPivLU:
                EigenDenseUtilities.SolvePartialPivLU(GetValues(), Rows, Cols, other.GetValues(), vout);
                break;

            case DenseSolverType.FullPivLU:
                EigenDenseUtilities.SolveFullPivLU(GetValues(), Rows, Cols, other.GetValues(), vout);
                break;

            case DenseSolverType.LDLT:
                EigenDenseUtilities.SolveLDLT(GetValues(), Rows, Cols, other.GetValues(), vout);
                break;

            case DenseSolverType.LLT:
                EigenDenseUtilities.SolveLLT(GetValues(), Rows, Cols, other.GetValues(), vout);
                break;

            case DenseSolverType.ColPivHouseholderQR:
            default:
                EigenDenseUtilities.SolveColPivHouseholderQr(GetValues(), Rows, Cols, other.GetValues(), vout);
                break;
            }

            return(new VectorXD(vout));
        }
Пример #2
0
        /// <summary>
        /// eigenvalues and eigenvectors for symmetric matrix.
        /// </summary>
        /// <returns></returns>
        public SAEigenSolverResult SymmetricEigen()
        {
            double[] realValues       = new double[Rows];
            double[] realEigenvectors = new double[Rows * Cols];

            EigenDenseUtilities.SelfAdjointEigenSolver(GetValues(), Rows, realValues, realEigenvectors);

            return(new SAEigenSolverResult(new VectorXD(realValues), new MatrixXD(realEigenvectors, Rows, Cols)));
        }
Пример #3
0
 public VectorXD Mult(VectorXD other)
 {
     double[] outVector = new double[Rows];
     EigenDenseUtilities.Mult(GetValues(),
                              Rows,
                              Cols,
                              other.GetValues(),
                              other.Length,
                              outVector);
     return(new VectorXD(outVector));
 }
Пример #4
0
        /// <summary>
        /// eigenvalues and eigenvectros.
        /// </summary>
        /// <returns></returns>
        public EigenSolverResult Eigen()
        {
            double[] realValues       = new double[Rows];
            double[] imagValues       = new double[Rows];
            double[] realEigenvectors = new double[Rows * Cols];
            double[] imagEigenvectors = new double[Rows * Cols];

            EigenDenseUtilities.EigenSolver(GetValues(), Rows, realValues, imagValues, realEigenvectors, imagEigenvectors);

            return(new EigenSolverResult(new VectorXCD(realValues, imagValues), new MatrixXCD(realEigenvectors, imagEigenvectors, Rows, Cols)));
        }
Пример #5
0
 public MatrixXD Mult(MatrixXD other)
 {
     double[] outMatrix = new double[Rows * other.Cols];
     EigenDenseUtilities.Mult(GetValues(),
                              Rows,
                              Cols,
                              other.GetValues(),
                              other.Rows,
                              other.Cols,
                              outMatrix);
     return(new MatrixXD(outMatrix, Rows, other.Cols));
 }
Пример #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="rhs"></param>
        public VectorXD LeastSquaresSVD(VectorXD rhs, SVDType svdType = SVDType.Jacobi)
        {
            double[] vout = new double[Cols];
            if (svdType == SVDType.Jacobi)
            {
                EigenDenseUtilities.SVDLeastSquares(GetValues(), Rows, Cols, rhs.GetValues(), vout);
            }
            else
            {
                EigenDenseUtilities.SVDLeastSquaresBdcSvd(GetValues(), Rows, Cols, rhs.GetValues(), vout);
            }

            return(new VectorXD(vout));
        }
Пример #7
0
        public FullPivLUResult FullPivLU()
        {
            double[] l = new double[Rows * Rows];
            double[] u = new double[Rows * Cols];
            double[] p = new double[Rows * Rows];
            double[] q = new double[Cols * Cols];

            EigenDenseUtilities.FullPivLU(GetValues(), Rows, Cols, l, u, p, q);

            var L = new MatrixXD(l, Rows, Rows);

            L.SetDiag(1.0);
            return(new FullPivLUResult(L,
                                       new MatrixXD(u, Rows, Cols),
                                       new MatrixXD(p, Rows, Rows),
                                       new MatrixXD(q, Cols, Cols)));
        }
Пример #8
0
        /// <summary>
        /// QR decomposition
        /// </summary>
        /// <param name="qRType"></param>
        /// <returns></returns>
        public QRResult QR(QRType qRType = QRType.HouseholderQR)
        {
            double[] q = new double[Rows * Rows];
            double[] r = new double[Rows * Cols];

            switch (qRType)
            {
            case QRType.ColPivHouseholderQR:
                double[] p = new double[Cols * Cols];
                EigenDenseUtilities.ColPivHouseholderQR(GetValues(), Rows, Cols, q, r, p);
                return(new QRResult(new MatrixXD(q, Rows, Rows), new MatrixXD(r, Rows, Cols), new MatrixXD(p, Cols, Cols)));

            case QRType.HouseholderQR:
            default:
                EigenDenseUtilities.HouseholderQR(GetValues(), Rows, Cols, q, r);
                break;
            }

            return(new QRResult(new MatrixXD(q, Rows, Rows), new MatrixXD(r, Rows, Cols)));
        }
Пример #9
0
        public SVDResult SVD(SVDType svdType = SVDType.Jacobi)
        {
            int minRowsCols = Cols < Rows ? Cols : Rows;

            double[] uout = new double[Rows * minRowsCols];
            double[] sout = new double[minRowsCols];
            double[] vout = new double[Cols * minRowsCols];

            if (svdType == SVDType.Jacobi)
            {
                EigenDenseUtilities.SVD(GetValues(), Rows, Cols, uout, sout, vout);
            }
            else
            {
                EigenDenseUtilities.SVDBdcSvd(GetValues(), Rows, Cols, uout, sout, vout);
            }

            return(new SVDResult(new MatrixXD(uout, Rows, minRowsCols),
                                 new VectorXD(sout),
                                 new MatrixXD(vout, Cols, minRowsCols)));
        }
Пример #10
0
 public double Dot(VectorXD other)
 {
     return(EigenDenseUtilities.Dot(GetValues(), other.GetValues(), Length));
 }
Пример #11
0
 /// <summary>
 /// X = A^T * A;
 /// </summary>
 public MatrixXD TMult()
 {
     double[] outMatrix = new double[Cols * Cols];
     EigenDenseUtilities.TMult(GetValues(), Rows, Cols, outMatrix);
     return(new MatrixXD(outMatrix, Cols, Cols));
 }
Пример #12
0
 /// <summary>
 /// X = A * A^T;
 /// </summary>
 public MatrixXD MultT()
 {
     double[] outMatrix = new double[Rows * Rows];
     EigenDenseUtilities.MultT(GetValues(), Rows, Rows, outMatrix);
     return(new MatrixXD(outMatrix, Rows, Rows));
 }
Пример #13
0
 /// <summary>
 /// X = A + A^T;
 /// </summary>
 public MatrixXD PlusT()
 {
     double[] outMatrix = new double[Rows * Cols];
     EigenDenseUtilities.PlusT(GetValues(), Rows, outMatrix);
     return(new MatrixXD(outMatrix, Rows, Cols));
 }
Пример #14
0
 public double Lp1Norm()
 {
     return(EigenDenseUtilities.Lp1Norm(GetValues(), Length));
 }
Пример #15
0
 public VectorXD Scale(double scalar)
 {
     double[] outVector = new double[Length];
     EigenDenseUtilities.Scale(GetValues(), scalar, Length, outVector);
     return(new VectorXD(outVector));
 }
Пример #16
0
 public double SquaredNorm()
 {
     return(EigenDenseUtilities.SquaredNorm(GetValues(), Rows, Cols));
 }
Пример #17
0
 public double SquaredNorm()
 {
     return(EigenDenseUtilities.SquaredNorm(GetValues(), Length));
 }
Пример #18
0
 public MatrixXD Transpose()
 {
     double[] outMatrix = new double[Rows * Cols];
     EigenDenseUtilities.Transpose(GetValues(), Rows, Cols, outMatrix);
     return(new MatrixXD(outMatrix, Cols, Rows));
 }
Пример #19
0
 public double Trace()
 {
     return(EigenDenseUtilities.Trace(GetValues(), Rows, Cols));
 }
Пример #20
0
 /// <summary>
 /// A^TAx = A^b
 /// </summary>
 /// <param name="rhs"></param>
 /// <returns></returns>
 public VectorXD LeastSquaresNE(VectorXD rhs)
 {
     double[] vout = new double[Cols];
     EigenDenseUtilities.NormalEquationsLeastSquares(GetValues(), Rows, Cols, rhs.GetValues(), vout);
     return(new VectorXD(vout));
 }
Пример #21
0
 public double Determinant()
 {
     return(EigenDenseUtilities.Determinant(GetValues(), Rows, Cols));
 }
Пример #22
0
 public MatrixXD Inverse()
 {
     double[] vout = new double[Rows * Cols];
     EigenDenseUtilities.Determinant(GetValues(), Rows, Cols, vout);
     return(new MatrixXD(vout, Rows, Cols));
 }
Пример #23
0
 public double RelativeError(VectorXD rhs, VectorXD x)
 {
     return(EigenDenseUtilities.RelativeError(GetValues(), Rows, Cols, rhs.GetValues(), x.GetValues()));
 }
Пример #24
0
 public double Lp1Norm()
 {
     return(EigenDenseUtilities.Lp1Norm(GetValues(), Rows, Cols));
 }
Пример #25
0
 public VectorXD Add(VectorXD other)
 {
     double[] outVector = new double[Length];
     EigenDenseUtilities.Add(GetValues(), other.GetValues(), Length, outVector);
     return(new VectorXD(outVector));
 }