SCALAPACK 2.2.2
LAPACK: Linear Algebra PACKage
All Classes Files Functions Variables Typedefs Macros
lamov.h
Go to the documentation of this file.
1//
2// lamov.h
3//
4// Written by Lee Killough 04/19/2012
5//
6
7#include "pblas.h"
8#include <ctype.h>
9
10extern void xerbla_(const char *, const F_INTG_FCT *, size_t);
11
12void LACPY(const char *UPLO,
13 const F_INTG_FCT *M,
14 const F_INTG_FCT *N,
15 const TYPE *A,
16 const F_INTG_FCT *LDA,
17 TYPE *B,
18 const F_INTG_FCT *LDB);
19
20void LAMOV(const char *UPLO,
21 const F_INTG_FCT *M,
22 const F_INTG_FCT *N,
23 const TYPE *A,
24 const F_INTG_FCT *LDA,
25 TYPE *B,
26 const F_INTG_FCT *LDB)
27{
28 const F_INTG_FCT m = *M;
29 const F_INTG_FCT n = *N;
30 const F_INTG_FCT lda = *LDA;
31 const F_INTG_FCT ldb = *LDB;
32
33 if (B + m-1 + ldb*(n-1) < A || A + m-1 + lda*(n-1) < B)
34 {
35 LACPY(UPLO, M, N, A, LDA, B, LDB);
36 }
37 else if (lda != ldb)
38 {
39 TYPE *tmp = malloc(sizeof(*A) * m * n);
40 if (!tmp)
41 {
42 F_INTG_FCT info = -1;
43 const char func[] = FUNC;
44 xerbla_(func, &info, sizeof func);
45 }
46 else
47 {
48 LACPY(UPLO, M, N, A, LDA, tmp, &m);
49 LACPY(UPLO, M, N, tmp, &m, B, LDB);
50 free(tmp);
51 }
52 }
53 else
54 {
55 F_INTG_FCT i, j;
56 switch (toupper(*UPLO))
57 {
58 case 'U':
59 if (A > B)
60 {
61 for (j=0; j<n; j++)
62 for (i=0; i<j && i<m; i++)
63 B[i+ldb*j] = A[i+lda*j];
64 }
65 else
66 {
67 for (j=n; --j>=0;)
68 for (i=j<m ? j : m; --i>=0;)
69 B[i+ldb*j] = A[i+lda*j];
70 }
71 break;
72
73 case 'L':
74 if (A > B)
75 {
76 for (j=0; j<n; j++)
77 for (i=j; i<m; i++)
78 B[i+ldb*j] = A[i+lda*j];
79 }
80 else
81 {
82 for (j=m<n ? m : n; --j>=0;)
83 for (i=m; --i>=j;)
84 B[i+ldb*j] = A[i+lda*j];
85 }
86 break;
87
88 default:
89 if (A > B)
90 {
91 for (j=0; j<n; j++)
92 for (i=0; i<m; i++)
93 B[i+ldb*j] = A[i+lda*j];
94 }
95 else
96 {
97 for (j=n; --j>=0;)
98 for (i=m; --i>=0;)
99 B[i+ldb*j] = A[i+lda*j];
100 }
101 break;
102 }
103 }
104}
#define F_INTG_FCT
Definition pblas.h:128
#define LAMOV
Definition clamov.c:9
#define FUNC
Definition clamov.c:8
#define TYPE
Definition clamov.c:7
#define LACPY
Definition clamov.c:10
void xerbla_(const char *, const F_INTG_FCT *, size_t)