dlapmt.c
Go to the documentation of this file.
00001 /* dlapmt.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 /* Subroutine */ int dlapmt_(logical *forwrd, integer *m, integer *n, 
00017         doublereal *x, integer *ldx, integer *k)
00018 {
00019     /* System generated locals */
00020     integer x_dim1, x_offset, i__1, i__2;
00021 
00022     /* Local variables */
00023     integer i__, j, ii, in;
00024     doublereal temp;
00025 
00026 
00027 /*  -- LAPACK auxiliary routine (version 3.2) -- */
00028 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00029 /*     November 2006 */
00030 
00031 /*     .. Scalar Arguments .. */
00032 /*     .. */
00033 /*     .. Array Arguments .. */
00034 /*     .. */
00035 
00036 /*  Purpose */
00037 /*  ======= */
00038 
00039 /*  DLAPMT rearranges the columns of the M by N matrix X as specified */
00040 /*  by the permutation K(1),K(2),...,K(N) of the integers 1,...,N. */
00041 /*  If FORWRD = .TRUE.,  forward permutation: */
00042 
00043 /*       X(*,K(J)) is moved X(*,J) for J = 1,2,...,N. */
00044 
00045 /*  If FORWRD = .FALSE., backward permutation: */
00046 
00047 /*       X(*,J) is moved to X(*,K(J)) for J = 1,2,...,N. */
00048 
00049 /*  Arguments */
00050 /*  ========= */
00051 
00052 /*  FORWRD  (input) LOGICAL */
00053 /*          = .TRUE., forward permutation */
00054 /*          = .FALSE., backward permutation */
00055 
00056 /*  M       (input) INTEGER */
00057 /*          The number of rows of the matrix X. M >= 0. */
00058 
00059 /*  N       (input) INTEGER */
00060 /*          The number of columns of the matrix X. N >= 0. */
00061 
00062 /*  X       (input/output) DOUBLE PRECISION array, dimension (LDX,N) */
00063 /*          On entry, the M by N matrix X. */
00064 /*          On exit, X contains the permuted matrix X. */
00065 
00066 /*  LDX     (input) INTEGER */
00067 /*          The leading dimension of the array X, LDX >= MAX(1,M). */
00068 
00069 /*  K       (input/output) INTEGER array, dimension (N) */
00070 /*          On entry, K contains the permutation vector. K is used as */
00071 /*          internal workspace, but reset to its original value on */
00072 /*          output. */
00073 
00074 /*  ===================================================================== */
00075 
00076 /*     .. Local Scalars .. */
00077 /*     .. */
00078 /*     .. Executable Statements .. */
00079 
00080     /* Parameter adjustments */
00081     x_dim1 = *ldx;
00082     x_offset = 1 + x_dim1;
00083     x -= x_offset;
00084     --k;
00085 
00086     /* Function Body */
00087     if (*n <= 1) {
00088         return 0;
00089     }
00090 
00091     i__1 = *n;
00092     for (i__ = 1; i__ <= i__1; ++i__) {
00093         k[i__] = -k[i__];
00094 /* L10: */
00095     }
00096 
00097     if (*forwrd) {
00098 
00099 /*        Forward permutation */
00100 
00101         i__1 = *n;
00102         for (i__ = 1; i__ <= i__1; ++i__) {
00103 
00104             if (k[i__] > 0) {
00105                 goto L40;
00106             }
00107 
00108             j = i__;
00109             k[j] = -k[j];
00110             in = k[j];
00111 
00112 L20:
00113             if (k[in] > 0) {
00114                 goto L40;
00115             }
00116 
00117             i__2 = *m;
00118             for (ii = 1; ii <= i__2; ++ii) {
00119                 temp = x[ii + j * x_dim1];
00120                 x[ii + j * x_dim1] = x[ii + in * x_dim1];
00121                 x[ii + in * x_dim1] = temp;
00122 /* L30: */
00123             }
00124 
00125             k[in] = -k[in];
00126             j = in;
00127             in = k[in];
00128             goto L20;
00129 
00130 L40:
00131 
00132 /* L50: */
00133             ;
00134         }
00135 
00136     } else {
00137 
00138 /*        Backward permutation */
00139 
00140         i__1 = *n;
00141         for (i__ = 1; i__ <= i__1; ++i__) {
00142 
00143             if (k[i__] > 0) {
00144                 goto L80;
00145             }
00146 
00147             k[i__] = -k[i__];
00148             j = k[i__];
00149 L60:
00150             if (j == i__) {
00151                 goto L80;
00152             }
00153 
00154             i__2 = *m;
00155             for (ii = 1; ii <= i__2; ++ii) {
00156                 temp = x[ii + i__ * x_dim1];
00157                 x[ii + i__ * x_dim1] = x[ii + j * x_dim1];
00158                 x[ii + j * x_dim1] = temp;
00159 /* L70: */
00160             }
00161 
00162             k[j] = -k[j];
00163             j = k[j];
00164             goto L60;
00165 
00166 L80:
00167 
00168 /* L90: */
00169             ;
00170         }
00171 
00172     }
00173 
00174     return 0;
00175 
00176 /*     End of DLAPMT */
00177 
00178 } /* dlapmt_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:46