My Project  debian-1:4.1.1-p2+ds-4
Functions
rotations Namespace Reference

Functions

template<unsigned int Precision>
void applyrotationsfromtheleft (bool isforward, int m1, int m2, int n1, int n2, const ap::template_1d_array< amp::ampf< Precision > > &c, const ap::template_1d_array< amp::ampf< Precision > > &s, ap::template_2d_array< amp::ampf< Precision > > &a, ap::template_1d_array< amp::ampf< Precision > > &work)
 
template<unsigned int Precision>
void applyrotationsfromtheright (bool isforward, int m1, int m2, int n1, int n2, const ap::template_1d_array< amp::ampf< Precision > > &c, const ap::template_1d_array< amp::ampf< Precision > > &s, ap::template_2d_array< amp::ampf< Precision > > &a, ap::template_1d_array< amp::ampf< Precision > > &work)
 
template<unsigned int Precision>
void generaterotation (amp::ampf< Precision > f, amp::ampf< Precision > g, amp::ampf< Precision > &cs, amp::ampf< Precision > &sn, amp::ampf< Precision > &r)
 

Function Documentation

◆ applyrotationsfromtheleft()

template<unsigned int Precision>
void rotations::applyrotationsfromtheleft ( bool  isforward,
int  m1,
int  m2,
int  n1,
int  n2,
const ap::template_1d_array< amp::ampf< Precision > > &  c,
const ap::template_1d_array< amp::ampf< Precision > > &  s,
ap::template_2d_array< amp::ampf< Precision > > &  a,
ap::template_1d_array< amp::ampf< Precision > > &  work 
)

Definition at line 133 of file rotations.h.

134  {
135  ctemp = c(j-m1+1);
136  stemp = s(j-m1+1);
137  if( ctemp!=1 || stemp!=0 )
138  {
139  jp1 = j+1;
140  ap::vmove(work.getvector(n1, n2), a.getrow(jp1, n1, n2), ctemp);
141  ap::vsub(work.getvector(n1, n2), a.getrow(j, n1, n2), stemp);
142  ap::vmul(a.getrow(j, n1, n2), ctemp);
143  ap::vadd(a.getrow(j, n1, n2), a.getrow(jp1, n1, n2), stemp);
144  ap::vmove(a.getrow(jp1, n1, n2), work.getvector(n1, n2));
145  }
146  }
147  }
148  else
149  {
150 
151  //
152  // Special case: N1=N2
153  //
154  for(j=m1; j<=m2-1; j++)
155  {
156  ctemp = c(j-m1+1);
157  stemp = s(j-m1+1);
158  if( ctemp!=1 || stemp!=0 )
159  {
160  temp = a(j+1,n1);
161  a(j+1,n1) = ctemp*temp-stemp*a(j,n1);
162  a(j,n1) = stemp*temp+ctemp*a(j,n1);
163  }
164  }
165  }
166  }
167  else
168  {
169  if( n1!=n2 )
170  {
171 
172  //
173  // Common case: N1<>N2
174  //
175  for(j=m2-1; j>=m1; j--)
176  {
177  ctemp = c(j-m1+1);
178  stemp = s(j-m1+1);
179  if( ctemp!=1 || stemp!=0 )
180  {
181  jp1 = j+1;
182  ap::vmove(work.getvector(n1, n2), a.getrow(jp1, n1, n2), ctemp);
183  ap::vsub(work.getvector(n1, n2), a.getrow(j, n1, n2), stemp);
184  ap::vmul(a.getrow(j, n1, n2), ctemp);
185  ap::vadd(a.getrow(j, n1, n2), a.getrow(jp1, n1, n2), stemp);
186  ap::vmove(a.getrow(jp1, n1, n2), work.getvector(n1, n2));
187  }
188  }
189  }
190  else
191  {
192 
193  //
194  // Special case: N1=N2
195  //
196  for(j=m2-1; j>=m1; j--)
197  {
198  ctemp = c(j-m1+1);
199  stemp = s(j-m1+1);
200  if( ctemp!=1 || stemp!=0 )
201  {
202  temp = a(j+1,n1);
203  a(j+1,n1) = ctemp*temp-stemp*a(j,n1);
204  a(j,n1) = stemp*temp+ctemp*a(j,n1);
205  }
206  }
207  }
208  }
209  }
210 
211 
212  /*************************************************************************
213  Application of a sequence of elementary rotations to a matrix
214 
215  The algorithm post-multiplies the matrix by a sequence of rotation
216  transformations which is given by arrays C and S. Depending on the value
217  of the IsForward parameter either 1 and 2, 3 and 4 and so on (if IsForward=true)
218  rows are rotated, or the rows N and N-1, N-2 and N-3 and so on are rotated.
219 
220  Not the whole matrix but only a part of it is transformed (rows from M1
221  to M2, columns from N1 to N2). Only the elements of this submatrix are changed.
222 
223  Input parameters:
224  IsForward - the sequence of the rotation application.
225  M1,M2 - the range of rows to be transformed.
226  N1, N2 - the range of columns to be transformed.
227  C,S - transformation coefficients.
228  Array whose index ranges within [1..N2-N1].
229  A - processed matrix.
230  WORK - working array whose index ranges within [M1..M2].
231 
232  Output parameters:
233  A - transformed matrix.
234 
235  Utility subroutine.
236  *************************************************************************/
237  template<unsigned int Precision>
238  void applyrotationsfromtheright(bool isforward,
239  int m1,
240  int m2,
241  int n1,
242  int n2,

◆ applyrotationsfromtheright()

template<unsigned int Precision>
void rotations::applyrotationsfromtheright ( bool  isforward,
int  m1,
int  m2,
int  n1,
int  n2,
const ap::template_1d_array< amp::ampf< Precision > > &  c,
const ap::template_1d_array< amp::ampf< Precision > > &  s,
ap::template_2d_array< amp::ampf< Precision > > &  a,
ap::template_1d_array< amp::ampf< Precision > > &  work 
)

Definition at line 270 of file rotations.h.

272  {
273  jp1 = j+1;
274  ap::vmove(work.getvector(m1, m2), a.getcolumn(jp1, m1, m2), ctemp);
275  ap::vsub(work.getvector(m1, m2), a.getcolumn(j, m1, m2), stemp);
276  ap::vmul(a.getcolumn(j, m1, m2), ctemp);
277  ap::vadd(a.getcolumn(j, m1, m2), a.getcolumn(jp1, m1, m2), stemp);
278  ap::vmove(a.getcolumn(jp1, m1, m2), work.getvector(m1, m2));
279  }
280  }
281  }
282  else
283  {
284 
285  //
286  // Special case: M1=M2
287  //
288  for(j=n1; j<=n2-1; j++)
289  {
290  ctemp = c(j-n1+1);
291  stemp = s(j-n1+1);
292  if( ctemp!=1 || stemp!=0 )
293  {
294  temp = a(m1,j+1);
295  a(m1,j+1) = ctemp*temp-stemp*a(m1,j);
296  a(m1,j) = stemp*temp+ctemp*a(m1,j);
297  }
298  }
299  }
300  }
301  else
302  {
303  if( m1!=m2 )
304  {
305 
306  //
307  // Common case: M1<>M2
308  //
309  for(j=n2-1; j>=n1; j--)
310  {
311  ctemp = c(j-n1+1);
312  stemp = s(j-n1+1);
313  if( ctemp!=1 || stemp!=0 )
314  {
315  jp1 = j+1;
316  ap::vmove(work.getvector(m1, m2), a.getcolumn(jp1, m1, m2), ctemp);
317  ap::vsub(work.getvector(m1, m2), a.getcolumn(j, m1, m2), stemp);
318  ap::vmul(a.getcolumn(j, m1, m2), ctemp);
319  ap::vadd(a.getcolumn(j, m1, m2), a.getcolumn(jp1, m1, m2), stemp);
320  ap::vmove(a.getcolumn(jp1, m1, m2), work.getvector(m1, m2));
321  }
322  }
323  }
324  else
325  {
326 
327  //
328  // Special case: M1=M2
329  //
330  for(j=n2-1; j>=n1; j--)
331  {
332  ctemp = c(j-n1+1);
333  stemp = s(j-n1+1);
334  if( ctemp!=1 || stemp!=0 )
335  {
336  temp = a(m1,j+1);
337  a(m1,j+1) = ctemp*temp-stemp*a(m1,j);
338  a(m1,j) = stemp*temp+ctemp*a(m1,j);
339  }
340  }
341  }
342  }
343  }
344 
345 
346  /*************************************************************************
347  The subroutine generates the elementary rotation, so that:
348 
349  [ CS SN ] . [ F ] = [ R ]
350  [ -SN CS ] [ G ] [ 0 ]
351 
352  CS**2 + SN**2 = 1
353  *************************************************************************/
354  template<unsigned int Precision>
360  {
363 
364 
365  if( g==0 )
366  {
367  cs = 1;
368  sn = 0;
369  r = f;
370  }
371  else
372  {
373  if( f==0 )
374  {
375  cs = 0;

◆ generaterotation()

template<unsigned int Precision>
void rotations::generaterotation ( amp::ampf< Precision >  f,
amp::ampf< Precision >  g,
amp::ampf< Precision > &  cs,
amp::ampf< Precision > &  sn,
amp::ampf< Precision > &  r 
)

Definition at line 386 of file rotations.h.

387  {
388  cs = -cs;
389  sn = -sn;
390  r = -r;
391  }
392  }
393  }
394  }
395 } // namespace
396 
397 #endif
rotations::generaterotation
void generaterotation(amp::ampf< Precision > f, amp::ampf< Precision > g, amp::ampf< Precision > &cs, amp::ampf< Precision > &sn, amp::ampf< Precision > &r)
Definition: rotations.h:386
ap::vmove
void vmove(raw_vector< T > vdst, const_raw_vector< T > vsrc)
Definition: ap.h:230
j
int j
Definition: facHensel.cc:105
f
FILE * f
Definition: checklibs.c:9
ap::vadd
void vadd(raw_vector< T > vdst, const_raw_vector< T > vsrc)
Definition: ap.h:403
ap::template_1d_array::getvector
raw_vector< T > getvector(int iStart, int iEnd)
Definition: ap.h:762
amp::ampf
Definition: amp.h:82
g
g
Definition: cfModGcd.cc:4031
ap::vmul
void vmul(raw_vector< T > vdst, T2 alpha)
Definition: ap.h:589
ap::template_2d_array::getcolumn
raw_vector< T > getcolumn(int iColumn, int iRowStart, int iRowEnd)
Definition: ap.h:916
rotations::applyrotationsfromtheright
void applyrotationsfromtheright(bool isforward, int m1, int m2, int n1, int n2, const ap::template_1d_array< amp::ampf< Precision > > &c, const ap::template_1d_array< amp::ampf< Precision > > &s, ap::template_2d_array< amp::ampf< Precision > > &a, ap::template_1d_array< amp::ampf< Precision > > &work)
Definition: rotations.h:270
ap::template_2d_array::getrow
raw_vector< T > getrow(int iRow, int iColumnStart, int iColumnEnd)
Definition: ap.h:924
ap::vsub
void vsub(raw_vector< T > vdst, const_raw_vector< T > vsrc)
Definition: ap.h:521
s
const CanonicalForm int s
Definition: facAbsFact.cc:55