149 {
157 bool isupper;
158 int minmn;
159 int ncu;
160 int nrvt;
161 int nru;
162 int ncvt;
165 int im1;
167
168
171 {
173 }
177
178
179
180
182 w.setbounds(1, minmn);
183 ncu = 0;
184 nru = 0;
185 if( uneeded==1 )
186 {
188 ncu = minmn;
190 }
191 if( uneeded==2 )
192 {
196 }
197 nrvt = 0;
198 ncvt = 0;
199 if( vtneeded==1 )
200 {
201 nrvt = minmn;
202 ncvt = n;
204 }
205 if( vtneeded==2 )
206 {
207 nrvt = n;
208 ncvt = n;
210 }
211
212
213
214
215
217 {
218 if( uneeded==0 )
219 {
220
221
222
223
224 qr::rmatrixqr<Precision>(a,
m, n,
tau);
225 for(
i=0;
i<=n-1;
i++)
226 {
227 for(
j=0;
j<=
i-1;
j++)
228 {
230 }
231 }
232 bidiagonal::rmatrixbd<Precision>(a, n, n, tauq, taup);
233 bidiagonal::rmatrixbdunpackpt<Precision>(a, n, n, taup, nrvt, vt);
234 bidiagonal::rmatrixbdunpackdiagonals<Precision>(a, n, n, isupper,
w, e);
235 result = bdsvd::rmatrixbdsvd<Precision>(
w, e, n, isupper,
false, u, 0, a, 0, vt, ncvt);
237 }
238 else
239 {
240
241
242
243
244 qr::rmatrixqr<Precision>(a,
m, n,
tau);
245 qr::rmatrixqrunpackq<Precision>(a,
m, n,
tau, ncu, u);
246 for(
i=0;
i<=n-1;
i++)
247 {
248 for(
j=0;
j<=
i-1;
j++)
249 {
251 }
252 }
253 bidiagonal::rmatrixbd<Precision>(a, n, n, tauq, taup);
254 bidiagonal::rmatrixbdunpackpt<Precision>(a, n, n, taup, nrvt, vt);
255 bidiagonal::rmatrixbdunpackdiagonals<Precision>(a, n, n, isupper,
w, e);
256 if( additionalmemory<1 )
257 {
258
259
260
261
262 bidiagonal::rmatrixbdmultiplybyq<Precision>(a, n, n, tauq, u,
m, n,
true,
false);
263 result = bdsvd::rmatrixbdsvd<Precision>(
w, e, n, isupper,
false, u,
m, a, 0, vt, ncvt);
264 }
265 else
266 {
267
268
269
270
272 bidiagonal::rmatrixbdunpackq<Precision>(a, n, n, tauq, n, t2);
273 blas::copymatrix<Precision>(u, 0,
m-1, 0, n-1, a, 0,
m-1, 0, n-1);
274 blas::inplacetranspose<Precision>(t2, 0, n-1, 0, n-1, work);
275 result = bdsvd::rmatrixbdsvd<Precision>(
w, e, n, isupper,
false, u, 0, t2, n, vt, ncvt);
276 blas::matrixmatrixmultiply<Precision>(a, 0,
m-1, 0, n-1,
false, t2, 0, n-1, 0, n-1,
true,
amp::ampf<Precision>(
"1.0"), u, 0,
m-1, 0, n-1,
amp::ampf<Precision>(
"0.0"), work);
277 }
279 }
280 }
281
282
283
284
285
287 {
288 if( vtneeded==0 )
289 {
290
291
292
293
294 lq::rmatrixlq<Precision>(a,
m, n,
tau);
295 for(
i=0;
i<=
m-1;
i++)
296 {
297 for(
j=
i+1;
j<=
m-1;
j++)
298 {
300 }
301 }
302 bidiagonal::rmatrixbd<Precision>(a,
m,
m, tauq, taup);
303 bidiagonal::rmatrixbdunpackq<Precision>(a,
m,
m, tauq, ncu, u);
304 bidiagonal::rmatrixbdunpackdiagonals<Precision>(a,
m,
m, isupper,
w, e);
306 blas::inplacetranspose<Precision>(u, 0, nru-1, 0, ncu-1, work);
307 result = bdsvd::rmatrixbdsvd<Precision>(
w, e,
m, isupper,
false, a, 0, u, nru, vt, 0);
308 blas::inplacetranspose<Precision>(u, 0, nru-1, 0, ncu-1, work);
310 }
311 else
312 {
313
314
315
316
317 lq::rmatrixlq<Precision>(a,
m, n,
tau);
318 lq::rmatrixlqunpackq<Precision>(a,
m, n,
tau, nrvt, vt);
319 for(
i=0;
i<=
m-1;
i++)
320 {
321 for(
j=
i+1;
j<=
m-1;
j++)
322 {
324 }
325 }
326 bidiagonal::rmatrixbd<Precision>(a,
m,
m, tauq, taup);
327 bidiagonal::rmatrixbdunpackq<Precision>(a,
m,
m, tauq, ncu, u);
328 bidiagonal::rmatrixbdunpackdiagonals<Precision>(a,
m,
m, isupper,
w, e);
330 blas::inplacetranspose<Precision>(u, 0, nru-1, 0, ncu-1, work);
331 if( additionalmemory<1 )
332 {
333
334
335
336
337 bidiagonal::rmatrixbdmultiplybyp<Precision>(a,
m,
m, taup, vt,
m, n,
false,
true);
338 result = bdsvd::rmatrixbdsvd<Precision>(
w, e,
m, isupper,
false, a, 0, u, nru, vt, n);
339 }
340 else
341 {
342
343
344
345
346 bidiagonal::rmatrixbdunpackpt<Precision>(a,
m,
m, taup,
m, t2);
347 result = bdsvd::rmatrixbdsvd<Precision>(
w, e,
m, isupper,
false, a, 0, u, nru, t2,
m);
348 blas::copymatrix<Precision>(vt, 0,
m-1, 0, n-1, a, 0,
m-1, 0, n-1);
349 blas::matrixmatrixmultiply<Precision>(t2, 0,
m-1, 0,
m-1,
false, a, 0,
m-1, 0, n-1,
false,
amp::ampf<Precision>(
"1.0"), vt, 0,
m-1, 0, n-1,
amp::ampf<Precision>(
"0.0"), work);
350 }
351 blas::inplacetranspose<Precision>(u, 0, nru-1, 0, ncu-1, work);
353 }
354 }
355
356
357
358
359
361 {
362 bidiagonal::rmatrixbd<Precision>(a,
m, n, tauq, taup);
363 bidiagonal::rmatrixbdunpackq<Precision>(a,
m, n, tauq, ncu, u);
364 bidiagonal::rmatrixbdunpackpt<Precision>(a,
m, n, taup, nrvt, vt);
365 bidiagonal::rmatrixbdunpackdiagonals<Precision>(a,
m, n, isupper,
w, e);
367 blas::inplacetranspose<Precision>(u, 0, nru-1, 0, ncu-1, work);
368 result = bdsvd::rmatrixbdsvd<Precision>(
w, e, minmn, isupper,
false, a, 0, u, nru, vt, ncvt);
369 blas::inplacetranspose<Precision>(u, 0, nru-1, 0, ncu-1, work);
371 }
372
373
374
375
376 bidiagonal::rmatrixbd<Precision>(a,
m, n, tauq, taup);
377 bidiagonal::rmatrixbdunpackq<Precision>(a,
m, n, tauq, ncu, u);
378 bidiagonal::rmatrixbdunpackpt<Precision>(a,
m, n, taup, nrvt, vt);
379 bidiagonal::rmatrixbdunpackdiagonals<Precision>(a,
m, n, isupper,
w, e);
380 if( additionalmemory<2 || uneeded==0 )
381 {
382
383
384
385
386 result = bdsvd::rmatrixbdsvd<Precision>(
w, e, minmn, isupper,
false, u, nru, a, 0, vt, ncvt);
387 }
388 else
389 {
390
391
392
393
395 blas::copyandtranspose<Precision>(u, 0,
m-1, 0, minmn-1, t2, 0, minmn-1, 0,
m-1);
396 result = bdsvd::rmatrixbdsvd<Precision>(
w, e, minmn, isupper,
false, u, 0, t2,
m, vt, ncvt);
397 blas::copyandtranspose<Precision>(t2, 0, minmn-1, 0,
m-1, u, 0,
m-1, 0, minmn-1);
398 }
400 }
void tau(int **points, int sizePoints, int k)
static void make_assertion(bool bClause)
void setbounds(int iLow, int iHigh)
void setbounds(int iLow1, int iHigh1, int iLow2, int iHigh2)
int maxint(int m1, int m2)
int minint(int m1, int m2)