| ap.h | | ap.h | |
| | | | |
| skipping to change at line 41 | | skipping to change at line 41 | |
| #include <list.h> | | #include <list.h> | |
| #include <vector.h> | | #include <vector.h> | |
| #else | | #else | |
| #include <list> | | #include <list> | |
| #include <vector> | | #include <vector> | |
| #endif | | #endif | |
| | | | |
| /******************************************************************** | | /******************************************************************** | |
| Array bounds check | | Array bounds check | |
| ********************************************************************/ | | ********************************************************************/ | |
|
| #define AP_ASSERT | | #define NO_AP_ASSERT | |
| | | | |
| #ifndef AP_ASSERT // | | #ifndef AP_ASSERT // | |
| #define NO_AP_ASSERT // This code avoids definition of the | | #define NO_AP_ASSERT // This code avoids definition of the | |
| #endif // both AP_ASSERT and NO_AP_ASSERT symbols | | #endif // both AP_ASSERT and NO_AP_ASSERT symbols | |
| #ifdef NO_AP_ASSERT // | | #ifdef NO_AP_ASSERT // | |
| #ifdef AP_ASSERT // | | #ifdef AP_ASSERT // | |
| #undef NO_AP_ASSERT // | | #undef NO_AP_ASSERT // | |
| #endif // | | #endif // | |
| #endif // | | #endif // | |
| | | | |
| | | | |
| skipping to change at line 182 | | skipping to change at line 182 | |
| const double abscomplex(const complex &z); | | const double abscomplex(const complex &z); | |
| const complex conj(const complex &z); | | const complex conj(const complex &z); | |
| const complex csqr(const complex &z); | | const complex csqr(const complex &z); | |
| | | | |
| /******************************************************************** | | /******************************************************************** | |
| Templates for vector operations | | Templates for vector operations | |
| ********************************************************************/ | | ********************************************************************/ | |
| #include "apvt.h" | | #include "apvt.h" | |
| | | | |
| /******************************************************************** | | /******************************************************************** | |
|
| BLAS functions | | Level 1 BLAS functions | |
| | | ********************************************************************/ | |
| | | double vdotproduct(const double *v0, int stride0, const double *v1, int str | |
| | | ide1, int n); | |
| | | complex vdotproduct(const complex *v0, int stride0, const char *conj0, cons | |
| | | t complex *v1, int stride1, const char *conj1, int n); | |
| | | | |
| | | void vmove(double *vdst, int stride_dst, const double* vsrc, int stride_s | |
| | | rc, int n); | |
| | | void vmove(complex *vdst, int stride_dst, const complex* vsrc, int stride_s | |
| | | rc, const char *conj_src, int n); | |
| | | | |
| | | void vmoveneg(double *vdst, int stride_dst, const double* vsrc, int strid | |
| | | e_src, int n); | |
| | | void vmoveneg(complex *vdst, int stride_dst, const complex* vsrc, int strid | |
| | | e_src, const char *conj_src, int n); | |
| | | | |
| | | void vmove(double *vdst, int stride_dst, const double* vsrc, int stride_s | |
| | | rc, int n, double alpha); | |
| | | void vmove(complex *vdst, int stride_dst, const complex* vsrc, int stride_s | |
| | | rc, const char *conj_src, int n, double alpha); | |
| | | void vmove(complex *vdst, int stride_dst, const complex* vsrc, int stride_s | |
| | | rc, const char *conj_src, int n, complex alpha); | |
| | | | |
| | | void vadd(double *vdst, int stride_dst, const double *vsrc, int stride_sr | |
| | | c, int n); | |
| | | void vadd(complex *vdst, int stride_dst, const complex *vsrc, int stride_sr | |
| | | c, const char *conj_src, int n); | |
| | | | |
| | | void vadd(double *vdst, int stride_dst, const double *vsrc, int stride_sr | |
| | | c, int n, double alpha); | |
| | | void vadd(complex *vdst, int stride_dst, const complex *vsrc, int stride_sr | |
| | | c, const char *conj_src, int n, double alpha); | |
| | | void vadd(complex *vdst, int stride_dst, const complex *vsrc, int stride_sr | |
| | | c, const char *conj_src, int n, complex alpha); | |
| | | | |
| | | void vsub(double *vdst, int stride_dst, const double *vsrc, int stride_sr | |
| | | c, int n); | |
| | | void vsub(complex *vdst, int stride_dst, const complex *vsrc, int stride_sr | |
| | | c, const char *conj_src, int n); | |
| | | | |
| | | void vsub(double *vdst, int stride_dst, const double *vsrc, int stride_sr | |
| | | c, int n, double alpha); | |
| | | void vsub(complex *vdst, int stride_dst, const complex *vsrc, int stride_sr | |
| | | c, const char *conj_src, int n, double alpha); | |
| | | void vsub(complex *vdst, int stride_dst, const complex *vsrc, int stride_sr | |
| | | c, const char *conj_src, int n, complex alpha); | |
| | | | |
| | | void vmul(double *vdst, int stride_dst, int n, double alpha); | |
| | | void vmul(complex *vdst, int stride_dst, int n, double alpha); | |
| | | void vmul(complex *vdst, int stride_dst, int n, complex alpha); | |
| | | | |
| | | /******************************************************************** | |
| | | Obsolete BLAS functions | |
| ********************************************************************/ | | ********************************************************************/ | |
| double vdotproduct(const double *v1, const double *v2, int N); | | double vdotproduct(const double *v1, const double *v2, int N); | |
| complex vdotproduct(const complex *v1, const complex *v2, int N); | | complex vdotproduct(const complex *v1, const complex *v2, int N); | |
| | | | |
| void vmove(double *vdst, const double* vsrc, int N); | | void vmove(double *vdst, const double* vsrc, int N); | |
| void vmove(complex *vdst, const complex* vsrc, int N); | | void vmove(complex *vdst, const complex* vsrc, int N); | |
| | | | |
| void vmoveneg(double *vdst, const double *vsrc, int N); | | void vmoveneg(double *vdst, const double *vsrc, int N); | |
| void vmoveneg(complex *vdst, const complex *vsrc, int N); | | void vmoveneg(complex *vdst, const complex *vsrc, int N); | |
| | | | |
| | | | |
| skipping to change at line 297 | | skipping to change at line 331 | |
| { | | { | |
| if( Aligned ) | | if( Aligned ) | |
| ap::afree(m_Vec); | | ap::afree(m_Vec); | |
| else | | else | |
| delete[] m_Vec; | | delete[] m_Vec; | |
| } | | } | |
| m_iLow = iLow; | | m_iLow = iLow; | |
| m_iHigh = iHigh; | | m_iHigh = iHigh; | |
| m_iVecSize = iHigh-iLow+1; | | m_iVecSize = iHigh-iLow+1; | |
| if( Aligned ) | | if( Aligned ) | |
|
| m_Vec = (T*)ap::amalloc(m_iVecSize*sizeof(T), 16); | | m_Vec = (T*)ap::amalloc((size_t)(m_iVecSize*sizeof(T)), 16); | |
| else | | else | |
|
| m_Vec = new T[m_iVecSize]; | | m_Vec = new T[(size_t)m_iVecSize]; | |
| }; | | }; | |
| | | | |
| void setlength(int iLen) | | void setlength(int iLen) | |
| { | | { | |
| setbounds(0, iLen-1); | | setbounds(0, iLen-1); | |
| } | | } | |
| | | | |
| void setcontent( int iLow, int iHigh, const T *pContent ) | | void setcontent( int iLow, int iHigh, const T *pContent ) | |
| { | | { | |
| setbounds(iLow, iHigh); | | setbounds(iLow, iHigh); | |
| | | | |
| skipping to change at line 472 | | skipping to change at line 506 | |
| int n2 = iHigh2-iLow2+1; | | int n2 = iHigh2-iLow2+1; | |
| m_iVecSize = n1*n2; | | m_iVecSize = n1*n2; | |
| if( Aligned ) | | if( Aligned ) | |
| { | | { | |
| //if( n2%2!=0 ) | | //if( n2%2!=0 ) | |
| while( (n2*sizeof(T))%16!=0 ) | | while( (n2*sizeof(T))%16!=0 ) | |
| { | | { | |
| n2++; | | n2++; | |
| m_iVecSize += n1; | | m_iVecSize += n1; | |
| } | | } | |
|
| m_Vec = (T*)ap::amalloc(m_iVecSize*sizeof(T), 16); | | m_Vec = (T*)ap::amalloc((size_t)(m_iVecSize*sizeof(T)), 16); | |
| } | | } | |
| else | | else | |
|
| m_Vec = new T[m_iVecSize]; | | m_Vec = new T[(size_t)m_iVecSize]; | |
| m_iLow1 = iLow1; | | m_iLow1 = iLow1; | |
| m_iHigh1 = iHigh1; | | m_iHigh1 = iHigh1; | |
| m_iLow2 = iLow2; | | m_iLow2 = iLow2; | |
| m_iHigh2 = iHigh2; | | m_iHigh2 = iHigh2; | |
| m_iConstOffset = -m_iLow2-m_iLow1*n2; | | m_iConstOffset = -m_iLow2-m_iLow1*n2; | |
| m_iLinearMember = n2; | | m_iLinearMember = n2; | |
| }; | | }; | |
| | | | |
| void setlength(int iLen1, int iLen2) | | void setlength(int iLen1, int iLen2) | |
| { | | { | |
| | | | |
| skipping to change at line 539 | | skipping to change at line 573 | |
| return const_raw_vector<T>(&((*this)(iRowStart, iColumn)), iRow
End-iRowStart+1, m_iLinearMember); | | return const_raw_vector<T>(&((*this)(iRowStart, iColumn)), iRow
End-iRowStart+1, m_iLinearMember); | |
| }; | | }; | |
| | | | |
| const_raw_vector<T> getrow(int iRow, int iColumnStart, int iColumnEnd)
const | | const_raw_vector<T> getrow(int iRow, int iColumnStart, int iColumnEnd)
const | |
| { | | { | |
| if( (iColumnStart>iColumnEnd) || wrongRow(iRow) || wrongColumn(iCol
umnStart) || wrongColumn(iColumnEnd)) | | if( (iColumnStart>iColumnEnd) || wrongRow(iRow) || wrongColumn(iCol
umnStart) || wrongColumn(iColumnEnd)) | |
| return const_raw_vector<T>(0, 0, 1); | | return const_raw_vector<T>(0, 0, 1); | |
| else | | else | |
| return const_raw_vector<T>(&((*this)(iRow, iColumnStart)), iCol
umnEnd-iColumnStart+1, 1); | | return const_raw_vector<T>(&((*this)(iRow, iColumnStart)), iCol
umnEnd-iColumnStart+1, 1); | |
| }; | | }; | |
|
| | | | |
| | | int getstride() const | |
| | | { | |
| | | return m_iLinearMember; | |
| | | }; | |
| private: | | private: | |
| bool wrongRow(int i) const { return i<m_iLow1 || i>m_iHigh1; }; | | bool wrongRow(int i) const { return i<m_iLow1 || i>m_iHigh1; }; | |
| bool wrongColumn(int j) const { return j<m_iLow2 || j>m_iHigh2; }; | | bool wrongColumn(int j) const { return j<m_iLow2 || j>m_iHigh2; }; | |
| | | | |
| T *m_Vec; | | T *m_Vec; | |
| long m_iVecSize; | | long m_iVecSize; | |
| long m_iLow1, m_iLow2, m_iHigh1, m_iHigh2; | | long m_iLow1, m_iLow2, m_iHigh1, m_iHigh2; | |
| long m_iConstOffset, m_iLinearMember; | | long m_iConstOffset, m_iLinearMember; | |
| }; | | }; | |
| | | | |
| | | | |
End of changes. 7 change blocks. |
| 6 lines changed or deleted | | 64 lines changed or added | |
|
| densesolver.h | | densesolver.h | |
| | | | |
| skipping to change at line 35 | | skipping to change at line 35 | |
| #include "ialglib.h" | | #include "ialglib.h" | |
| | | | |
| #include "reflections.h" | | #include "reflections.h" | |
| #include "bidiagonal.h" | | #include "bidiagonal.h" | |
| #include "qr.h" | | #include "qr.h" | |
| #include "lq.h" | | #include "lq.h" | |
| #include "blas.h" | | #include "blas.h" | |
| #include "rotations.h" | | #include "rotations.h" | |
| #include "bdsvd.h" | | #include "bdsvd.h" | |
| #include "svd.h" | | #include "svd.h" | |
|
| #include "lu.h" | | #include "creflections.h" | |
| | | #include "hqrnd.h" | |
| | | #include "matgen.h" | |
| | | #include "ablasf.h" | |
| | | #include "ablas.h" | |
| | | #include "trfac.h" | |
| #include "trlinsolve.h" | | #include "trlinsolve.h" | |
|
| | | #include "safesolve.h" | |
| #include "rcond.h" | | #include "rcond.h" | |
| #include "tsort.h" | | #include "tsort.h" | |
| #include "xblas.h" | | #include "xblas.h" | |
| | | | |
| struct densesolverreport | | struct densesolverreport | |
| { | | { | |
| double r1; | | double r1; | |
| double rinf; | | double rinf; | |
| }; | | }; | |
| | | | |
| | | | |
| skipping to change at line 58 | | skipping to change at line 64 | |
| { | | { | |
| double r2; | | double r2; | |
| ap::real_2d_array cx; | | ap::real_2d_array cx; | |
| int n; | | int n; | |
| int k; | | int k; | |
| }; | | }; | |
| | | | |
| /************************************************************************* | | /************************************************************************* | |
| Dense solver. | | Dense solver. | |
| | | | |
|
| This subroutine solves a system A*X=B, where A is NxN non-denegerate | | This subroutine solves a system A*x=b, where A is NxN non-denegerate | |
| real matrix, X and B are NxM real matrices. | | real matrix, x and b are vectors. | |
| | | | |
|
| Additional features include: | | Algorithm features: | |
| * automatic detection of degenerate cases | | * automatic detection of degenerate cases | |
|
| * iterative improvement | | * condition number estimation | |
| | | * iterative refinement | |
| | | * O(N^3) complexity | |
| | | | |
| INPUT PARAMETERS | | INPUT PARAMETERS | |
| A - array[0..N-1,0..N-1], system matrix | | A - array[0..N-1,0..N-1], system matrix | |
| N - size of A | | N - size of A | |
|
| B - array[0..N-1,0..M-1], right part | | B - array[0..N-1], right part | |
| M - size of right part | | | |
| | | | |
| OUTPUT PARAMETERS | | OUTPUT PARAMETERS | |
| Info - return code: | | Info - return code: | |
|
| * -3 if A is singular, or VERY close to singular. | | * -3 A is singular, or VERY close to singular. | |
| X is filled by zeros in such cases. | | X is filled by zeros in such cases. | |
|
| * -1 if N<=0 or M<=0 was passed | | * -1 N<=0 was passed | |
| * 1 if task is solved (matrix A may be near singular, | | * 1 task is solved (but matrix A may be ill-conditioned | |
| | | , | |
| check R1/RInf parameters for condition numbers). | | check R1/RInf parameters for condition numbers). | |
| Rep - solver report, see below for more info | | Rep - solver report, see below for more info | |
|
| X - array[0..N-1,0..M-1], it contains: | | X - array[0..N-1], it contains: | |
| * solution of A*X=B if A is non-singular (well-conditioned | | * solution of A*x=b if A is non-singular (well-conditioned | |
| or ill-conditioned, but not very close to singular) | | or ill-conditioned, but not very close to singular) | |
| * zeros, if A is singular or VERY close to singular | | * zeros, if A is singular or VERY close to singular | |
| (in this case Info=-3). | | (in this case Info=-3). | |
| | | | |
| SOLVER REPORT | | SOLVER REPORT | |
| | | | |
| Subroutine sets following fields of the Rep structure: | | Subroutine sets following fields of the Rep structure: | |
| * R1 reciprocal of condition number: 1/cond(A), 1-norm. | | * R1 reciprocal of condition number: 1/cond(A), 1-norm. | |
| * RInf reciprocal of condition number: 1/cond(A), inf-norm. | | * RInf reciprocal of condition number: 1/cond(A), inf-norm. | |
| | | | |
|
| SEE ALSO: | | -- ALGLIB -- | |
| DenseSolverR() - solves A*x = b, where x and b are Nx1 matrices. | | Copyright 27.01.2010 by Bochkanov Sergey | |
| | | *************************************************************************/ | |
| | | void rmatrixsolve(const ap::real_2d_array& a, | |
| | | int n, | |
| | | const ap::real_1d_array& b, | |
| | | int& info, | |
| | | densesolverreport& rep, | |
| | | ap::real_1d_array& x); | |
| | | | |
| | | /************************************************************************* | |
| | | Dense solver. | |
| | | | |
| | | Similar to RMatrixSolve() but solves task with multiple right parts (where | |
| | | b and x are NxM matrices). | |
| | | | |
| | | Algorithm features: | |
| | | * automatic detection of degenerate cases | |
| | | * condition number estimation | |
| | | * optional iterative refinement | |
| | | * O(N^3+M*N^2) complexity | |
| | | | |
| | | INPUT PARAMETERS | |
| | | A - array[0..N-1,0..N-1], system matrix | |
| | | N - size of A | |
| | | B - array[0..N-1,0..M-1], right part | |
| | | M - right part size | |
| | | RFS - iterative refinement switch: | |
| | | * True - refinement is used. | |
| | | Less performance, more precision. | |
| | | * False - refinement is not used. | |
| | | More performance, less precision. | |
| | | | |
| | | OUTPUT PARAMETERS | |
| | | Info - same as in RMatrixSolve | |
| | | Rep - same as in RMatrixSolve | |
| | | X - same as in RMatrixSolve | |
| | | | |
| -- ALGLIB -- | | -- ALGLIB -- | |
|
| Copyright 24.08.2009 by Bochkanov Sergey | | Copyright 27.01.2010 by Bochkanov Sergey | |
| *************************************************************************/ | | *************************************************************************/ | |
| void rmatrixsolvem(const ap::real_2d_array& a, | | void rmatrixsolvem(const ap::real_2d_array& a, | |
| int n, | | int n, | |
| const ap::real_2d_array& b, | | const ap::real_2d_array& b, | |
| int m, | | int m, | |
|
| | | bool rfs, | |
| | | int& info, | |
| | | densesolverreport& rep, | |
| | | ap::real_2d_array& x); | |
| | | | |
| | | /************************************************************************* | |
| | | Dense solver. | |
| | | | |
| | | This subroutine solves a system A*X=B, where A is NxN non-denegerate | |
| | | real matrix given by its LU decomposition, X and B are NxM real matrices. | |
| | | | |
| | | Algorithm features: | |
| | | * automatic detection of degenerate cases | |
| | | * O(N^2) complexity | |
| | | * condition number estimation | |
| | | | |
| | | No iterative refinement is provided because exact form of original matrix | |
| | | is not known to subroutine. Use RMatrixSolve or RMatrixMixedSolve if you | |
| | | need iterative refinement. | |
| | | | |
| | | INPUT PARAMETERS | |
| | | LUA - array[0..N-1,0..N-1], LU decomposition, RMatrixLU result | |
| | | P - array[0..N-1], pivots array, RMatrixLU result | |
| | | N - size of A | |
| | | B - array[0..N-1], right part | |
| | | | |
| | | OUTPUT PARAMETERS | |
| | | Info - same as in RMatrixSolve | |
| | | Rep - same as in RMatrixSolve | |
| | | X - same as in RMatrixSolve | |
| | | | |
| | | -- ALGLIB -- | |
| | | Copyright 27.01.2010 by Bochkanov Sergey | |
| | | *************************************************************************/ | |
| | | void rmatrixlusolve(const ap::real_2d_array& lua, | |
| | | const ap::integer_1d_array& p, | |
| | | int n, | |
| | | const ap::real_1d_array& b, | |
| | | int& info, | |
| | | densesolverreport& rep, | |
| | | ap::real_1d_array& x); | |
| | | | |
| | | /************************************************************************* | |
| | | Dense solver. | |
| | | | |
| | | Similar to RMatrixLUSolve() but solves task with multiple right parts | |
| | | (where b and x are NxM matrices). | |
| | | | |
| | | Algorithm features: | |
| | | * automatic detection of degenerate cases | |
| | | * O(M*N^2) complexity | |
| | | * condition number estimation | |
| | | | |
| | | No iterative refinement is provided because exact form of original matrix | |
| | | is not known to subroutine. Use RMatrixSolve or RMatrixMixedSolve if you | |
| | | need iterative refinement. | |
| | | | |
| | | INPUT PARAMETERS | |
| | | LUA - array[0..N-1,0..N-1], LU decomposition, RMatrixLU result | |
| | | P - array[0..N-1], pivots array, RMatrixLU result | |
| | | N - size of A | |
| | | B - array[0..N-1,0..M-1], right part | |
| | | M - right part size | |
| | | | |
| | | OUTPUT PARAMETERS | |
| | | Info - same as in RMatrixSolve | |
| | | Rep - same as in RMatrixSolve | |
| | | X - same as in RMatrixSolve | |
| | | | |
| | | -- ALGLIB -- | |
| | | Copyright 27.01.2010 by Bochkanov Sergey | |
| | | *************************************************************************/ | |
| | | void rmatrixlusolvem(const ap::real_2d_array& lua, | |
| | | const ap::integer_1d_array& p, | |
| | | int n, | |
| | | const ap::real_2d_array& b, | |
| | | int m, | |
| int& info, | | int& info, | |
| densesolverreport& rep, | | densesolverreport& rep, | |
| ap::real_2d_array& x); | | ap::real_2d_array& x); | |
| | | | |
| /************************************************************************* | | /************************************************************************* | |
| Dense solver. | | Dense solver. | |
| | | | |
|
| | | This subroutine solves a system A*x=b, where BOTH ORIGINAL A AND ITS | |
| | | LU DECOMPOSITION ARE KNOWN. You can use it if for some reasons you have | |
| | | both A and its LU decomposition. | |
| | | | |
| | | Algorithm features: | |
| | | * automatic detection of degenerate cases | |
| | | * condition number estimation | |
| | | * iterative refinement | |
| | | * O(N^2) complexity | |
| | | | |
| | | INPUT PARAMETERS | |
| | | A - array[0..N-1,0..N-1], system matrix | |
| | | LUA - array[0..N-1,0..N-1], LU decomposition, RMatrixLU result | |
| | | P - array[0..N-1], pivots array, RMatrixLU result | |
| | | N - size of A | |
| | | B - array[0..N-1], right part | |
| | | | |
| | | OUTPUT PARAMETERS | |
| | | Info - same as in RMatrixSolveM | |
| | | Rep - same as in RMatrixSolveM | |
| | | X - same as in RMatrixSolveM | |
| | | | |
| | | -- ALGLIB -- | |
| | | Copyright 27.01.2010 by Bochkanov Sergey | |
| | | *************************************************************************/ | |
| | | void rmatrixmixedsolve(const ap::real_2d_array& a, | |
| | | const ap::real_2d_array& lua, | |
| | | const ap::integer_1d_array& p, | |
| | | int n, | |
| | | const ap::real_1d_array& b, | |
| | | int& info, | |
| | | densesolverreport& rep, | |
| | | ap::real_1d_array& x); | |
| | | | |
| | | /************************************************************************* | |
| | | Dense solver. | |
| | | | |
| | | Similar to RMatrixMixedSolve() but solves task with multiple right parts | |
| | | (where b and x are NxM matrices). | |
| | | | |
| | | Algorithm features: | |
| | | * automatic detection of degenerate cases | |
| | | * condition number estimation | |
| | | * iterative refinement | |
| | | * O(M*N^2) complexity | |
| | | | |
| | | INPUT PARAMETERS | |
| | | A - array[0..N-1,0..N-1], system matrix | |
| | | LUA - array[0..N-1,0..N-1], LU decomposition, RMatrixLU result | |
| | | P - array[0..N-1], pivots array, RMatrixLU result | |
| | | N - size of A | |
| | | B - array[0..N-1,0..M-1], right part | |
| | | M - right part size | |
| | | | |
| | | OUTPUT PARAMETERS | |
| | | Info - same as in RMatrixSolveM | |
| | | Rep - same as in RMatrixSolveM | |
| | | X - same as in RMatrixSolveM | |
| | | | |
| | | -- ALGLIB -- | |
| | | Copyright 27.01.2010 by Bochkanov Sergey | |
| | | *************************************************************************/ | |
| | | void rmatrixmixedsolvem(const ap::real_2d_array& a, | |
| | | const ap::real_2d_array& lua, | |
| | | const ap::integer_1d_array& p, | |
| | | int n, | |
| | | const ap::real_2d_array& b, | |
| | | int m, | |
| | | int& info, | |
| | | densesolverreport& rep, | |
| | | ap::real_2d_array& x); | |
| | | | |
| | | /************************************************************************* | |
| | | Dense solver. Same as RMatrixSolveM(), but for complex matrices. | |
| | | | |
| | | Algorithm features: | |
| | | * automatic detection of degenerate cases | |
| | | * condition number estimation | |
| | | * iterative refinement | |
| | | * O(N^3+M*N^2) complexity | |
| | | | |
| | | INPUT PARAMETERS | |
| | | A - array[0..N-1,0..N-1], system matrix | |
| | | N - size of A | |
| | | B - array[0..N-1,0..M-1], right part | |
| | | M - right part size | |
| | | RFS - iterative refinement switch: | |
| | | * True - refinement is used. | |
| | | Less performance, more precision. | |
| | | * False - refinement is not used. | |
| | | More performance, less precision. | |
| | | | |
| | | OUTPUT PARAMETERS | |
| | | Info - same as in RMatrixSolve | |
| | | Rep - same as in RMatrixSolve | |
| | | X - same as in RMatrixSolve | |
| | | | |
| | | -- ALGLIB -- | |
| | | Copyright 27.01.2010 by Bochkanov Sergey | |
| | | *************************************************************************/ | |
| | | void cmatrixsolvem(const ap::complex_2d_array& a, | |
| | | int n, | |
| | | const ap::complex_2d_array& b, | |
| | | int m, | |
| | | bool rfs, | |
| | | int& info, | |
| | | densesolverreport& rep, | |
| | | ap::complex_2d_array& x); | |
| | | | |
| | | /************************************************************************* | |
| | | Dense solver. Same as RMatrixSolve(), but for complex matrices. | |
| | | | |
| | | Algorithm features: | |
| | | * automatic detection of degenerate cases | |
| | | * condition number estimation | |
| | | * iterative refinement | |
| | | * O(N^3) complexity | |
| | | | |
| | | INPUT PARAMETERS | |
| | | A - array[0..N-1,0..N-1], system matrix | |
| | | N - size of A | |
| | | B - array[0..N-1], right part | |
| | | | |
| | | OUTPUT PARAMETERS | |
| | | Info - same as in RMatrixSolve | |
| | | Rep - same as in RMatrixSolve | |
| | | X - same as in RMatrixSolve | |
| | | | |
| | | -- ALGLIB -- | |
| | | Copyright 27.01.2010 by Bochkanov Sergey | |
| | | *************************************************************************/ | |
| | | void cmatrixsolve(const ap::complex_2d_array& a, | |
| | | int n, | |
| | | const ap::complex_1d_array& b, | |
| | | int& info, | |
| | | densesolverreport& rep, | |
| | | ap::complex_1d_array& x); | |
| | | | |
| | | /************************************************************************* | |
| | | Dense solver. Same as RMatrixLUSolveM(), but for complex matrices. | |
| | | | |
| | | Algorithm features: | |
| | | * automatic detection of degenerate cases | |
| | | * O(M*N^2) complexity | |
| | | * condition number estimation | |
| | | | |
| | | No iterative refinement is provided because exact form of original matrix | |
| | | is not known to subroutine. Use CMatrixSolve or CMatrixMixedSolve if you | |
| | | need iterative refinement. | |
| | | | |
| | | INPUT PARAMETERS | |
| | | LUA - array[0..N-1,0..N-1], LU decomposition, RMatrixLU result | |
| | | P - array[0..N-1], pivots array, RMatrixLU result | |
| | | N - size of A | |
| | | B - array[0..N-1,0..M-1], right part | |
| | | M - right part size | |
| | | | |
| | | OUTPUT PARAMETERS | |
| | | Info - same as in RMatrixSolve | |
| | | Rep - same as in RMatrixSolve | |
| | | X - same as in RMatrixSolve | |
| | | | |
| | | -- ALGLIB -- | |
| | | Copyright 27.01.2010 by Bochkanov Sergey | |
| | | *************************************************************************/ | |
| | | void cmatrixlusolvem(const ap::complex_2d_array& lua, | |
| | | const ap::integer_1d_array& p, | |
| | | int n, | |
| | | const ap::complex_2d_array& b, | |
| | | int m, | |
| | | int& info, | |
| | | densesolverreport& rep, | |
| | | ap::complex_2d_array& x); | |
| | | | |
| | | /************************************************************************* | |
| | | Dense solver. Same as RMatrixLUSolve(), but for complex matrices. | |
| | | | |
| | | Algorithm features: | |
| | | * automatic detection of degenerate cases | |
| | | * O(N^2) complexity | |
| | | * condition number estimation | |
| | | | |
| | | No iterative refinement is provided because exact form of original matrix | |
| | | is not known to subroutine. Use CMatrixSolve or CMatrixMixedSolve if you | |
| | | need iterative refinement. | |
| | | | |
| | | INPUT PARAMETERS | |
| | | LUA - array[0..N-1,0..N-1], LU decomposition, CMatrixLU result | |
| | | P - array[0..N-1], pivots array, CMatrixLU result | |
| | | N - size of A | |
| | | B - array[0..N-1], right part | |
| | | | |
| | | OUTPUT PARAMETERS | |
| | | Info - same as in RMatrixSolve | |
| | | Rep - same as in RMatrixSolve | |
| | | X - same as in RMatrixSolve | |
| | | | |
| | | -- ALGLIB -- | |
| | | Copyright 27.01.2010 by Bochkanov Sergey | |
| | | *************************************************************************/ | |
| | | void cmatrixlusolve(const ap::complex_2d_array& lua, | |
| | | const ap::integer_1d_array& p, | |
| | | int n, | |
| | | const ap::complex_1d_array& b, | |
| | | int& info, | |
| | | densesolverreport& rep, | |
| | | ap::complex_1d_array& x); | |
| | | | |
| | | /************************************************************************* | |
| | | Dense solver. Same as RMatrixMixedSolveM(), but for complex matrices. | |
| | | | |
| | | Algorithm features: | |
| | | * automatic detection of degenerate cases | |
| | | * condition number estimation | |
| | | * iterative refinement | |
| | | * O(M*N^2) complexity | |
| | | | |
| | | INPUT PARAMETERS | |
| | | A - array[0..N-1,0..N-1], system matrix | |
| | | LUA - array[0..N-1,0..N-1], LU decomposition, CMatrixLU result | |
| | | P - array[0..N-1], pivots array, CMatrixLU result | |
| | | N - size of A | |
| | | B - array[0..N-1,0..M-1], right part | |
| | | M - right part size | |
| | | | |
| | | OUTPUT PARAMETERS | |
| | | Info - same as in RMatrixSolveM | |
| | | Rep - same as in RMatrixSolveM | |
| | | X - same as in RMatrixSolveM | |
| | | | |
| | | -- ALGLIB -- | |
| | | Copyright 27.01.2010 by Bochkanov Sergey | |
| | | *************************************************************************/ | |
| | | void cmatrixmixedsolvem(const ap::complex_2d_array& a, | |
| | | const ap::complex_2d_array& lua, | |
| | | const ap::integer_1d_array& p, | |
| | | int n, | |
| | | const ap::complex_2d_array& b, | |
| | | int m, | |
| | | int& info, | |
| | | densesolverreport& rep, | |
| | | ap::complex_2d_array& x); | |
| | | | |
| | | /************************************************************************* | |
| | | Dense solver. Same as RMatrixMixedSolve(), but for complex matrices. | |
| | | | |
| | | Algorithm features: | |
| | | * automatic detection of degenerate cases | |
| | | * condition number estimation | |
| | | * iterative refinement | |
| | | * O(N^2) complexity | |
| | | | |
| | | INPUT PARAMETERS | |
| | | A - array[0..N-1,0..N-1], system matrix | |
| | | LUA - array[0..N-1,0..N-1], LU decomposition, CMatrixLU result | |
| | | P - array[0..N-1], pivots array, CMatrixLU result | |
| | | N - size of A | |
| | | B - array[0..N-1], right part | |
| | | | |
| | | OUTPUT PARAMETERS | |
| | | Info - same as in RMatrixSolveM | |
| | | Rep - same as in RMatrixSolveM | |
| | | X - same as in RMatrixSolveM | |
| | | | |
| | | -- ALGLIB -- | |
| | | Copyright 27.01.2010 by Bochkanov Sergey | |
| | | *************************************************************************/ | |
| | | void cmatrixmixedsolve(const ap::complex_2d_array& a, | |
| | | const ap::complex_2d_array& lua, | |
| | | const ap::integer_1d_array& p, | |
| | | int n, | |
| | | const ap::complex_1d_array& b, | |
| | | int& info, | |
| | | densesolverreport& rep, | |
| | | ap::complex_1d_array& x); | |
| | | | |
| | | /************************************************************************* | |
| | | Dense solver. Same as RMatrixSolveM(), but for symmetric positive definite | |
| | | matrices. | |
| | | | |
| | | Algorithm features: | |
| | | * automatic detection of degenerate cases | |
| | | * condition number estimation | |
| | | * O(N^3+M*N^2) complexity | |
| | | * matrix is represented by its upper or lower triangle | |
| | | | |
| | | No iterative refinement is provided because such partial representation of | |
| | | matrix does not allow efficient calculation of extra-precise matrix-vector | |
| | | products for large matrices. Use RMatrixSolve or RMatrixMixedSolve if you | |
| | | need iterative refinement. | |
| | | | |
| | | INPUT PARAMETERS | |
| | | A - array[0..N-1,0..N-1], system matrix | |
| | | N - size of A | |
| | | IsUpper - what half of A is provided | |
| | | B - array[0..N-1,0..M-1], right part | |
| | | M - right part size | |
| | | | |
| | | OUTPUT PARAMETERS | |
| | | Info - same as in RMatrixSolve. | |
| | | Returns -3 for non-SPD matrices. | |
| | | Rep - same as in RMatrixSolve | |
| | | X - same as in RMatrixSolve | |
| | | | |
| | | -- ALGLIB -- | |
| | | Copyright 27.01.2010 by Bochkanov Sergey | |
| | | *************************************************************************/ | |
| | | void spdmatrixsolvem(const ap::real_2d_array& a, | |
| | | int n, | |
| | | bool isupper, | |
| | | const ap::real_2d_array& b, | |
| | | int m, | |
| | | int& info, | |
| | | densesolverreport& rep, | |
| | | ap::real_2d_array& x); | |
| | | | |
| | | /************************************************************************* | |
| | | Dense solver. Same as RMatrixSolve(), but for SPD matrices. | |
| | | | |
| | | Algorithm features: | |
| | | * automatic detection of degenerate cases | |
| | | * condition number estimation | |
| | | * O(N^3) complexity | |
| | | * matrix is represented by its upper or lower triangle | |
| | | | |
| | | No iterative refinement is provided because such partial representation of | |
| | | matrix does not allow efficient calculation of extra-precise matrix-vector | |
| | | products for large matrices. Use RMatrixSolve or RMatrixMixedSolve if you | |
| | | need iterative refinement. | |
| | | | |
| | | INPUT PARAMETERS | |
| | | A - array[0..N-1,0..N-1], system matrix | |
| | | N - size of A | |
| | | IsUpper - what half of A is provided | |
| | | B - array[0..N-1], right part | |
| | | | |
| | | OUTPUT PARAMETERS | |
| | | Info - same as in RMatrixSolve | |
| | | Returns -3 for non-SPD matrices. | |
| | | Rep - same as in RMatrixSolve | |
| | | X - same as in RMatrixSolve | |
| | | | |
| | | -- ALGLIB -- | |
| | | Copyright 27.01.2010 by Bochkanov Sergey | |
| | | *************************************************************************/ | |
| | | void spdmatrixsolve(const ap::real_2d_array& a, | |
| | | int n, | |
| | | bool isupper, | |
| | | const ap::real_1d_array& b, | |
| | | int& info, | |
| | | densesolverreport& rep, | |
| | | ap::real_1d_array& x); | |
| | | | |
| | | /************************************************************************* | |
| | | Dense solver. Same as RMatrixLUSolveM(), but for SPD matrices represented | |
| | | by their Cholesky decomposition. | |
| | | | |
| | | Algorithm features: | |
| | | * automatic detection of degenerate cases | |
| | | * O(M*N^2) complexity | |
| | | * condition number estimation | |
| | | * matrix is represented by its upper or lower triangle | |
| | | | |
| | | No iterative refinement is provided because such partial representation of | |
| | | matrix does not allow efficient calculation of extra-precise matrix-vector | |
| | | products for large matrices. Use RMatrixSolve or RMatrixMixedSolve if you | |
| | | need iterative refinement. | |
| | | | |
| | | INPUT PARAMETERS | |
| | | CHA - array[0..N-1,0..N-1], Cholesky decomposition, | |
| | | SPDMatrixCholesky result | |
| | | N - size of CHA | |
| | | IsUpper - what half of CHA is provided | |
| | | B - array[0..N-1,0..M-1], right part | |
| | | M - right part size | |
| | | | |
| | | OUTPUT PARAMETERS | |
| | | Info - same as in RMatrixSolve | |
| | | Rep - same as in RMatrixSolve | |
| | | X - same as in RMatrixSolve | |
| | | | |
| | | -- ALGLIB -- | |
| | | Copyright 27.01.2010 by Bochkanov Sergey | |
| | | *************************************************************************/ | |
| | | void spdmatrixcholeskysolvem(const ap::real_2d_array& cha, | |
| | | int n, | |
| | | bool isupper, | |
| | | const ap::real_2d_array& b, | |
| | | int m, | |
| | | int& info, | |
| | | densesolverreport& rep, | |
| | | ap::real_2d_array& x); | |
| | | | |
| | | /************************************************************************* | |
| | | Dense solver. Same as RMatrixLUSolve(), but for SPD matrices represented | |
| | | by their Cholesky decomposition. | |
| | | | |
| | | Algorithm features: | |
| | | * automatic detection of degenerate cases | |
| | | * O(N^2) complexity | |
| | | * condition number estimation | |
| | | * matrix is represented by its upper or lower triangle | |
| | | | |
| | | No iterative refinement is provided because such partial representation of | |
| | | matrix does not allow efficient calculation of extra-precise matrix-vector | |
| | | products for large matrices. Use RMatrixSolve or RMatrixMixedSolve if you | |
| | | need iterative refinement. | |
| | | | |
| | | INPUT PARAMETERS | |
| | | CHA - array[0..N-1,0..N-1], Cholesky decomposition, | |
| | | SPDMatrixCholesky result | |
| | | N - size of A | |
| | | IsUpper - what half of CHA is provided | |
| | | B - array[0..N-1], right part | |
| | | | |
| | | OUTPUT PARAMETERS | |
| | | Info - same as in RMatrixSolve | |
| | | Rep - same as in RMatrixSolve | |
| | | X - same as in RMatrixSolve | |
| | | | |
| | | -- ALGLIB -- | |
| | | Copyright 27.01.2010 by Bochkanov Sergey | |
| | | *************************************************************************/ | |
| | | void spdmatrixcholeskysolve(const ap::real_2d_array& cha, | |
| | | int n, | |
| | | bool isupper, | |
| | | const ap::real_1d_array& b, | |
| | | int& info, | |
| | | densesolverreport& rep, | |
| | | ap::real_1d_array& x); | |
| | | | |
| | | /************************************************************************* | |
| | | Dense solver. Same as RMatrixSolveM(), but for Hermitian positive definite | |
| | | matrices. | |
| | | | |
| | | Algorithm features: | |
| | | * automatic detection of degenerate cases | |
| | | * condition number estimation | |
| | | * O(N^3+M*N^2) complexity | |
| | | * matrix is represented by its upper or lower triangle | |
| | | | |
| | | No iterative refinement is provided because such partial representation of | |
| | | matrix does not allow efficient calculation of extra-precise matrix-vector | |
| | | products for large matrices. Use RMatrixSolve or RMatrixMixedSolve if you | |
| | | need iterative refinement. | |
| | | | |
| | | INPUT PARAMETERS | |
| | | A - array[0..N-1,0..N-1], system matrix | |
| | | N - size of A | |
| | | IsUpper - what half of A is provided | |
| | | B - array[0..N-1,0..M-1], right part | |
| | | M - right part size | |
| | | | |
| | | OUTPUT PARAMETERS | |
| | | Info - same as in RMatrixSolve. | |
| | | Returns -3 for non-HPD matrices. | |
| | | Rep - same as in RMatrixSolve | |
| | | X - same as in RMatrixSolve | |
| | | | |
| | | -- ALGLIB -- | |
| | | Copyright 27.01.2010 by Bochkanov Sergey | |
| | | *************************************************************************/ | |
| | | void hpdmatrixsolvem(const ap::complex_2d_array& a, | |
| | | int n, | |
| | | bool isupper, | |
| | | const ap::complex_2d_array& b, | |
| | | int m, | |
| | | int& info, | |
| | | densesolverreport& rep, | |
| | | ap::complex_2d_array& x); | |
| | | | |
| | | /************************************************************************* | |
| | | Dense solver. Same as RMatrixSolve(), but for Hermitian positive definite | |
| | | matrices. | |
| | | | |
| | | Algorithm features: | |
| | | * automatic detection of degenerate cases | |
| | | * condition number estimation | |
| | | * O(N^3) complexity | |
| | | * matrix is represented by its upper or lower triangle | |
| | | | |
| | | No iterative refinement is provided because such partial representation of | |
| | | matrix does not allow efficient calculation of extra-precise matrix-vector | |
| | | products for large matrices. Use RMatrixSolve or RMatrixMixedSolve if you | |
| | | need iterative refinement. | |
| | | | |
| | | INPUT PARAMETERS | |
| | | A - array[0..N-1,0..N-1], system matrix | |
| | | N - size of A | |
| | | IsUpper - what half of A is provided | |
| | | B - array[0..N-1], right part | |
| | | | |
| | | OUTPUT PARAMETERS | |
| | | Info - same as in RMatrixSolve | |
| | | Returns -3 for non-HPD matrices. | |
| | | Rep - same as in RMatrixSolve | |
| | | X - same as in RMatrixSolve | |
| | | | |
| | | -- ALGLIB -- | |
| | | Copyright 27.01.2010 by Bochkanov Sergey | |
| | | *************************************************************************/ | |
| | | void hpdmatrixsolve(const ap::complex_2d_array& a, | |
| | | int n, | |
| | | bool isupper, | |
| | | const ap::complex_1d_array& b, | |
| | | int& info, | |
| | | densesolverreport& rep, | |
| | | ap::complex_1d_array& x); | |
| | | | |
| | | /************************************************************************* | |
| | | Dense solver. Same as RMatrixLUSolveM(), but for HPD matrices represented | |
| | | by their Cholesky decomposition. | |
| | | | |
| | | Algorithm features: | |
| | | * automatic detection of degenerate cases | |
| | | * O(M*N^2) complexity | |
| | | * condition number estimation | |
| | | * matrix is represented by its upper or lower triangle | |
| | | | |
| | | No iterative refinement is provided because such partial representation of | |
| | | matrix does not allow efficient calculation of extra-precise matrix-vector | |
| | | products for large matrices. Use RMatrixSolve or RMatrixMixedSolve if you | |
| | | need iterative refinement. | |
| | | | |
| | | INPUT PARAMETERS | |
| | | CHA - array[0..N-1,0..N-1], Cholesky decomposition, | |
| | | HPDMatrixCholesky result | |
| | | N - size of CHA | |
| | | IsUpper - what half of CHA is provided | |
| | | B - array[0..N-1,0..M-1], right part | |
| | | M - right part size | |
| | | | |
| | | OUTPUT PARAMETERS | |
| | | Info - same as in RMatrixSolve | |
| | | Rep - same as in RMatrixSolve | |
| | | X - same as in RMatrixSolve | |
| | | | |
| | | -- ALGLIB -- | |
| | | Copyright 27.01.2010 by Bochkanov Sergey | |
| | | *************************************************************************/ | |
| | | void hpdmatrixcholeskysolvem(const ap::complex_2d_array& cha, | |
| | | int n, | |
| | | bool isupper, | |
| | | const ap::complex_2d_array& b, | |
| | | int m, | |
| | | int& info, | |
| | | densesolverreport& rep, | |
| | | ap::complex_2d_array& x); | |
| | | | |
| | | /************************************************************************* | |
| | | Dense solver. Same as RMatrixLUSolve(), but for HPD matrices represented | |
| | | by their Cholesky decomposition. | |
| | | | |
| | | Algorithm features: | |
| | | * automatic detection of degenerate cases | |
| | | * O(N^2) complexity | |
| | | * condition number estimation | |
| | | * matrix is represented by its upper or lower triangle | |
| | | | |
| | | No iterative refinement is provided because such partial representation of | |
| | | matrix does not allow efficient calculation of extra-precise matrix-vector | |
| | | products for large matrices. Use RMatrixSolve or RMatrixMixedSolve if you | |
| | | need iterative refinement. | |
| | | | |
| | | INPUT PARAMETERS | |
| | | CHA - array[0..N-1,0..N-1], Cholesky decomposition, | |
| | | SPDMatrixCholesky result | |
| | | N - size of A | |
| | | IsUpper - what half of CHA is provided | |
| | | B - array[0..N-1], right part | |
| | | | |
| | | OUTPUT PARAMETERS | |
| | | Info - same as in RMatrixSolve | |
| | | Rep - same as in RMatrixSolve | |
| | | X - same as in RMatrixSolve | |
| | | | |
| | | -- ALGLIB -- | |
| | | Copyright 27.01.2010 by Bochkanov Sergey | |
| | | *************************************************************************/ | |
| | | void hpdmatrixcholeskysolve(const ap::complex_2d_array& cha, | |
| | | int n, | |
| | | bool isupper, | |
| | | const ap::complex_1d_array& b, | |
| | | int& info, | |
| | | densesolverreport& rep, | |
| | | ap::complex_1d_array& x); | |
| | | | |
| | | /************************************************************************* | |
| | | Dense solver. | |
| | | | |
| This subroutine finds solution of the linear system A*X=B with non-square, | | This subroutine finds solution of the linear system A*X=B with non-square, | |
| possibly degenerate A. System is solved in the least squares sense, and | | possibly degenerate A. System is solved in the least squares sense, and | |
| general least squares solution X = X0 + CX*y which minimizes |A*X-B| is | | general least squares solution X = X0 + CX*y which minimizes |A*X-B| is | |
| returned. If A is non-degenerate, solution in the usual sense is returned | | returned. If A is non-degenerate, solution in the usual sense is returned | |
| | | | |
|
| Additional features include: | | Algorithm features: | |
| * iterative improvement | | * automatic detection of degenerate cases | |
| | | * iterative refinement | |
| | | * O(N^3) complexity | |
| | | | |
| INPUT PARAMETERS | | INPUT PARAMETERS | |
| A - array[0..NRows-1,0..NCols-1], system matrix | | A - array[0..NRows-1,0..NCols-1], system matrix | |
| NRows - vertical size of A | | NRows - vertical size of A | |
| NCols - horizontal size of A | | NCols - horizontal size of A | |
| B - array[0..NCols-1], right part | | B - array[0..NCols-1], right part | |
| Threshold- a number in [0,1]. Singular values beyond Threshold are | | Threshold- a number in [0,1]. Singular values beyond Threshold are | |
| considered zero. Set it to 0.0, if you don't understand | | considered zero. Set it to 0.0, if you don't understand | |
| what it means, so the solver will choose good value on its | | what it means, so the solver will choose good value on its | |
| own. | | own. | |
| | | | |
| skipping to change at line 159 | | skipping to change at line 870 | |
| *************************************************************************/ | | *************************************************************************/ | |
| void rmatrixsolvels(const ap::real_2d_array& a, | | void rmatrixsolvels(const ap::real_2d_array& a, | |
| int nrows, | | int nrows, | |
| int ncols, | | int ncols, | |
| const ap::real_1d_array& b, | | const ap::real_1d_array& b, | |
| double threshold, | | double threshold, | |
| int& info, | | int& info, | |
| densesolverlsreport& rep, | | densesolverlsreport& rep, | |
| ap::real_1d_array& x); | | ap::real_1d_array& x); | |
| | | | |
|
| /************************************************************************* | | | |
| Dense solver. | | | |
| | | | |
| Similar to RMatrixSolveM() but solves task with one right part (where b/x | | | |
| are vectors, not matrices). | | | |
| | | | |
| See RMatrixSolveM() description for more information about subroutine | | | |
| parameters. | | | |
| | | | |
| -- ALGLIB -- | | | |
| Copyright 24.08.2009 by Bochkanov Sergey | | | |
| *************************************************************************/ | | | |
| void rmatrixsolve(const ap::real_2d_array& a, | | | |
| int n, | | | |
| const ap::real_1d_array& b, | | | |
| int& info, | | | |
| densesolverreport& rep, | | | |
| ap::real_1d_array& x); | | | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 15 change blocks. |
| 36 lines changed or deleted | | 729 lines changed or added | |
|
| rcond.h | | rcond.h | |
| | | | |
| skipping to change at line 33 | | skipping to change at line 33 | |
| | | | |
| >>> END OF LICENSE >>> | | >>> END OF LICENSE >>> | |
| *************************************************************************/ | | *************************************************************************/ | |
| | | | |
| #ifndef _rcond_h | | #ifndef _rcond_h | |
| #define _rcond_h | | #define _rcond_h | |
| | | | |
| #include "ap.h" | | #include "ap.h" | |
| #include "ialglib.h" | | #include "ialglib.h" | |
| | | | |
|
| #include "lu.h" | | #include "reflections.h" | |
| | | #include "creflections.h" | |
| | | #include "hqrnd.h" | |
| | | #include "matgen.h" | |
| | | #include "ablasf.h" | |
| | | #include "ablas.h" | |
| | | #include "trfac.h" | |
| #include "trlinsolve.h" | | #include "trlinsolve.h" | |
|
| | | #include "safesolve.h" | |
| | | | |
| /************************************************************************* | | /************************************************************************* | |
| Estimate of a matrix condition number (1-norm) | | Estimate of a matrix condition number (1-norm) | |
| | | | |
| The algorithm calculates a lower bound of the condition number. In this cas
e, | | The algorithm calculates a lower bound of the condition number. In this cas
e, | |
| the algorithm does not return a lower bound of the condition number, but an | | the algorithm does not return a lower bound of the condition number, but an | |
| inverse number (to avoid an overflow in case of a singular matrix). | | inverse number (to avoid an overflow in case of a singular matrix). | |
| | | | |
| Input parameters: | | Input parameters: | |
| A - matrix. Array whose indexes range within [0..N-1, 0..N-1]. | | A - matrix. Array whose indexes range within [0..N-1, 0..N-1]. | |
| N - size of matrix A. | | N - size of matrix A. | |
| | | | |
| Result: 1/LowerBound(cond(A)) | | Result: 1/LowerBound(cond(A)) | |
|
| | | | |
| | | NOTE: | |
| | | if k(A)>1/epsilon, then matrix is assumed degenerate, k(A)=INF, 0.0 is | |
| | | returned in such cases. | |
| *************************************************************************/ | | *************************************************************************/ | |
|
| double rmatrixrcond1(const ap::real_2d_array& a, int n); | | double rmatrixrcond1(ap::real_2d_array a, int n); | |
| | | | |
| /************************************************************************* | | /************************************************************************* | |
|
| Estimate of the condition number of a matrix given by its LU decomposition
(1-norm) | | Estimate of a matrix condition number (infinity-norm). | |
| | | | |
| The algorithm calculates a lower bound of the condition number. In this cas
e, | | The algorithm calculates a lower bound of the condition number. In this cas
e, | |
| the algorithm does not return a lower bound of the condition number, but an | | the algorithm does not return a lower bound of the condition number, but an | |
| inverse number (to avoid an overflow in case of a singular matrix). | | inverse number (to avoid an overflow in case of a singular matrix). | |
| | | | |
| Input parameters: | | Input parameters: | |
|
| LUDcmp - LU decomposition of a matrix in compact form. Output of | | A - matrix. Array whose indexes range within [0..N-1, 0..N-1]. | |
| the RMatrixLU subroutine. | | N - size of matrix A. | |
| N - size of matrix A. | | | |
| | | Result: 1/LowerBound(cond(A)) | |
| | | | |
| | | NOTE: | |
| | | if k(A)>1/epsilon, then matrix is assumed degenerate, k(A)=INF, 0.0 is | |
| | | returned in such cases. | |
| | | *************************************************************************/ | |
| | | double rmatrixrcondinf(ap::real_2d_array a, int n); | |
| | | | |
| | | /************************************************************************* | |
| | | Condition number estimate of a symmetric positive definite matrix. | |
| | | | |
| | | The algorithm calculates a lower bound of the condition number. In this cas | |
| | | e, | |
| | | the algorithm does not return a lower bound of the condition number, but an | |
| | | inverse number (to avoid an overflow in case of a singular matrix). | |
| | | | |
| | | It should be noted that 1-norm and inf-norm of condition numbers of symmetr | |
| | | ic | |
| | | matrices are equal, so the algorithm doesn't take into account the | |
| | | differences between these types of norms. | |
| | | | |
| | | Input parameters: | |
| | | A - symmetric positive definite matrix which is given by its | |
| | | upper or lower triangle depending on the value of | |
| | | IsUpper. Array with elements [0..N-1, 0..N-1]. | |
| | | N - size of matrix A. | |
| | | IsUpper - storage format. | |
| | | | |
| | | Result: | |
| | | 1/LowerBound(cond(A)), if matrix A is positive definite, | |
| | | -1, if matrix A is not positive definite, and its condition number | |
| | | could not be found by this algorithm. | |
| | | | |
| | | NOTE: | |
| | | if k(A)>1/epsilon, then matrix is assumed degenerate, k(A)=INF, 0.0 is | |
| | | returned in such cases. | |
| | | *************************************************************************/ | |
| | | double spdmatrixrcond(ap::real_2d_array a, int n, bool isupper); | |
| | | | |
| | | /************************************************************************* | |
| | | Condition number estimate of a Hermitian positive definite matrix. | |
| | | | |
| | | The algorithm calculates a lower bound of the condition number. In this cas | |
| | | e, | |
| | | the algorithm does not return a lower bound of the condition number, but an | |
| | | inverse number (to avoid an overflow in case of a singular matrix). | |
| | | | |
| | | It should be noted that 1-norm and inf-norm of condition numbers of symmetr | |
| | | ic | |
| | | matrices are equal, so the algorithm doesn't take into account the | |
| | | differences between these types of norms. | |
| | | | |
| | | Input parameters: | |
| | | A - Hermitian positive definite matrix which is given by its | |
| | | upper or lower triangle depending on the value of | |
| | | IsUpper. Array with elements [0..N-1, 0..N-1]. | |
| | | N - size of matrix A. | |
| | | IsUpper - storage format. | |
| | | | |
| | | Result: | |
| | | 1/LowerBound(cond(A)), if matrix A is positive definite, | |
| | | -1, if matrix A is not positive definite, and its condition number | |
| | | could not be found by this algorithm. | |
| | | | |
| | | NOTE: | |
| | | if k(A)>1/epsilon, then matrix is assumed degenerate, k(A)=INF, 0.0 is | |
| | | returned in such cases. | |
| | | *************************************************************************/ | |
| | | double hpdmatrixrcond(ap::complex_2d_array a, int n, bool isupper); | |
| | | | |
| | | /************************************************************************* | |
| | | Estimate of a matrix condition number (1-norm) | |
| | | | |
| | | The algorithm calculates a lower bound of the condition number. In this cas | |
| | | e, | |
| | | the algorithm does not return a lower bound of the condition number, but an | |
| | | inverse number (to avoid an overflow in case of a singular matrix). | |
| | | | |
| | | Input parameters: | |
| | | A - matrix. Array whose indexes range within [0..N-1, 0..N-1]. | |
| | | N - size of matrix A. | |
| | | | |
| Result: 1/LowerBound(cond(A)) | | Result: 1/LowerBound(cond(A)) | |
|
| | | | |
| | | NOTE: | |
| | | if k(A)>1/epsilon, then matrix is assumed degenerate, k(A)=INF, 0.0 is | |
| | | returned in such cases. | |
| *************************************************************************/ | | *************************************************************************/ | |
|
| double rmatrixlurcond1(const ap::real_2d_array& ludcmp, int n); | | double cmatrixrcond1(ap::complex_2d_array a, int n); | |
| | | | |
| /************************************************************************* | | /************************************************************************* | |
| Estimate of a matrix condition number (infinity-norm). | | Estimate of a matrix condition number (infinity-norm). | |
| | | | |
| The algorithm calculates a lower bound of the condition number. In this cas
e, | | The algorithm calculates a lower bound of the condition number. In this cas
e, | |
| the algorithm does not return a lower bound of the condition number, but an | | the algorithm does not return a lower bound of the condition number, but an | |
| inverse number (to avoid an overflow in case of a singular matrix). | | inverse number (to avoid an overflow in case of a singular matrix). | |
| | | | |
| Input parameters: | | Input parameters: | |
| A - matrix. Array whose indexes range within [0..N-1, 0..N-1]. | | A - matrix. Array whose indexes range within [0..N-1, 0..N-1]. | |
| N - size of matrix A. | | N - size of matrix A. | |
| | | | |
| Result: 1/LowerBound(cond(A)) | | Result: 1/LowerBound(cond(A)) | |
|
| | | | |
| | | NOTE: | |
| | | if k(A)>1/epsilon, then matrix is assumed degenerate, k(A)=INF, 0.0 is | |
| | | returned in such cases. | |
| *************************************************************************/ | | *************************************************************************/ | |
|
| double rmatrixrcondinf(const ap::real_2d_array& a, int n); | | double cmatrixrcondinf(ap::complex_2d_array a, int n); | |
| | | | |
| | | /************************************************************************* | |
| | | Estimate of the condition number of a matrix given by its LU decomposition | |
| | | (1-norm) | |
| | | | |
| | | The algorithm calculates a lower bound of the condition number. In this cas | |
| | | e, | |
| | | the algorithm does not return a lower bound of the condition number, but an | |
| | | inverse number (to avoid an overflow in case of a singular matrix). | |
| | | | |
| | | Input parameters: | |
| | | LUA - LU decomposition of a matrix in compact form. Output of | |
| | | the RMatrixLU subroutine. | |
| | | N - size of matrix A. | |
| | | | |
| | | Result: 1/LowerBound(cond(A)) | |
| | | | |
| | | NOTE: | |
| | | if k(A)>1/epsilon, then matrix is assumed degenerate, k(A)=INF, 0.0 is | |
| | | returned in such cases. | |
| | | *************************************************************************/ | |
| | | double rmatrixlurcond1(const ap::real_2d_array& lua, int n); | |
| | | | |
| /************************************************************************* | | /************************************************************************* | |
| Estimate of the condition number of a matrix given by its LU decomposition | | Estimate of the condition number of a matrix given by its LU decomposition | |
| (infinity norm). | | (infinity norm). | |
| | | | |
| The algorithm calculates a lower bound of the condition number. In this cas
e, | | The algorithm calculates a lower bound of the condition number. In this cas
e, | |
| the algorithm does not return a lower bound of the condition number, but an | | the algorithm does not return a lower bound of the condition number, but an | |
| inverse number (to avoid an overflow in case of a singular matrix). | | inverse number (to avoid an overflow in case of a singular matrix). | |
| | | | |
| Input parameters: | | Input parameters: | |
|
| LUDcmp - LU decomposition of a matrix in compact form. Output of | | LUA - LU decomposition of a matrix in compact form. Output of | |
| the RMatrixLU subroutine. | | the RMatrixLU subroutine. | |
| N - size of matrix A. | | N - size of matrix A. | |
| | | | |
| Result: 1/LowerBound(cond(A)) | | Result: 1/LowerBound(cond(A)) | |
|
| | | | |
| | | NOTE: | |
| | | if k(A)>1/epsilon, then matrix is assumed degenerate, k(A)=INF, 0.0 is | |
| | | returned in such cases. | |
| | | *************************************************************************/ | |
| | | double rmatrixlurcondinf(const ap::real_2d_array& lua, int n); | |
| | | | |
| | | /************************************************************************* | |
| | | Condition number estimate of a symmetric positive definite matrix given by | |
| | | Cholesky decomposition. | |
| | | | |
| | | The algorithm calculates a lower bound of the condition number. In this | |
| | | case, the algorithm does not return a lower bound of the condition number, | |
| | | but an inverse number (to avoid an overflow in case of a singular matrix). | |
| | | | |
| | | It should be noted that 1-norm and inf-norm condition numbers of symmetric | |
| | | matrices are equal, so the algorithm doesn't take into account the | |
| | | differences between these types of norms. | |
| | | | |
| | | Input parameters: | |
| | | CD - Cholesky decomposition of matrix A, | |
| | | output of SMatrixCholesky subroutine. | |
| | | N - size of matrix A. | |
| | | | |
| | | Result: 1/LowerBound(cond(A)) | |
| | | | |
| | | NOTE: | |
| | | if k(A)>1/epsilon, then matrix is assumed degenerate, k(A)=INF, 0.0 is | |
| | | returned in such cases. | |
| *************************************************************************/ | | *************************************************************************/ | |
|
| double rmatrixlurcondinf(const ap::real_2d_array& ludcmp, int n); | | double spdmatrixcholeskyrcond(const ap::real_2d_array& a, int n, bool isupp | |
| | | er); | |
| | | | |
| | | /************************************************************************* | |
| | | Condition number estimate of a Hermitian positive definite matrix given by | |
| | | Cholesky decomposition. | |
| | | | |
| | | The algorithm calculates a lower bound of the condition number. In this | |
| | | case, the algorithm does not return a lower bound of the condition number, | |
| | | but an inverse number (to avoid an overflow in case of a singular matrix). | |
| | | | |
| | | It should be noted that 1-norm and inf-norm condition numbers of symmetric | |
| | | matrices are equal, so the algorithm doesn't take into account the | |
| | | differences between these types of norms. | |
| | | | |
| | | Input parameters: | |
| | | CD - Cholesky decomposition of matrix A, | |
| | | output of SMatrixCholesky subroutine. | |
| | | N - size of matrix A. | |
| | | | |
|
| double rcond1(ap::real_2d_array a, int n); | | Result: 1/LowerBound(cond(A)) | |
| | | | |
|
| double rcond1lu(const ap::real_2d_array& ludcmp, int n); | | NOTE: | |
| | | if k(A)>1/epsilon, then matrix is assumed degenerate, k(A)=INF, 0.0 is | |
| | | returned in such cases. | |
| | | *************************************************************************/ | |
| | | double hpdmatrixcholeskyrcond(const ap::complex_2d_array& a, | |
| | | int n, | |
| | | bool isupper); | |
| | | | |
|
| double rcondinf(ap::real_2d_array a, int n); | | /************************************************************************* | |
| | | Estimate of the condition number of a matrix given by its LU decomposition | |
| | | (1-norm) | |
| | | | |
|
| double rcondinflu(const ap::real_2d_array& ludcmp, int n); | | The algorithm calculates a lower bound of the condition number. In this cas | |
| | | e, | |
| | | the algorithm does not return a lower bound of the condition number, but an | |
| | | inverse number (to avoid an overflow in case of a singular matrix). | |
| | | | |
| | | Input parameters: | |
| | | LUA - LU decomposition of a matrix in compact form. Output of | |
| | | the CMatrixLU subroutine. | |
| | | N - size of matrix A. | |
| | | | |
| | | Result: 1/LowerBound(cond(A)) | |
| | | | |
| | | NOTE: | |
| | | if k(A)>1/epsilon, then matrix is assumed degenerate, k(A)=INF, 0.0 is | |
| | | returned in such cases. | |
| | | *************************************************************************/ | |
| | | double cmatrixlurcond1(const ap::complex_2d_array& lua, int n); | |
| | | | |
| | | /************************************************************************* | |
| | | Estimate of the condition number of a matrix given by its LU decomposition | |
| | | (infinity norm). | |
| | | | |
| | | The algorithm calculates a lower bound of the condition number. In this cas | |
| | | e, | |
| | | the algorithm does not return a lower bound of the condition number, but an | |
| | | inverse number (to avoid an overflow in case of a singular matrix). | |
| | | | |
| | | Input parameters: | |
| | | LUA - LU decomposition of a matrix in compact form. Output of | |
| | | the CMatrixLU subroutine. | |
| | | N - size of matrix A. | |
| | | | |
| | | Result: 1/LowerBound(cond(A)) | |
| | | | |
| | | NOTE: | |
| | | if k(A)>1/epsilon, then matrix is assumed degenerate, k(A)=INF, 0.0 is | |
| | | returned in such cases. | |
| | | *************************************************************************/ | |
| | | double cmatrixlurcondinf(const ap::complex_2d_array& lua, int n); | |
| | | | |
| | | /************************************************************************* | |
| | | Threshold for rcond: matrices with condition number beyond this threshold | |
| | | are considered singular. | |
| | | | |
| | | Threshold must be far enough from underflow, at least Sqr(Threshold) must | |
| | | be greater than underflow. | |
| | | *************************************************************************/ | |
| | | double rcondthreshold(); | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 17 change blocks. |
| 14 lines changed or deleted | | 238 lines changed or added | |
|