My Project
Loading...
Searching...
No Matches
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 100 of file rotations.h.

109 {
110 int j;
111 int jp1;
115
116
117 if( m1>m2 || n1>n2 )
118 {
119 return;
120 }
121
122 //
123 // Form P * A
124 //
125 if( isforward )
126 {
127 if( n1!=n2 )
128 {
129
130 //
131 // Common case: N1<>N2
132 //
133 for(j=m1; j<=m2-1; j++)
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 }
Definition: amp.h:82
raw_vector< T > getvector(int iStart, int iEnd)
Definition: ap.h:776
raw_vector< T > getrow(int iRow, int iColumnStart, int iColumnEnd)
Definition: ap.h:939
const CanonicalForm int s
Definition: facAbsFact.cc:51
int j
Definition: facHensel.cc:110
void vmove(raw_vector< T > vdst, const_raw_vector< T > vsrc)
Definition: ap.h:237
void vadd(raw_vector< T > vdst, const_raw_vector< T > vsrc)
Definition: ap.h:413
void vmul(raw_vector< T > vdst, T2 alpha)
Definition: ap.h:603
void vsub(raw_vector< T > vdst, const_raw_vector< T > vsrc)
Definition: ap.h:533

◆ 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 238 of file rotations.h.

247 {
248 int j;
249 int jp1;
253
254
255
256 //
257 // Form A * P'
258 //
259 if( isforward )
260 {
261 if( m1!=m2 )
262 {
263
264 //
265 // Common case: M1<>M2
266 //
267 for(j=n1; j<=n2-1; j++)
268 {
269 ctemp = c(j-n1+1);
270 stemp = s(j-n1+1);
271 if( ctemp!=1 || stemp!=0 )
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 }
raw_vector< T > getcolumn(int iColumn, int iRowStart, int iRowEnd)
Definition: ap.h:931

◆ 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 355 of file rotations.h.

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;
376 sn = 1;
377 r = g;
378 }
379 else
380 {
381 f1 = f;
382 g1 = g;
383 r = amp::sqrt<Precision>(amp::sqr<Precision>(f1)+amp::sqr<Precision>(g1));
384 cs = f1/r;
385 sn = g1/r;
386 if( amp::abs<Precision>(f)>amp::abs<Precision>(g) && cs<0 )
387 {
388 cs = -cs;
389 sn = -sn;
390 r = -r;
391 }
392 }
393 }
394 }
g
Definition: cfModGcd.cc:4090
FILE * f
Definition: checklibs.c:9