1 /* 2 * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * 27 * @summary converted from VM Testbase jit/FloatingPoint/gen_math/Loops01. 28 * VM Testbase keywords: [jit, quick] 29 * 30 * @library /vmTestbase 31 * /test/lib 32 * @run driver jdk.test.lib.FileInstaller . . 33 * @build jit.FloatingPoint.gen_math.Loops01.Loops01 34 * @run driver ExecDriver --java jit.FloatingPoint.gen_math.Loops01.Loops01 35 */ 36 37 package jit.FloatingPoint.gen_math.Loops01; 38 39 import nsk.share.TestFailure; 40 41 class Loops01 42 { 43 44 static final int N = 500; 45 46 public static void main (String args[]) 47 { 48 49 double Error = 0.01; 50 51 double xx[][]; 52 xx = new double[N][N]; 53 54 double rn = N; 55 double dx = 1/rn; 56 double dy = 1/rn; 57 58 double r1, r2, r3, r4, r5; 59 60 Loops01 ll; 61 ll = new Loops01(); 62 63 for(int i = 0; i < N; i++) 64 { for(int j = 0; j < N; j++) 65 { 66 r1 = i * dx; 67 r2 = j * dy; 68 r3 = Math.sqrt(r1 * r1 + r2 * r2); 69 r4 = Math.sin(4 * r1) + Math.cos(4 * r2); 70 r5 = r3 * (2 + r4); 71 xx[i][j] = r5; 72 } 73 } 74 75 double norma = ll.Norma(N,xx); 76 double er = Math.abs(2.5 - norma); 77 ll.Echeck(er,Error); 78 79 } 80 81 public double Norma(int nn, double ww[][]) 82 { 83 double nor = 0; 84 double r1 = nn; 85 double r2 = r1 * r1; 86 double r3; 87 88 for(int i = 0; i < nn; i++) 89 { 90 for(int j = 0; j < nn; j++) 91 { r3 = ww[i][j] * ww[i][j]; 92 nor = nor + r3; 93 } 94 } 95 nor = nor/r2; 96 return nor; 97 } 98 99 100 101 public void Echeck(double er, double ER) 102 { 103 104 if( er < ER) 105 System.out.println("test PASS"); 106 else 107 { 108 System.out.println("expected error: " + ER); 109 System.out.println(" found error: " + er); 110 throw new TestFailure("test FAIL"); 111 } 112 113 } 114 115 116 117 118 119 120 }