1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
/*
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) INRIA -
*
* This file must be used under the terms of the CeCILL.
* This source file is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at
* http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
*
*/
#include <math.h>
#include <string.h>
#include <stdio.h>
#include "core_math.h"
#include "genmdsp.h"
#define DSP(Type,Fmt) {\
Type *X;\
Type a;\
double aa;\
X=(Type *)x;\
--iw;\
--X;\
m = Abs(*mm); n = Abs(*nn);\
dl = ' '; if (m * n > 1) dl = ' ';\
lbloc = n; nbloc = 1;\
iw[lbloc + nbloc] = n;\
lp = -(*nx);s = 0;\
for (k = 1; k <= n; ++k) {\
iw[k] = 0;\
lp += *nx;\
for (l = 1; l <= m; ++l) {\
aa = Abs((double)X[lp + l]);\
if (aa == 0) {\
fl = 0;\
} else {\
fl = (int)(log(aa)/log(10.)) ;\
}\
iw[k] = Max(iw[k],fl + 2);\
}\
s += iw[k];\
if (s > *ll - 2) {\
iw[lbloc + nbloc] = k - 1;\
++nbloc;\
iw[lbloc + nbloc] = n;\
s = iw[k];\
}\
}\
if (*mm < 0) {\
cw[0] = '\0';\
strcpy(&(cw[0]), "(eye *)");\
C2F(basout)(&io, lunit, cw, 7L);\
C2F(basout)(&io, lunit, " ", 1L);\
if (io == -1) return 0;\
}\
k1 = 1;\
for (ib = 1; ib <= nbloc; ++ib) {\
k2 = iw[lbloc + ib];\
if (nbloc != 1) {\
C2F(blktit)(lunit, &k1, &k2, &io);\
if (io == -1) return 0;\
}\
for (l = 1; l <= m; ++l) {\
cw[0] = dl;l1 = 1;\
for (k = k1; k <= k2; ++k) {\
a = X[l + (k - 1) * *nx];\
sprintf((char *)&(cw[l1]),Fmt,iw[k],a);\
l1 += iw[k]+1;\
}\
cw[l1] = dl;\
C2F(basout)(&io, lunit, cw, l1+1);\
if (io == -1) return 0;\
}\
k1 = k2 + 1;\
}\
}
int C2F(genmdsp)(int *typ, int *x, int *nx, int *mm, int *nn, int *ll, int *lunit, char cw[], int *iw, int cw_len)
{
static int k, l, m, n, s, lbloc, nbloc, k1, l1, k2, ib;
static char dl;
static int fl, io, lp;
extern int C2F(blktit)(), C2F(basout)();
switch (*typ)
{
case 1:
DSP(integer1, "%*i ");
break;
case 2:
DSP(integer2, "%*i ");
break;
case 4:
DSP(integer, "%*i ");
break;
case 11:
DSP(unsigned char, "%*u ");
break;
case 12:
DSP(unsigned short, "%*u ");
break;
case 14:
DSP(unsigned int, "%*u ");
break;
}
return 0;
}
|