/*Translated by FOR_C, v3.4.2 (-), on 07/09/115 at 08:30:06 */ /*FOR_C Options SET: ftn=u io=c no=p op=aimnv s=dbov str=l x=f - prototypes */ #include #include "fcrt.h" #include "dmatp.h" #include #include #include void /*FUNCTION*/ dmatp( double *a, long lda, long m, long n, char *text) { #define A(I_,J_) (*(a+(I_)*(lda)+(J_))) long int _l0, iblock, j1, j2, mode, nblock; static long maxcol[2]={8,6}; /* OFFSET Vectors w/subscript range: 1 to dimension */ long *const Maxcol = &maxcol[0] - 1; /* end of OFFSET VECTORS */ /* DMATP.. Print a matrix. * Copyright (c) 1996 California Institute of Technology, Pasadena, CA. * ALL RIGHTS RESERVED. * Based on Government Sponsored Research NAS7-03001. *>> 2001-05-25 DMATP Krogh Minor change for making .f90 version. *>> 1996-07-02 DMATP Krogh Changes to use .C. and C%%. *>> 1996-03-30 DMATP Krogh Added external statement. *>> 1996-01-24 DMATP Krogh M77CON instructions for conversion to C. *>> 1994-10-20 DMATP Krogh Changes to use M77CON *>> 1994-08-08 DMATP CLL Special treatment for text(1:1) .eq. '0' *>> 1994-04-20 CLL Making DP & SP codes similar. *>> 1992-04-22 CLL *>> 1990-01-23 CLL removed extraneous "60 continue" *>> 1985-09-20 CLL *>> 1983-07-05 Kris Stewart For MATH77 *>> 1981-07-23 Kris Stewart Improve portability. *>> 1969-00-00 C. L. Lawson, JPL, Original code: MOUT/VOUT * ------------------------------------------------------------------ * A(,) Matrix to be output * LDA Leading dimension of array A(). * M No. of rows to be printed from A(). * N No. of cols to be printed from A(). * TEXT Character string to be printed as a title. * First character in TEXT controls line spacing before title on * an impact printer. For output to be viewed on a screen it is * safest to always use ' '. * ' ' = normal single space. * '0' = double space. * '1' = page advance. * '+' = suppress space, i.e., overprint. * ------------------------------------------------------------------ * Method: If the machine epsilon, is larger than 0.5*10**(-12), we set * MODE = 1 and print 8 numbers across a line, using a g15.7 format. * Otherwise we set MODE = 2 and print 6 numbers across a line, using a * g20.12 format. * ------------------------------------------------------------------ *--D replaces "?": ?MATP * ------------------------------------------------------------------ */ int i, j; /* Converter doesn't declare these for some reason. */ /* integer i, j */ /* ------------------------------------------------------------------ *++ CODE for ~.C. is inactive * data fmt1 /'(/12x,8(4x,a3,i4,4x)/1x)','(/12x,6(6x,a3,i5,6x)/1x)'/ * data fmt2 /'(a,i4,4x,1p,8g15.7 )', '(a,i4,4x,1p,6g20.12)'/ * if(text(1:1) .eq. '0') then * write(*,'(/1x,a)') text(2:) * else * write(*,'(a)') text * endif *++ CODE for .C. is active */ if(text[0] == '0') printf("\n %s\n", &text[1]); else printf("%s\n", text); if (DBL_EPSILON/FLT_RADIX > 0.5e-12) { /*++ END */ mode = 1; } else { mode = 2; } nblock = (n + Maxcol[mode] - 1)/Maxcol[mode]; j2 = 0; for (iblock = 1; iblock <= nblock; iblock++) { j1 = j2 + 1; j2 = min( j1 + Maxcol[mode] - 1, n ); /*++ CODE for ~.C. is inactive * write(*,fmt1(mode)) ('COL',j,j=j1,j2) * do 50 i=1,m * write(*,fmt2(mode)) ' ROW',i,(a(i,j),j=j1,j2) * 50 continue *++ CODE for .C. is active */ printf("\n "); if (mode == 1) { for (j = j1; j<= j2; j++) printf(" COL%4i ", j); printf("\n"); for (i = 1; i <= m; i++){ printf("ROW %4i", i); for (j=j1; j <= j2; j++) printf("%15.7g", A(j-1, i-1)); printf("\n");} }else { for (j=j1;j<=j2;j++) printf(" COL%5i ", j); printf("\n"); for (i = 1; i <= m; i++){ printf("ROW %4i", i); for (j=j1; j <= j2; j++) printf("%20.12g", A(j-1, i-1)); printf("\n");} } } /*++ END */ return; #undef A } /* end of function */