~ubuntu-branches/ubuntu/karmic/python-scipy/karmic

« back to all changes in this revision

Viewing changes to Lib/special/cephes/mtransp.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T. Chen (new)
  • Date: 2005-03-16 02:15:29 UTC
  • Revision ID: james.westby@ubuntu.com-20050316021529-xrjlowsejs0cijig
Tags: upstream-0.3.2
ImportĀ upstreamĀ versionĀ 0.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*                                                      mtransp.c
 
2
 *
 
3
 *      Matrix transpose
 
4
 *
 
5
 *
 
6
 *
 
7
 * SYNOPSIS:
 
8
 *
 
9
 * int n;
 
10
 * double A[n*n], T[n*n];
 
11
 *
 
12
 * mtransp( n, A, T );
 
13
 *
 
14
 *
 
15
 *
 
16
 * DESCRIPTION:
 
17
 *
 
18
 *
 
19
 * T[r][c] = A[c][r]
 
20
 *
 
21
 *
 
22
 * Transposes the n by n square matrix A and puts the result in T.
 
23
 * The output, T, may occupy the same storage as A.
 
24
 *
 
25
 *
 
26
 *
 
27
 */
 
28
 
 
29
 
 
30
#define ANSIPROT
 
31
#ifdef ANSIPROT
 
32
void mtransp( int,double*,double* );
 
33
#endif
 
34
 
 
35
void
 
36
mtransp( n, A, T )
 
37
int n;
 
38
double *A, *T;
 
39
{
 
40
int i, j, np1;
 
41
double *pAc, *pAr, *pTc, *pTr, *pA0, *pT0;
 
42
double x;
 
43
 
 
44
np1 = n+1;
 
45
pA0 = A;
 
46
pT0 = T;
 
47
for( i=0; i<n-1; i++ ) /* row index */
 
48
        {
 
49
        pAc = pA0; /* next diagonal element of input */
 
50
        pAr = pAc + n; /* next row down underneath the diagonal element */
 
51
        pTc = pT0; /* next diagonal element of the output */
 
52
        pTr = pTc + n; /* next row underneath */
 
53
        *pTc++ = *pAc++; /* copy the diagonal element */
 
54
        for( j=i+1; j<n; j++ ) /* column index */
 
55
                {
 
56
                x = *pAr;
 
57
                *pTr = *pAc++;
 
58
                *pTc++ = x;
 
59
                pAr += n;
 
60
                pTr += n;
 
61
                }
 
62
        pA0 += np1; /* &A[n*i+i] for next i */
 
63
        pT0 += np1; /* &T[n*i+i] for next i */
 
64
        }
 
65
*pT0 = *pA0; /* copy the diagonal element */
 
66
}
 
67