67 int i = 0, j = 0, k = 0;
70 for (k = 0; k < n; k++) {
73 for (i = k; i < m; i++) {
74 nrm = hypot(nrm, QR_(i, k));
79 if (QR_(k, k) < 0) { nrm = -nrm; }
80 for (i = k; i < m; i++) {
86 for (j = k + 1; j < n; j++) {
88 for (i = k; i < m; i++) {
89 s += QR_(i, k) * QR_(i, j);
92 for (i = k; i < m; i++) {
93 QR_(i, j) += s * QR_(i, k);
107 for (
int j = 0; j < n; j++) {
108 if (Rdiag(j) == 0)
return 0;
124 for (
int i = 0; i < m; i++) {
125 for (
int j = 0; j < n; j++) {
141 for (
int i = 0; i < n; i++) {
142 for (
int j = 0; j < n; j++) {
160 int i = 0, j = 0, k = 0;
163 for (k = n - 1; k >= 0; k--) {
164 for (i = 0; i < m; i++) {
168 for (j = k; j < n; j++) {
169 if (QR_(k, k) != 0) {
171 for (i = k; i < m; i++) {
172 s += QR_(i, k) * Q(i, j);
175 for (i = k; i < m; i++) {
176 Q(i, j) += s * QR_(i, k);
191 if (b.size() != (
unsigned int)m)
202 for (
int k = 0; k < n; k++) {
204 for (
int i = k; i < m; i++) {
205 s += QR_(i, k) * x(i);
208 for (
int i = k; i < m; i++) {
209 x(i) += s * QR_(i, k);
213 for (
int k = n - 1; k >= 0; k--) {
215 for (
int i = 0; i < k; i++) {
216 x(i) -= x(k) * QR_(i, k);
222 for (
int i = 0; i < n; i++)
235 if (B.getNRow() != m)
243 int nx = B.getNCol();
245 int i = 0, j = 0, k = 0;
248 for (k = 0; k < n; k++) {
249 for (j = 0; j < nx; j++) {
251 for (i = k; i < m; i++) {
252 s += QR_(i, k) * X(i, j);
255 for (i = k; i < m; i++) {
256 X(i, j) += s * QR_(i, k);
261 for (k = n - 1; k >= 0; k--) {
262 for (j = 0; j < nx; j++) {
265 for (i = 0; i < k; i++) {
266 for (j = 0; j < nx; j++) {
267 X(i, j) -= X(k, j) * QR_(i, k);
274 for (i = 0; i < n; i++)
275 for (j = 0; j < nx; j++)
DynamicRectMatrix< Real > solve(const DynamicRectMatrix< Real > &B) const
Least squares solution of A*X = B.
int isFullRank() const
Flag to denote the matrix is of full rank.
DynamicVector< Real > solve(const DynamicVector< Real > &b) const
Least squares solution of A*x = b.
DynamicRectMatrix< Real > getQ() const
Generate and return the (economy-sized) orthogonal factor.
DynamicRectMatrix< Real > getHouseholder(void) const
Retreive the Householder vectors from QR factorization.
DynamicRectMatrix< Real > getR() const
Return the upper triangular factor, R, of the QR factorization.
Dynamically-sized vector class.
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.