65 Eigen::MatrixXd x, Eigen::VectorXd& residual,
const Eigen::MatrixXd& bc,
66 const std::string solverType)
69 M_Assert(solverType ==
"fullPivLu" || solverType ==
"partialPivLu"
70 || solverType ==
"householderQR" || solverType ==
"colPivHouseholderQR"
71 || solverType ==
"fullPivHouseholderQR"
72 || solverType ==
"completeOrthogonalDecomposition" || solverType ==
"llt"
73 || solverType ==
"ldlt" || solverType ==
"bdcSvd"
74 || solverType ==
"jacobiSvd",
"solver not defined");
78 if (LinSys[0].rows() < LinSys[0].cols())
80 FatalErrorInFunction <<
"The system is undetermined, it has more unknowns: " <<
81 LinSys[0].rows() <<
", then equations: " << LinSys[0].rows() << abort(
86 residual = LinSys[0] * x - LinSys[1];
90 if (A.rows() > A.cols())
92 if (solverType !=
"completeOrthogonalDecomposition" && solverType !=
"bdcSvd"
93 && solverType !=
"jacobiSvd")
95 A.resize(A.cols(), A.cols());
96 b.resize(A.cols(), 1);
97 A = LinSys[0].transpose() * LinSys[0];
98 b = LinSys[0].transpose() * LinSys[1];
100 "Using normal equation, results might be inaccurate, better to rely on completeOrthogonalDecomposition, bdcSvd or jacobiSvd"
105 for (
int i = 0; i < bc.size(); i++)
112 if (solverType ==
"fullPivLu")
114 y = A.fullPivLu().solve(b);
116 else if (solverType ==
"partialPivLu")
118 y = A.partialPivLu().solve(b);
120 else if (solverType ==
"householderQr")
122 y = A.householderQr().solve(b);
124 else if (solverType ==
"colPivHouseholderQr")
126 y = A.colPivHouseholderQr().solve(b);
128 else if (solverType ==
"fullPivHouseholderQr")
130 y = A.fullPivHouseholderQr().solve(b);
132 else if (solverType ==
"completeOrthogonalDecomposition")
134 y = A.completeOrthogonalDecomposition().solve(b);
136 else if (solverType ==
"llt")
138 y = A.llt().solve(b);
140 else if (solverType ==
"ldlt")
142 y = A.ldlt().solve(b);
144 else if (solverType ==
"bdcSvd")
146 y = A.bdcSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).solve(b);
148 else if (solverType ==
"jacobiSvd")
150 if (A.rows() > A.cols())
152 y = A.jacobiSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).solve(b);
156 y = A.jacobiSvd().solve(b);
164 Eigen::MatrixXd x, Eigen::VectorXd& residual,
const std::string solverType)
166 const Eigen::MatrixXd& bc = Eigen::MatrixXd::Zero(0, 0);
187 rbfVec, Eigen::MatrixXd mu_interp)
190 "Matrix 'mu_interp' must have same number and order of columns (i.e. parameters) as the matrix 'mu_samples'.");
191 int Nmodes = rbfVec.size();
193 int Nsamples = mu_interp.rows();
194 Eigen::MatrixXd muInterpRefined(mu_interp.rows(), 0);
197 for (
int i = 0; i < mu_interp.cols(); i++)
199 double firstVal = mu_interp(0, i);
200 bool isConst = (mu_interp.col(i).array() == firstVal).all();
205 muInterpRefined.conservativeResize(muInterpRefined.rows(),
206 muInterpRefined.cols() + 1);
207 muInterpRefined.col(muInterpRefined.cols() - 1) = mu_interp.col(i);
211 int Nmu = muInterpRefined.cols();
212 Eigen::MatrixXd coeff_interp(Nmodes, Nsamples);
214 for (
int i = 0; i < Nmodes; i++)
216 for (
int j = 0; j < Nsamples; j++)
218 SPLINTER::DenseVector x(Nmu);
220 for (
int k = 0; k < Nmu; k++)
222 x(k) = muInterpRefined(j, k);
225 coeff_interp(i, j) = rbfVec[i].eval(x);
234 splVec, Eigen::MatrixXd mu_interp)
237 "Matrix 'mu_interp' must have same number and order of columns (i.e. parametes) as the matrix 'mu_samples'.");
238 int Nmodes = splVec.size();
240 int Nsamples = mu_interp.rows();
241 Eigen::MatrixXd muInterpRefined(mu_interp.rows(), 0);
244 for (
int i = 0; i < mu_interp.cols(); i++)
246 double firstVal = mu_interp(0, i);
247 bool isConst = (mu_interp.col(i).array() == firstVal).all();
252 muInterpRefined.conservativeResize(muInterpRefined.rows(),
253 muInterpRefined.cols() + 1);
254 muInterpRefined.col(muInterpRefined.cols() - 1) = mu_interp.col(i);
258 int Nmu = muInterpRefined.cols();
259 Eigen::MatrixXd coeff_interp(Nmodes, Nsamples);
261 for (
int i = 0; i < Nmodes; i++)
263 for (
int j = 0; j < Nsamples; j++)
265 SPLINTER::DenseVector x(Nmu);
267 for (
int k = 0; k < Nmu; k++)
269 x(k) = muInterpRefined(j, k);
272 coeff_interp(i, j) = splVec[i].eval(x);
static Eigen::MatrixXd solveLinearSys(List< Eigen::MatrixXd > LinSys, Eigen::MatrixXd x, Eigen::VectorXd &residual, const Eigen::MatrixXd &bc=Eigen::MatrixXd::Zero(0, 0), const std::string solverType="fullPivLu")
Linear system solver for the online problem.