Skip to content

Commit aa55f22

Browse files
committed
clustering and r/w
1 parent 2381c5a commit aa55f22

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1805
-740
lines changed

Diff for: CHANGELOG.md

+37
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,43 @@ Added / Changed / Deprecated / Fixed / Removed / Security
1111

1212
> Corresponds to changes in the `develop` branch since the last release
1313
14+
### Added
15+
16+
#### org.ojalgo.data
17+
18+
- New package `org.ojalgo.data.cluster` with k-means and greedy clustering algorithms implemented, as well as generalisations, specialisations and combinations of those.
19+
- `DataProcessors` now has a method `Transformation2D newRowsTransformer(Function<SampleSet, UnaryFunction>)` to complement the existing `newColumnsTransformer`.
20+
21+
#### org.ojalgo.random
22+
23+
- `SampleSet` gained a couple of methods; `getMidrange()` and `getRange()`.
24+
25+
### Changed
26+
27+
#### org.ojalgo.array
28+
29+
- Sorting is no longer parallel/multi-threaded. The previous implementations made use of the common `ForkJoinPool`.
30+
31+
#### org.ojalgo.netio
32+
33+
- The `FromFileReader` and `ToFileWriter` interfaces and their implementations used to extend and delegate to code in the `org.ojalgo.type.function` package. Much of what was in that package has been moved to and merged with stuff in the `org.ojalgo.netio` package.
34+
- The `FromFileReader.Builder` and `ToFileWriter.Builder` builders now use generic "file" types. They used to be implemented in terms of Java's `File`, but can now be anything like `Path` or ojAlgo's own `SegmentedFile`, `ShardedFile` or `InMemoryFile`.
35+
- The `DataInterpreter` gained some additional standard interpreters, as well as utilities to convert back and forth between `byte[]`.
36+
37+
#### org.ojalgo.random
38+
39+
- `SamleSet` no longer makes use of parallel/multi-threaded sorting – to avoid making use of the common `ForkJoinPool`.
40+
41+
#### org.ojalgo.type
42+
43+
- The `AutoSupplier` and `AutoConsumer` interfaces are removed. They used to provide abstract/generalised functionality for `FromFileReader` and `ToFileWriter` in the `org.ojalgo.netio` package. All features and functionality still exists, but in terms of the more specific/concrete `FromFileReader` and `ToFileWriter`. If you directly referenced any of the various utility methods in `AutoSupplier` or `AutoConsumer` they're now gone. They primarily existed so that `FromFileReader` and `ToFileWriter` could access them (from another package). The features and functionality they provided are now available through other classes in the `org.ojalgo.netio` package – like `FromFileReader.Builder` and `ToFileWriter.Builder`.
44+
45+
### Fixed
46+
47+
#### org.ojalgo.data
48+
49+
- In `DataProcessors`, the `CENTER_AND_SCALE` transformation didn't do exactly what the documentation said it. That's been fixed.
50+
1451
## [55.0.2] – 2024-11-30
1552

1653
### Added

Diff for: src/main/java/org/ojalgo/array/Array1D.java

+2-143
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
import java.math.BigDecimal;
2525
import java.util.AbstractList;
2626
import java.util.RandomAccess;
27-
import java.util.concurrent.ExecutionException;
28-
import java.util.concurrent.ForkJoinPool;
29-
import java.util.concurrent.RecursiveAction;
3027

3128
import org.ojalgo.ProgrammingError;
3229
import org.ojalgo.function.BinaryFunction;
@@ -124,132 +121,6 @@ public Array1D<N> wrap(final BasicArray<N> array) {
124121

125122
}
126123

127-
static final class QuickAscendingSorter extends RecursiveAction {
128-
129-
private static final long serialVersionUID = 1L;
130-
131-
private final long high;
132-
private final long low;
133-
private final Array1D<?> myArray;
134-
135-
private QuickAscendingSorter(final Array1D<?> array, final long low, final long high) {
136-
super();
137-
myArray = array;
138-
this.low = low;
139-
this.high = high;
140-
}
141-
142-
QuickAscendingSorter(final Array1D<?> array) {
143-
this(array, 0L, array.count() - 1L);
144-
}
145-
146-
@Override
147-
protected void compute() {
148-
149-
long i = low, j = high;
150-
151-
double pivot = myArray.doubleValue(low + (high - low) / 2);
152-
153-
while (i <= j) {
154-
155-
while (myArray.doubleValue(i) < pivot) {
156-
i++;
157-
}
158-
while (myArray.doubleValue(j) > pivot) {
159-
j--;
160-
}
161-
162-
if (i <= j) {
163-
myArray.exchange(i, j);
164-
i++;
165-
j--;
166-
}
167-
}
168-
169-
QuickAscendingSorter tmpPartL = null;
170-
QuickAscendingSorter tmpPartH = null;
171-
172-
if (low < j) {
173-
tmpPartL = new QuickAscendingSorter(myArray, low, j);
174-
tmpPartL.fork();
175-
}
176-
if (i < high) {
177-
tmpPartH = new QuickAscendingSorter(myArray, i, high);
178-
tmpPartH.fork();
179-
}
180-
if (tmpPartL != null) {
181-
tmpPartL.join();
182-
}
183-
if (tmpPartH != null) {
184-
tmpPartH.join();
185-
}
186-
}
187-
188-
}
189-
190-
static final class QuickDescendingSorter extends RecursiveAction {
191-
192-
private static final long serialVersionUID = 1L;
193-
194-
private final long high;
195-
private final long low;
196-
private final Array1D<?> myArray;
197-
198-
private QuickDescendingSorter(final Array1D<?> array, final long low, final long high) {
199-
super();
200-
myArray = array;
201-
this.low = low;
202-
this.high = high;
203-
}
204-
205-
QuickDescendingSorter(final Array1D<?> array) {
206-
this(array, 0L, array.count() - 1L);
207-
}
208-
209-
@Override
210-
protected void compute() {
211-
212-
long i = low, j = high;
213-
214-
double pivot = myArray.doubleValue(low + (high - low) / 2);
215-
216-
while (i <= j) {
217-
218-
while (myArray.doubleValue(i) > pivot) {
219-
i++;
220-
}
221-
while (myArray.doubleValue(j) < pivot) {
222-
j--;
223-
}
224-
225-
if (i <= j) {
226-
myArray.exchange(i, j);
227-
i++;
228-
j--;
229-
}
230-
}
231-
232-
QuickDescendingSorter tmpPartL = null;
233-
QuickDescendingSorter tmpPartH = null;
234-
235-
if (low < j) {
236-
tmpPartL = new QuickDescendingSorter(myArray, low, j);
237-
tmpPartL.fork();
238-
}
239-
if (i < high) {
240-
tmpPartH = new QuickDescendingSorter(myArray, i, high);
241-
tmpPartH.fork();
242-
}
243-
if (tmpPartL != null) {
244-
tmpPartL.join();
245-
}
246-
if (tmpPartH != null) {
247-
tmpPartH.join();
248-
}
249-
}
250-
251-
}
252-
253124
public static final Factory<ComplexNumber> C128 = Array1D.factory(ArrayC128.FACTORY);
254125
public static final Factory<Quaternion> H256 = Array1D.factory(ArrayH256.FACTORY);
255126
public static final Factory<RationalNumber> Q128 = Array1D.factory(ArrayQ128.FACTORY);
@@ -674,13 +545,7 @@ public void sortAscending() {
674545

675546
} else {
676547

677-
//this.sortAscending(0L, this.count() - 1L);
678-
679-
try {
680-
ForkJoinPool.commonPool().submit(new QuickAscendingSorter(this)).get();
681-
} catch (InterruptedException | ExecutionException exception) {
682-
exception.printStackTrace();
683-
}
548+
this.sortAscending(0L, this.count() - 1L);
684549
}
685550
}
686551

@@ -693,13 +558,7 @@ public void sortDescending() {
693558

694559
} else {
695560

696-
//this.sortDescending(0L, this.count() - 1L);
697-
698-
try {
699-
ForkJoinPool.commonPool().submit(new QuickDescendingSorter(this)).get();
700-
} catch (InterruptedException | ExecutionException exception) {
701-
exception.printStackTrace();
702-
}
561+
this.sortDescending(0L, this.count() - 1L);
703562
}
704563
}
705564

Diff for: src/main/java/org/ojalgo/array/ArrayR032.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,13 @@ public short shortValue(final int index) {
217217

218218
@Override
219219
public void sortAscending() {
220-
Arrays.parallelSort(data);
220+
Arrays.sort(data);
221221
}
222222

223223
@Override
224224
public void sortDescending() {
225225
CorePrimitiveOperation.negate(data, 0, data.length, 1, data);
226-
Arrays.parallelSort(data);
226+
Arrays.sort(data);
227227
CorePrimitiveOperation.negate(data, 0, data.length, 1, data);
228228
}
229229

Diff for: src/main/java/org/ojalgo/array/ArrayR064.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,13 @@ public short shortValue(final int index) {
221221

222222
@Override
223223
public void sortAscending() {
224-
Arrays.parallelSort(data);
224+
Arrays.sort(data);
225225
}
226226

227227
@Override
228228
public void sortDescending() {
229229
CorePrimitiveOperation.negate(data, 0, data.length, 1, data);
230-
Arrays.parallelSort(data);
230+
Arrays.sort(data);
231231
CorePrimitiveOperation.negate(data, 0, data.length, 1, data);
232232
}
233233

Diff for: src/main/java/org/ojalgo/array/ArrayR256.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ public short shortValue(final int index) {
131131

132132
@Override
133133
public void sortAscending() {
134-
Arrays.parallelSort(data);
134+
Arrays.sort(data);
135135
}
136136

137137
@Override
138138
public void sortDescending() {
139-
Arrays.parallelSort(data, Comparator.reverseOrder());
139+
Arrays.sort(data, Comparator.reverseOrder());
140140
}
141141

142142
@Override

Diff for: src/main/java/org/ojalgo/array/ArrayZ008.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,13 @@ public void set(final int index, final long value) {
154154

155155
@Override
156156
public void sortAscending() {
157-
Arrays.parallelSort(data);
157+
Arrays.sort(data);
158158
}
159159

160160
@Override
161161
public void sortDescending() {
162162
CorePrimitiveOperation.negate(data, 0, data.length, 1, data);
163-
Arrays.parallelSort(data);
163+
Arrays.sort(data);
164164
CorePrimitiveOperation.negate(data, 0, data.length, 1, data);
165165
}
166166

Diff for: src/main/java/org/ojalgo/array/ArrayZ016.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,13 @@ public short shortValue(final int index) {
159159

160160
@Override
161161
public void sortAscending() {
162-
Arrays.parallelSort(data);
162+
Arrays.sort(data);
163163
}
164164

165165
@Override
166166
public void sortDescending() {
167167
CorePrimitiveOperation.negate(data, 0, data.length, 1, data);
168-
Arrays.parallelSort(data);
168+
Arrays.sort(data);
169169
CorePrimitiveOperation.negate(data, 0, data.length, 1, data);
170170
}
171171

Diff for: src/main/java/org/ojalgo/array/ArrayZ032.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,13 @@ public short shortValue(final int index) {
164164

165165
@Override
166166
public void sortAscending() {
167-
Arrays.parallelSort(data);
167+
Arrays.sort(data);
168168
}
169169

170170
@Override
171171
public void sortDescending() {
172172
CorePrimitiveOperation.negate(data, 0, data.length, 1, data);
173-
Arrays.parallelSort(data);
173+
Arrays.sort(data);
174174
CorePrimitiveOperation.negate(data, 0, data.length, 1, data);
175175
}
176176

Diff for: src/main/java/org/ojalgo/array/ArrayZ064.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,13 @@ public short shortValue(final int index) {
164164

165165
@Override
166166
public void sortAscending() {
167-
Arrays.parallelSort(data);
167+
Arrays.sort(data);
168168
}
169169

170170
@Override
171171
public void sortDescending() {
172172
CorePrimitiveOperation.negate(data, 0, data.length, 1, data);
173-
Arrays.parallelSort(data);
173+
Arrays.sort(data);
174174
CorePrimitiveOperation.negate(data, 0, data.length, 1, data);
175175
}
176176

Diff for: src/main/java/org/ojalgo/array/NumberList.java

+9
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,15 @@ public boolean add(final double element) {
109109
return true;
110110
}
111111

112+
public boolean add(final float element) {
113+
114+
this.ensureCapacity();
115+
116+
myStorage.set(myActualCount++, element);
117+
118+
return true;
119+
}
120+
112121
@Override
113122
public void add(final int index, final N element) {
114123

Diff for: src/main/java/org/ojalgo/array/ScalarArray.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ public short shortValue(final int index) {
8787

8888
@Override
8989
public final void sortAscending() {
90-
Arrays.parallelSort(data);
90+
Arrays.sort(data);
9191
}
9292

9393
@Override
9494
public final void sortDescending() {
95-
Arrays.parallelSort(data, Comparator.reverseOrder());
95+
Arrays.sort(data, Comparator.reverseOrder());
9696
}
9797

9898
@Override

0 commit comments

Comments
 (0)