genasin.c revision 60d7101085a33323664fc145e21a8a07057015e0
1/*
2 * Copyright (C) Bull S.A. 2001
3 * Copyright (c) International Business Machines  Corp., 2001
4 *
5 *   This program is free software;  you can redistribute it and/or modify
6 *   it under the terms of the GNU General Public License as published by
7 *   the Free Software Foundation; either version 2 of the License, or
8 *   (at your option) any later version.
9 *
10 *   This program is distributed in the hope that it will be useful,
11 *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
13 *   the GNU General Public License for more details.
14 *
15 *   You should have received a copy of the GNU General Public License
16 *   along with this program;  if not, write to the Free Software
17 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20/******************************************************************************/
21/*                                                                            */
22/* Dec-03-2001  Created: Jacky Malcles & Jean Noel Cordenner                  */
23/*              These tests are adapted from AIX float PVT tests.             */
24/*                                                                            */
25/******************************************************************************/
26#include 	<float.h>
27#include 	<stdio.h>
28#include 	<stdlib.h>
29#include 	<string.h>
30#include 	<errno.h>
31#include        <limits.h>
32#include        <unistd.h>
33#include        <fcntl.h>
34#include        <errno.h>
35#include        <sys/signal.h>
36#include        <math.h>
37
38#define M_PIl	3.1415926535897932384626433832795029L
39
40
41
42
43int create_Result_file()
44{
45
46	int i, nbVal;
47	double	tabRasin[20000], Inc;
48	char *F_name;
49	int fp;
50
51	F_name = "rasin";
52	nbVal = 20000;
53
54	Inc = 2/nbVal;
55
56	for (i=0; i<nbVal; i++)
57		tabRasin[i] = asin( (Inc * i) -1);
58
59
60	fp = open(F_name,O_RDWR|O_CREAT|O_TRUNC,0777);
61        if (!fp)
62        {
63            	printf("error opening file");
64		close(fp);
65		return -1;
66	}
67	else
68	{
69		for (i = 0; i<nbVal; i++ )
70		{
71			write(fp,&tabRasin[i],sizeof(double));
72		}
73
74		close(fp);
75		return 0;
76	}
77}
78
79
80int create_Data_file()
81{
82	int i, nbVal;
83	double	tabDasin[20000], Inc;
84	char *F_name;
85	int fp;
86
87	F_name = "dasin";
88	nbVal = 20000;
89
90	Inc = 2/nbVal;
91
92	for (i=0; i<nbVal; i++)
93		tabDasin[i] = (Inc * i) -1;
94
95
96	fp = open(F_name,O_RDWR|O_CREAT|O_TRUNC,0777);
97        if (!fp)
98        {
99            	printf("error opening file");
100	    	close(fp);
101	    	return -1;
102        }
103        else
104        {
105		for (i = 0; i<nbVal; i++ )
106		{
107			write(fp,&tabDasin[i],sizeof(double));
108		}
109		close(fp);
110		return 0;
111	}
112}
113
114
115int main(int argc, char  *argv[])
116{
117
118	if (argc > 1)
119	{
120		switch ( atoi(argv[1]) )
121		{
122		case 1:
123			if (create_Data_file() == 0)
124				printf("Data file created\n");
125			else
126				printf("problem during asin data file creation\n");
127			break;
128
129		case 2:
130			if (create_Result_file() == 0)
131				printf("Result file created\n");
132			else
133				printf("problem during asin result file creation\n");
134			break;
135		default:
136			printf("Bad arglist code for: '%s'\n", argv[0]);
137			return -1;
138			break;
139		}
140	}
141	else
142	{
143		if (create_Data_file() != 0)
144			printf("problem during asindata file creation\n");
145		if (create_Result_file() != 0)
146			printf("problem during asin result file creation\n");
147	}
148}
149