From 1414a5b32ef6182e5dacdf5a3a0bbf304db9c9a0 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 15 May 2009 06:04:44 +0000 Subject: [PATCH] change --- .../Benchmarks/SingleTM/KMeans/Cluster.java | 18 +++++++------- .../Benchmarks/SingleTM/KMeans/Common.java | 3 +-- .../SingleTM/KMeans/GlobalArgs.java | 8 +++---- .../Benchmarks/SingleTM/KMeans/KMeans.java | 24 +++++++++---------- .../Benchmarks/SingleTM/KMeans/Normal.java | 22 ++++++++--------- 5 files changed, 37 insertions(+), 38 deletions(-) diff --git a/Robust/src/Benchmarks/SingleTM/KMeans/Cluster.java b/Robust/src/Benchmarks/SingleTM/KMeans/Cluster.java index 4b694240..037dc779 100644 --- a/Robust/src/Benchmarks/SingleTM/KMeans/Cluster.java +++ b/Robust/src/Benchmarks/SingleTM/KMeans/Cluster.java @@ -83,10 +83,10 @@ public class Cluster { * extractMoments * ============================================================================= */ - public double[] - extractMoments (double []data, int num_elts, int num_moments) + public float[] + extractMoments (float []data, int num_elts, int num_moments) { - double[] moments = new double[num_moments]; + float[] moments = new float[num_moments]; for (int i = 0; i < num_elts; i++) { moments[0] += data[i]; @@ -109,18 +109,18 @@ public class Cluster { * ============================================================================= */ public void - zscoreTransform (double[][] data, /* in & out: [numObjects][numAttributes] */ + zscoreTransform (float[][] data, /* in & out: [numObjects][numAttributes] */ int numObjects, int numAttributes) { - double[] moments; - double[] single_variable = new double[numObjects]; + float[] moments; + float[] single_variable = new float[numObjects]; for (int i = 0; i < numAttributes; i++) { for (int j = 0; j < numObjects; j++) { single_variable[j] = data[j][i]; } moments = extractMoments(single_variable, numObjects, 2); - moments[1] = Math.sqrt((double)moments[1]); + moments[1] = (float) Math.sqrt((double)moments[1]); for (int j = 0; j < numObjects; j++) { data[j][i] = (data[j][i]-moments[0])/moments[1]; } @@ -137,7 +137,7 @@ public class Cluster { int nthreads, /* in: number of threads*/ int numObjects, /* number of input objects */ int numAttributes, /* size of attribute of each object */ - double[][] attributes, /* [numObjects][numAttributes] */ + float[][] attributes, /* [numObjects][numAttributes] */ KMeans kms, /* KMeans class hold the inputs and outputs */ GlobalArgs args /* Global thread arguments */ ) @@ -145,7 +145,7 @@ public class Cluster { int itime; int nclusters; - double[][] tmp_cluster_centres = null; + float[][] tmp_cluster_centres = null; int[] membership = new int[numObjects]; Random randomPtr = new Random(); diff --git a/Robust/src/Benchmarks/SingleTM/KMeans/Common.java b/Robust/src/Benchmarks/SingleTM/KMeans/Common.java index b72294a9..83fc44b2 100644 --- a/Robust/src/Benchmarks/SingleTM/KMeans/Common.java +++ b/Robust/src/Benchmarks/SingleTM/KMeans/Common.java @@ -106,8 +106,7 @@ public class Common { /* Find the cluster center id with min distance to pt */ for (i = 0; i < npts; i++) { - double dist; - dist = common_euclidDist2(pt, pts[i], nfeatures); /* no need square root */ + float dist = common_euclidDist2(pt, pts[i], nfeatures); /* no need square root */ if ((dist / max_dist) < limit) { max_dist = dist; index = i; diff --git a/Robust/src/Benchmarks/SingleTM/KMeans/GlobalArgs.java b/Robust/src/Benchmarks/SingleTM/KMeans/GlobalArgs.java index 6285ae75..432c6f04 100644 --- a/Robust/src/Benchmarks/SingleTM/KMeans/GlobalArgs.java +++ b/Robust/src/Benchmarks/SingleTM/KMeans/GlobalArgs.java @@ -28,7 +28,7 @@ public class GlobalArgs { /** * List of attributes **/ - public double[][] feature; + public float[][] feature; /** * Number of attributes per Object @@ -55,7 +55,7 @@ public class GlobalArgs { /** * **/ - public double[][] clusters; + public float[][] clusters; /** @@ -66,13 +66,13 @@ public class GlobalArgs { /** * New centers of the clusters [nclusters][nfeatures] **/ - public double[][] new_centers; + public float[][] new_centers; /** * **/ public long global_i; - public double global_delta; + public float global_delta; } diff --git a/Robust/src/Benchmarks/SingleTM/KMeans/KMeans.java b/Robust/src/Benchmarks/SingleTM/KMeans/KMeans.java index 30a179ee..44fdffaf 100644 --- a/Robust/src/Benchmarks/SingleTM/KMeans/KMeans.java +++ b/Robust/src/Benchmarks/SingleTM/KMeans/KMeans.java @@ -114,7 +114,7 @@ public class KMeans extends Thread { /** * threshold until which kmeans cluster continues **/ - double threshold; + float threshold; /** * thread id @@ -134,7 +134,7 @@ public class KMeans extends Thread { /** * Output: Cluster centers **/ - double[][] cluster_centres; + float[][] cluster_centres; public KMeans() { max_nclusters = 13; @@ -181,8 +181,8 @@ public class KMeans extends Thread { System.exit(0); } - double[][] buf; - double[][] attributes; + float[][] buf; + float[][] attributes; int numAttributes = 0; int numObjects = 0; @@ -225,8 +225,8 @@ public class KMeans extends Thread { System.out.println("numObjects= " + numObjects + " numAttributes= " + numAttributes); /* Allocate new shared objects and read attributes of all objects */ - buf = new double[numObjects][numAttributes]; - attributes = new double[numObjects][numAttributes]; + buf = new float[numObjects][numAttributes]; + attributes = new float[numObjects][numAttributes]; KMeans.readFromFile(inputFile, kms.filename, buf, MAX_LINE_LENGTH); System.out.println("Finished Reading from file ......"); @@ -352,7 +352,7 @@ public class KMeans extends Thread { * readFromFile() * Read attributes from the input file into an array **/ - public static void readFromFile(FileInputStream inputFile, String filename, double[][] buf, int MAX_LINE_LENGTH) { + public static void readFromFile(FileInputStream inputFile, String filename, float[][] buf, int MAX_LINE_LENGTH) { inputFile = new FileInputStream(filename); int j; int i = 0; @@ -415,11 +415,11 @@ public class KMeans extends Thread { } /** - * Convert a string into double + * Convert a string into float **/ - public static double ByteToFloat (byte[] str, int offset, int length) { - double left=0.0d; - double right=0.0d; + public static float ByteToFloat (byte[] str, int offset, int length) { + float left=0.0d; + float right=0.0d; int i; for(i=0;i