/// <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)); }
/// <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))); }
public VectorXD Mult(VectorXD other) { double[] outVector = new double[Rows]; EigenDenseUtilities.Mult(GetValues(), Rows, Cols, other.GetValues(), other.Length, outVector); return(new VectorXD(outVector)); }
/// <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))); }
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)); }
/// <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)); }
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))); }
/// <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))); }
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))); }
public double Dot(VectorXD other) { return(EigenDenseUtilities.Dot(GetValues(), other.GetValues(), Length)); }
/// <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)); }
/// <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)); }
/// <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)); }
public double Lp1Norm() { return(EigenDenseUtilities.Lp1Norm(GetValues(), Length)); }
public VectorXD Scale(double scalar) { double[] outVector = new double[Length]; EigenDenseUtilities.Scale(GetValues(), scalar, Length, outVector); return(new VectorXD(outVector)); }
public double SquaredNorm() { return(EigenDenseUtilities.SquaredNorm(GetValues(), Rows, Cols)); }
public double SquaredNorm() { return(EigenDenseUtilities.SquaredNorm(GetValues(), Length)); }
public MatrixXD Transpose() { double[] outMatrix = new double[Rows * Cols]; EigenDenseUtilities.Transpose(GetValues(), Rows, Cols, outMatrix); return(new MatrixXD(outMatrix, Cols, Rows)); }
public double Trace() { return(EigenDenseUtilities.Trace(GetValues(), Rows, Cols)); }
/// <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)); }
public double Determinant() { return(EigenDenseUtilities.Determinant(GetValues(), Rows, Cols)); }
public MatrixXD Inverse() { double[] vout = new double[Rows * Cols]; EigenDenseUtilities.Determinant(GetValues(), Rows, Cols, vout); return(new MatrixXD(vout, Rows, Cols)); }
public double RelativeError(VectorXD rhs, VectorXD x) { return(EigenDenseUtilities.RelativeError(GetValues(), Rows, Cols, rhs.GetValues(), x.GetValues())); }
public double Lp1Norm() { return(EigenDenseUtilities.Lp1Norm(GetValues(), Rows, Cols)); }
public VectorXD Add(VectorXD other) { double[] outVector = new double[Length]; EigenDenseUtilities.Add(GetValues(), other.GetValues(), Length, outVector); return(new VectorXD(outVector)); }