FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
gnuplot-old/src/bf_test.c at gnuplot-4-4-alpha · gnuplot/gnuplot-old · GitHub
gnuplot
gnuplot-old
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
gnuplot-old
/
src
/
bf_test.c
Copy path
More file actions
More file actions
Latest commit
History
History
History
168 lines (138 loc) · 3.94 KB
Breadcrumbs
gnuplot-old
/
src
/
bf_test.c
Copy path
File metadata and controls
168 lines (138 loc) · 3.94 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#ifndef
lint
static
char
*
RCSid
() {
return
RCSid
(
"$Id: bf_test.c,v 1.10 2007/10/02 18:18:57 sfeam Exp $"
); }
#endif
/*
* Test routines for binary files
* cc bf_test.c -o bf_test binary_files.o -lm
*
* Copyright (c) 1992 Robert K. Cunningham, MIT Lincoln Laboratory
*
*/
/* Note that this file is not compiled into gnuplot, and so
* its more-restrictive copyright need not apply to gnuplot
* as a whole. (I think.)
*/
#ifdef
HAVE_CONFIG_H
#include
"config.h"
#endif
#define
GPFAR
/**/
#include
"syscfg.h"
#include
"stdfn.h"
#include
"binary.h"
/* we declare these here instead of including more header files */
void
int_error
__PROTO
((
int
,
const
char
*
));
void
FreeHelp
__PROTO
((
void
));
/* static functions */
static
float
function
__PROTO
((
int
p
,
double
x
,
double
y
));
typedef
struct
{
float
xmin
,
xmax
;
float
ymin
,
ymax
;
}
range
;
#define
NUM_PLOTS
2
static
range
TheRange
[]
=
{{
-3
,
3
,
-2
,
2
},
{
-3
,
3
,
-3
,
3
},
{
-3
,
3
,
-3
,
3
}};
/* Sampling rate causes this to go from -3:6*/
/*---- Stubs to make this work without including huge libraries ----*/
void
int_error
(
int
dummy
,
const
char
*
error_text
)
{
(
void
)
dummy
;
/* avoid -Wunused warning */
fprintf
(
stderr
,
"Fatal error..\n%s\n...now exiting to system ...\n"
,
error_text
);
exit
(
EXIT_FAILURE
);
}
void
FreeHelp
()
{
}
/*---- End of stubs ----*/
static
float
function
(
int
p
,
double
x
,
double
y
)
{
float
t
=
0
;
/* HBB 990828: initialize */
switch
(
p
) {
case
0
:
t
=
1.0
/ (
x
*
x
+
y
*
y
+
1.0
);
break
;
case
1
:
t
=
sin
(
x
*
x
+
y
*
y
) / (
x
*
x
+
y
*
y
);
if
(
t
>
1.0
)
t
=
1.0
;
break
;
case
2
:
t
=
sin
(
x
*
x
+
y
*
y
) / (
x
*
x
+
y
*
y
);
/* sinc modulated sinc */
t
*=
sin
(
4.
*
(
x
*
x
+
y
*
y
)) / (
4.
*
(
x
*
x
+
y
*
y
));
if
(
t
>
1.0
)
t
=
1.0
;
break
;
default
:
fprintf
(
stderr
,
"Unknown function\n"
);
break
;
}
return
t
;
}
#define
ISOSAMPLES
5.0
int
main
(
void
)
{
int
plot
;
int
i
,
j
;
float
x
,
y
;
float
*
rt
,
*
ct
;
float
*
*
m
;
int
xsize
,
ysize
;
char
buf
[
256
];
FILE
*
fout
;
/* Create a few standard test interfaces */
for
(
plot
=
0
;
plot
<
NUM_PLOTS
;
plot
++
) {
xsize
=
(
TheRange
[
plot
].
xmax
-
TheRange
[
plot
].
xmin
)
*
ISOSAMPLES
+
1
;
ysize
=
(
TheRange
[
plot
].
ymax
-
TheRange
[
plot
].
ymin
)
*
ISOSAMPLES
+
1
;
rt
=
alloc_vector
(
0
,
xsize
-
1
);
ct
=
alloc_vector
(
0
,
ysize
-
1
);
m
=
matrix
(
0
,
xsize
-
1
,
0
,
ysize
-
1
);
for
(
y
=
TheRange
[
plot
].
ymin
,
j
=
0
;
j
<
ysize
;
j
++
,
y
+=
1.0
/ (
double
)
ISOSAMPLES
) {
ct
[
j
]
=
y
;
}
for
(
x
=
TheRange
[
plot
].
xmin
,
i
=
0
;
i
<
xsize
;
i
++
,
x
+=
1.0
/ (
double
)
ISOSAMPLES
) {
rt
[
i
]
=
x
;
for
(
y
=
TheRange
[
plot
].
ymin
,
j
=
0
;
j
<
ysize
;
j
++
,
y
+=
1.0
/ (
double
)
ISOSAMPLES
) {
m
[
i
][
j
]
=
function
(
plot
,
x
,
y
);
}
}
sprintf
(
buf
,
"binary%d"
,
plot
+
1
);
if
(!(
fout
=
fopen
(
buf
,
"wb"
)))
int_error
(
0
,
"Could not open file"
);
else
{
fwrite_matrix
(
fout
,
m
,
0
,
xsize
-
1
,
0
,
ysize
-
1
,
rt
,
ct
);
}
free_vector
(
rt
,
0
);
free_vector
(
ct
,
0
);
free_matrix
(
m
,
0
,
xsize
-
1
,
0
);
}
/* Show that it's ok to vary sampling rate, as long as x1<x2, y1<y2... */
xsize
=
(
TheRange
[
plot
].
xmax
-
TheRange
[
plot
].
xmin
)
*
ISOSAMPLES
+
1
;
ysize
=
(
TheRange
[
plot
].
ymax
-
TheRange
[
plot
].
ymin
)
*
ISOSAMPLES
+
1
;
rt
=
alloc_vector
(
0
,
xsize
-
1
);
ct
=
alloc_vector
(
0
,
ysize
-
1
);
m
=
matrix
(
0
,
xsize
-
1
,
0
,
ysize
-
1
);
for
(
y
=
TheRange
[
plot
].
ymin
,
j
=
0
;
j
<
ysize
;
j
++
,
y
+=
1.0
/ (
double
)
ISOSAMPLES
) {
ct
[
j
]
=
y
>
0
?
2
*
y
:
y
;
}
for
(
x
=
TheRange
[
plot
].
xmin
,
i
=
0
;
i
<
xsize
;
i
++
,
x
+=
1.0
/ (
double
)
ISOSAMPLES
) {
rt
[
i
]
=
x
>
0
?
2
*
x
:
x
;
for
(
y
=
TheRange
[
plot
].
ymin
,
j
=
0
;
j
<
ysize
;
j
++
,
y
+=
1.0
/ (
double
)
ISOSAMPLES
) {
m
[
i
][
j
]
=
function
(
plot
,
x
,
y
);
}
}
sprintf
(
buf
,
"binary%d"
,
plot
+
1
);
if
(!(
fout
=
fopen
(
buf
,
"wb"
)))
int_error
(
0
,
"Could not open file"
);
else
{
fwrite_matrix
(
fout
,
m
,
0
,
xsize
-
1
,
0
,
ysize
-
1
,
rt
,
ct
);
}
free_vector
(
rt
,
0
);
free_vector
(
ct
,
0
);
free_matrix
(
m
,
0
,
xsize
-
1
,
0
);
return
EXIT_SUCCESS
;
}
Back
|
FazBrowse Home
|
New Git URL