92 template <
class MaTRiX,
class Vector>
95 BIASASSERT(A.lbound() == 1);
96 BIASASSERT(C.
lbound() == 1);
97 BIASASSERT(D.
lbound() == 1);
105 typename MaTRiX::element_type eta, sigma, sum;
119 double absA = fabs(A(i,k));
120 eta = ( absA > eta ? absA : eta );
125 cerr <<
"QR: k=" << k <<
"\n";
132 A(i,k) = A(i,k) / eta;
136 sum = sum + A(i,k)*A(i,k);
137 sigma =
sign(A(k,k)) * sqrt(sum);
140 A(k,k) = A(k,k) + sigma;
141 C(k) = sigma * A(k,k);
144 for (j=k+1; j<=N; j++)
148 sum = sum + A(i,k)*A(i,j);
152 A(i,j) = A(i,j) - sum * A(i,k);
164 template <
class MaTRiX,
class Vector>
167 BIASASSERT(A.lbound() == 1);
168 BIASASSERT(D.
lbound() == 1);
169 BIASASSERT(b.
lbound() == 1);
174 BIASASSERT(N == A.num_cols());
175 BIASASSERT(N == D.
dim());
176 BIASASSERT(N == b.
dim());
178 typename MaTRiX::element_type sum;
186 for (i=N-1; i>=1; i--)
191 for (j=i+1; j<=N; j++)
192 sum = sum + A(i,j)*b(j);
193 b(i) = ( b(i) - sum ) /
201 template <
class MaTRiX,
class Vector>
205 BIASASSERT(A.lbound() == 1);
206 BIASASSERT(c.
lbound() == 1);
207 BIASASSERT(d.
lbound() == 1);
211 BIASASSERT(N == A.num_cols());
212 BIASASSERT(N == c.
dim());
213 BIASASSERT(N == d.
dim());
214 BIASASSERT(N == b.
dim());
217 typename MaTRiX::element_type sum, tau;
224 sum = sum + A(i,j)*b(i);
229 b(i) = b(i) - tau * A(i,j);
int QR_factor(MaTRiX &A, Vector &C, Vector &D)
TNT_SUBSCRIPT_TYPE Subscript
Vector< T > & newsize(Subscript N)
int R_solve(const MaTRiX &A, Vector &D, Vector &b)
int QR_solve(const MaTRiX &A, const Vector &c, Vector &d, Vector &b)