SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
BatchSortPow2.java
1/*
2 * Class: BatchSortPow2
3 * Description: performs a batch sort on an array, batch numbers must be powers of 2.
4 * Environment: Java
5 * Software: SSJ
6 * Copyright (C) 2015 Pierre L'Ecuyer and Universite de Montreal
7 * Organization: DIRO, Universite de Montreal
8 * @author
9 * @since
10
11 * SSJ is free software: you can redistribute it and/or modify it under
12 * the terms of the GNU General Public License (GPL) as published by the
13 * Free Software Foundation, either version 3 of the License, or
14 * any later version.
15
16 * SSJ is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20
21 * A copy of the GNU General Public License is available at
22 <a href="http://www.gnu.org/licenses">GPL licence site</a>.
23 */
24package umontreal.ssj.util.multidimsort;
25
44public class BatchSortPow2<T extends MultiDimComparable<? super T>> extends BatchSort<T> {
45 int[] ej; // The current exponents e_j.
46
53 public BatchSortPow2(double[] batchExponents) {
54 super(batchExponents);
55 ej = new int[this.dimension];
56 }
57
66 public void setBatchNumbers(int n) {
67 if (batchExponents == null)
68 throw new NullPointerException("batchExponents is null");
69 // Round up to the nearest power of 2. Will be 2^e.
70 int e = 1;
71 while (n > (1 << e))
72 e++;
73 nSaved = n;
74 batchProduct = 1 << e; // Product of batch numbers = p = 2^e.
75 for (int j = 0; j < dimension; ++j) {
76 ej[j] = (int) Math.ceil(e * batchExponents[j]); // log_2 of num of batches.
77 e -= ej[j]; // The power of 2 that remains for each batch.
78 batchNumbers[j] = 1 << ej[j];
79 }
80 }
81
85 public int[] getBitNumbers() {
86 return ej;
87 }
88
89}
void setBatchNumbers(int n)
For a number of objects and a predefined vector of proportion exponents , computes and sets the corr...
int[] getBitNumbers()
Returns the current vector of integers .
BatchSortPow2(double[] batchExponents)
Constructs a BatchSortPow2 that will use proportion exponents in batchExponents, which must contain n...
This interface is an extension (or variant) of the Comparable interface in Java.