4 #define MAP(i,j,N) (i*N + j) 31 A_ = (
double*)calloc(
N_ *
N_,
sizeof(
double));
33 for (
int i = 0; i <
N_; i++)
35 for (
int j = 0; j <
N_; j++)
37 A_[
MAP(i, j, N_)] = K.coeff(i, j);
42 std::vector<double> tmp;
43 for (
int i = 0; i <
N_; i++)
46 for (
int j = 0; j <
N_; j++)
48 sum +=
A_[
MAP(i, j, N_)];
52 auto max = std::max_element(tmp.begin(), tmp.end());
58 assert(_ns > 0 || _nl > 0 || _condthres > 1 || _gap > 0);
72 double *A_copy = (
double*)malloc(
N_ *
N_ *
sizeof(
double));
73 for (
int i = 0; i <
N_ *
N_; i++)
78 double *S = (
double*)malloc(N_ *
sizeof(
double));
79 double *U = (
double*)malloc(N_ * N_*
sizeof(
double));
80 double *Vt = (
double*)malloc(N_ * N_*
sizeof(
double));
82 double *work = (
double*)malloc(lwork*
sizeof(
double));
85 dgesvd_(jobu, jobvt, &N_, &N_, A_copy, &lda, S, U, &N_, Vt, &N_, work, &lwork, &info);
90 printf(
"svd decomposition succeed in IllConditionDetecter.\n");
94 printf(
"svd decomposition fails in IllConditionDetecter.");
100 std::vector<double> compare;
103 for (
int i = 0; i <
N_; i++)
105 compare.push_back(S[i]);
111 double max = *std::max_element(compare.begin(), compare.end());
113 cout <<
"Ill Condition Detector Rank Stat" << endl;
114 for (
int i = 0; i < compare.size(); i++)
116 if (10e-15 * max < compare[i])
125 std::cout <<
"Rank of K_ : " << rank << std::endl;
126 std::cout <<
"ColN of K_ : " << N_ << std::endl;
136 double *workcon = (
double*)malloc(3 * N_ *
sizeof(
double));
137 int *lworkcon = (
int*)malloc(N_ *
sizeof(
int));
143 printf(
"condition number calculation succeed in IllConditionDetecter.\n");
144 cout <<
"Condition Number: " << 1 /
rcond_num_ << endl;
148 printf(
"condition number calculation failed in IllConditionDetecter.");
170 return (dF.norm() / F.norm());
180 double A[9] = { 76, 27, 18, 25, 89, 60, 11, 51, 32 };
181 double b[3] = { 10, 7, 43 };
198 dpotrf_(uplo, &N, A, &lda, &info);
202 cout <<
"cholesky succeed." << endl;
206 cout <<
"cholesky dead." << endl;
209 double *workcon = (
double*)malloc(3 * N *
sizeof(
double));
210 int *lworkcon = (
int*)malloc(N *
sizeof(
int));
217 printf(
"condition number calculation succeed in IllConditionDetecter.\n");
218 cout <<
"Condition number: " << 1 /
rcond_num_ << endl;
222 printf(
"condition number calculation in IllConditionDetecter.");
void SetParm(int _ns, int _nl, int _condthres, int _gap)
void dgesvd_(const char *JOBU, const char *JOBVT, const int *M, const int *N, double *A, const int *LDA, double *S, double *U, const int *LDU, double *VT, const int *LDVT, double *WORK, const int *LWORK, int *info)
void dpocon_(const char *UPLO, const int *N, const double *AP, const int *lda, const double *ANORM, double *RCOND, double *WORK, int *LWORK, int *INFO)
double EquilibriumError(EigenSp const &K, VX const &D, VX const &F)
GLboolean GLboolean GLboolean b
void GenerateStdVecFile()
void dpotrf_(const char *UPLO, const int *N, double *A, const int *LDA, int *info)
Eigen::SparseMatrix< double > EigenSp
void EigenLap(EigenSp const &K)