My Project
Loading...
Searching...
No Matches
Functions
qr Namespace Reference

Functions

template<unsigned int Precision>
void rmatrixqr (ap::template_2d_array< amp::ampf< Precision > > &a, int m, int n, ap::template_1d_array< amp::ampf< Precision > > &tau)
 
template<unsigned int Precision>
void rmatrixqrunpackq (const ap::template_2d_array< amp::ampf< Precision > > &a, int m, int n, const ap::template_1d_array< amp::ampf< Precision > > &tau, int qcolumns, ap::template_2d_array< amp::ampf< Precision > > &q)
 
template<unsigned int Precision>
void rmatrixqrunpackr (const ap::template_2d_array< amp::ampf< Precision > > &a, int m, int n, ap::template_2d_array< amp::ampf< Precision > > &r)
 
template<unsigned int Precision>
void qrdecomposition (ap::template_2d_array< amp::ampf< Precision > > &a, int m, int n, ap::template_1d_array< amp::ampf< Precision > > &tau)
 
template<unsigned int Precision>
void unpackqfromqr (const ap::template_2d_array< amp::ampf< Precision > > &a, int m, int n, const ap::template_1d_array< amp::ampf< Precision > > &tau, int qcolumns, ap::template_2d_array< amp::ampf< Precision > > &q)
 
template<unsigned int Precision>
void qrdecompositionunpacked (ap::template_2d_array< amp::ampf< Precision > > a, int m, int n, ap::template_2d_array< amp::ampf< Precision > > &q, ap::template_2d_array< amp::ampf< Precision > > &r)
 

Function Documentation

◆ qrdecomposition()

template<unsigned int Precision>
void qr::qrdecomposition ( ap::template_2d_array< amp::ampf< Precision > > &  a,
int  m,
int  n,
ap::template_1d_array< amp::ampf< Precision > > &  tau 
)

Definition at line 303 of file qr.h.

307 {
310 int i;
311 int k;
312 int mmip1;
313 int minmn;
315
316
317 minmn = ap::minint(m, n);
318 work.setbounds(1, n);
319 t.setbounds(1, m);
320 tau.setbounds(1, minmn);
321
322 //
323 // Test the input arguments
324 //
325 k = ap::minint(m, n);
326 for(i=1; i<=k; i++)
327 {
328
329 //
330 // Generate elementary reflector H(i) to annihilate A(i+1:m,i)
331 //
332 mmip1 = m-i+1;
333 ap::vmove(t.getvector(1, mmip1), a.getcolumn(i, i, m));
334 reflections::generatereflection<Precision>(t, mmip1, tmp);
335 tau(i) = tmp;
336 ap::vmove(a.getcolumn(i, i, m), t.getvector(1, mmip1));
337 t(1) = 1;
338 if( i<n )
339 {
340
341 //
342 // Apply H(i) to A(i:m,i+1:n) from the left
343 //
344 reflections::applyreflectionfromtheleft<Precision>(a, tau(i), t, i, m, i+1, n, work);
345 }
346 }
347 }
int m
Definition: cfEzgcd.cc:128
int i
Definition: cfEzgcd.cc:132
int k
Definition: cfEzgcd.cc:99
void tau(int **points, int sizePoints, int k)
Definition: amp.h:82
raw_vector< T > getvector(int iStart, int iEnd)
Definition: ap.h:776
void setbounds(int iLow, int iHigh)
Definition: ap.h:735
raw_vector< T > getcolumn(int iColumn, int iRowStart, int iRowEnd)
Definition: ap.h:931
void vmove(raw_vector< T > vdst, const_raw_vector< T > vsrc)
Definition: ap.h:237
int minint(int m1, int m2)
Definition: ap.cpp:167

◆ qrdecompositionunpacked()

template<unsigned int Precision>
void qr::qrdecompositionunpacked ( ap::template_2d_array< amp::ampf< Precision > >  a,
int  m,
int  n,
ap::template_2d_array< amp::ampf< Precision > > &  q,
ap::template_2d_array< amp::ampf< Precision > > &  r 
)

Definition at line 420 of file qr.h.

425 {
426 int i;
427 int k;
431
432
433 k = ap::minint(m, n);
434 if( n<=0 )
435 {
436 return;
437 }
438 work.setbounds(1, m);
439 v.setbounds(1, m);
440 q.setbounds(1, m, 1, m);
441 r.setbounds(1, m, 1, n);
442
443 //
444 // QRDecomposition
445 //
446 qrdecomposition<Precision>(a, m, n, tau);
447
448 //
449 // R
450 //
451 for(i=1; i<=n; i++)
452 {
453 r(1,i) = 0;
454 }
455 for(i=2; i<=m; i++)
456 {
457 ap::vmove(r.getrow(i, 1, n), r.getrow(1, 1, n));
458 }
459 for(i=1; i<=k; i++)
460 {
461 ap::vmove(r.getrow(i, i, n), a.getrow(i, i, n));
462 }
463
464 //
465 // Q
466 //
467 unpackqfromqr<Precision>(a, m, n, tau, m, q);
468 }
void setbounds(int iLow1, int iHigh1, int iLow2, int iHigh2)
Definition: ap.h:890
raw_vector< T > getrow(int iRow, int iColumnStart, int iColumnEnd)
Definition: ap.h:939
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39

◆ rmatrixqr()

template<unsigned int Precision>
void qr::rmatrixqr ( ap::template_2d_array< amp::ampf< Precision > > &  a,
int  m,
int  n,
ap::template_1d_array< amp::ampf< Precision > > &  tau 
)

Definition at line 123 of file qr.h.

127 {
130 int i;
131 int k;
132 int minmn;
134
135
136 if( m<=0 || n<=0 )
137 {
138 return;
139 }
140 minmn = ap::minint(m, n);
141 work.setbounds(0, n-1);
142 t.setbounds(1, m);
143 tau.setbounds(0, minmn-1);
144
145 //
146 // Test the input arguments
147 //
148 k = minmn;
149 for(i=0; i<=k-1; i++)
150 {
151
152 //
153 // Generate elementary reflector H(i) to annihilate A(i+1:m,i)
154 //
155 ap::vmove(t.getvector(1, m-i), a.getcolumn(i, i, m-1));
156 reflections::generatereflection<Precision>(t, m-i, tmp);
157 tau(i) = tmp;
158 ap::vmove(a.getcolumn(i, i, m-1), t.getvector(1, m-i));
159 t(1) = 1;
160 if( i<n )
161 {
162
163 //
164 // Apply H(i) to A(i:m-1,i+1:n-1) from the left
165 //
166 reflections::applyreflectionfromtheleft<Precision>(a, tau(i), t, i, m-1, i+1, n-1, work);
167 }
168 }
169 }

◆ rmatrixqrunpackq()

template<unsigned int Precision>
void qr::rmatrixqrunpackq ( const ap::template_2d_array< amp::ampf< Precision > > &  a,
int  m,
int  n,
const ap::template_1d_array< amp::ampf< Precision > > &  tau,
int  qcolumns,
ap::template_2d_array< amp::ampf< Precision > > &  q 
)

Definition at line 193 of file qr.h.

199 {
200 int i;
201 int j;
202 int k;
203 int minmn;
206
207
209 if( m<=0 || n<=0 || qcolumns<=0 )
210 {
211 return;
212 }
213
214 //
215 // init
216 //
217 minmn = ap::minint(m, n);
218 k = ap::minint(minmn, qcolumns);
219 q.setbounds(0, m-1, 0, qcolumns-1);
220 v.setbounds(1, m);
221 work.setbounds(0, qcolumns-1);
222 for(i=0; i<=m-1; i++)
223 {
224 for(j=0; j<=qcolumns-1; j++)
225 {
226 if( i==j )
227 {
228 q(i,j) = 1;
229 }
230 else
231 {
232 q(i,j) = 0;
233 }
234 }
235 }
236
237 //
238 // unpack Q
239 //
240 for(i=k-1; i>=0; i--)
241 {
242
243 //
244 // Apply H(i)
245 //
246 ap::vmove(v.getvector(1, m-i), a.getcolumn(i, i, m-1));
247 v(1) = 1;
248 reflections::applyreflectionfromtheleft<Precision>(q, tau(i), v, i, m-1, 0, qcolumns-1, work);
249 }
250 }
static void make_assertion(bool bClause)
Definition: ap.h:49
int j
Definition: facHensel.cc:110

◆ rmatrixqrunpackr()

template<unsigned int Precision>
void qr::rmatrixqrunpackr ( const ap::template_2d_array< amp::ampf< Precision > > &  a,
int  m,
int  n,
ap::template_2d_array< amp::ampf< Precision > > &  r 
)

Definition at line 269 of file qr.h.

273 {
274 int i;
275 int k;
276
277
278 if( m<=0 || n<=0 )
279 {
280 return;
281 }
282 k = ap::minint(m, n);
283 r.setbounds(0, m-1, 0, n-1);
284 for(i=0; i<=n-1; i++)
285 {
286 r(0,i) = 0;
287 }
288 for(i=1; i<=m-1; i++)
289 {
290 ap::vmove(r.getrow(i, 0, n-1), r.getrow(0, 0, n-1));
291 }
292 for(i=0; i<=k-1; i++)
293 {
294 ap::vmove(r.getrow(i, i, n-1), a.getrow(i, i, n-1));
295 }
296 }

◆ unpackqfromqr()

template<unsigned int Precision>
void qr::unpackqfromqr ( const ap::template_2d_array< amp::ampf< Precision > > &  a,
int  m,
int  n,
const ap::template_1d_array< amp::ampf< Precision > > &  tau,
int  qcolumns,
ap::template_2d_array< amp::ampf< Precision > > &  q 
)

Definition at line 354 of file qr.h.

360 {
361 int i;
362 int j;
363 int k;
364 int minmn;
367 int vm;
368
369
371 if( m==0 || n==0 || qcolumns==0 )
372 {
373 return;
374 }
375
376 //
377 // init
378 //
379 minmn = ap::minint(m, n);
380 k = ap::minint(minmn, qcolumns);
381 q.setbounds(1, m, 1, qcolumns);
382 v.setbounds(1, m);
383 work.setbounds(1, qcolumns);
384 for(i=1; i<=m; i++)
385 {
386 for(j=1; j<=qcolumns; j++)
387 {
388 if( i==j )
389 {
390 q(i,j) = 1;
391 }
392 else
393 {
394 q(i,j) = 0;
395 }
396 }
397 }
398
399 //
400 // unpack Q
401 //
402 for(i=k; i>=1; i--)
403 {
404
405 //
406 // Apply H(i)
407 //
408 vm = m-i+1;
409 ap::vmove(v.getvector(1, vm), a.getcolumn(i, i, m));
410 v(1) = 1;
411 reflections::applyreflectionfromtheleft<Precision>(q, tau(i), v, i, m, 1, qcolumns, work);
412 }
413 }