This repository has been archived by the owner on Aug 27, 2022. It is now read-only.
/
Loops06.java
144 lines (116 loc) · 3.87 KB
/
Loops06.java
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
/*
* Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
*
* @summary converted from VM Testbase jit/FloatingPoint/gen_math/Loops06.
* VM Testbase keywords: [jit, quick]
*
* @library /vmTestbase
* /test/lib
* @run main/othervm jit.FloatingPoint.gen_math.Loops06.Loops06
*/
package jit.FloatingPoint.gen_math.Loops06;
import nsk.share.TestFailure;
public class Loops06
{
static final int N = 20;
static final double pi = 3.14;
public static void main (String args[])
{
double Error = 0.01;
double xx[];
double yy[];
double zz[];
xx = new double[N];
yy = new double[N];
zz = new double[N];
double r1, r2, r3, r4, r5;
double rN = N;
Loops06 ll;
ll = new Loops06();
for(int i = 0; i < N; i++)
{ r1 = i;
xx[i] = Math.sin( 2 * pi * r1 / rN);
}
int i=0;
while( i < N)
{ r2 = i;
yy[i] = xx[i] * Math.sin(r2);
zz[i] = xx[i] * Math.cos(r2);
i++;
}
for( i = 1; i < N - 1; i++)
{
for(int j = 1; j < N - 1; j++)
{ zz[0] = 0;
for(int k = 1; k < N - 1; k++)
{
for(int n = 1; n < N - 1; n++)
{ yy[0] = 0;
for(int m = 1; m < N - 1; m++)
{
for(int l = 1; l < N - 1; l++)
{
xx[i] = xx[i - 1] + xx[i+1];
}
}
}
}
}
}
double norma_x = ll.norma(N,xx);
double norma_y = ll.norma(N,yy);
double norma_z = ll.norma(N,zz);
r5 = norma_x * norma_x + norma_y * norma_y + norma_z * norma_z;
double total_norma = Math.sqrt(r5);
double errrr = Math.abs(total_norma - 0.83);
ll.Echeck(errrr,Error);
}
public double norma(int nn, double ww[])
{
double nor = 0;
double r1 = nn;
double r2 = r1 * r1;
double r3;
for(int i = 0; i < nn; i++)
{
r3 = ww[i] * ww[i];
nor = nor + r3;
}
nor = nor/r2;
nor = Math.sqrt(nor);
return nor;
}
public void Echeck(double er, double ER)
{
if( er < ER)
System.out.println("test PASS");
else
{
System.out.println("expected error: " + ER);
System.out.println(" found error: " + er);
throw new TestFailure("test FAIL");
}
}
}