Skip to content

Commit 51c181b

Browse files
committed
Fixed nextRandom()
1 parent 4174b00 commit 51c181b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

mihxil-algebra/src/main/java/org/meeuw/math/abstractalgebra/linear/AbstractGeneralLinearGroup.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,13 @@ public M newElement(@Square E[][] matrix) throws InvalidElementCreationException
106106
public M nextRandom(Random random) {
107107
while(true) {
108108
try {
109-
List<E> list = new ArrayList<>();
109+
E[][] values = elementStructure.newMatrix(dimension, dimension);
110110
for (int i = 0; i < dimension; i++) {
111-
list.add(elementStructure.nextRandom(random));
111+
for (int j = 0; j < dimension; j++) {
112+
values[i][j] = elementStructure.nextRandom(random);
113+
}
112114
}
113-
return newElement((E[]) list.toArray());
115+
return newElement(values);
114116
} catch (InvalidElementCreationException ie) {
115117
//ignored
116118
}

0 commit comments

Comments
 (0)