Skip to content

Commit 2f05e07

Browse files
committed
Expected Size of Function can now be specified for MatrixFunctionBuilder
1 parent d93ce01 commit 2f05e07

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/main/java/org/optimizationBenchmarking/utils/math/matrix/impl/MatrixFunctionBuilder.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,34 @@ public final class MatrixFunctionBuilder {
4747
* Create the function builder, i.e., an object that can help you
4848
* represent a mathematical function as 2D matrix.
4949
*
50+
* @param expectedSize
51+
* the expected size of the resulting matrix
5052
* @param onlyOnePointPerYCoordinate
5153
* print only one point per {@code y} coordinate and omit all
5254
* following points with the same {@code y} value (except the
5355
* very last point added to the function)
5456
*/
55-
public MatrixFunctionBuilder(final boolean onlyOnePointPerYCoordinate) {
57+
public MatrixFunctionBuilder(final int expectedSize,
58+
final boolean onlyOnePointPerYCoordinate) {
5659
super();
57-
this.m_builder = new MatrixBuilder();
60+
this.m_builder = new MatrixBuilder(expectedSize * 2);
5861
this.m_builder.setN(2);
5962
this.m_onlyOnePointPerYCoordinate = onlyOnePointPerYCoordinate;
6063
}
6164

65+
/**
66+
* Create the function builder, i.e., an object that can help you
67+
* represent a mathematical function as 2D matrix.
68+
*
69+
* @param onlyOnePointPerYCoordinate
70+
* print only one point per {@code y} coordinate and omit all
71+
* following points with the same {@code y} value (except the
72+
* very last point added to the function)
73+
*/
74+
public MatrixFunctionBuilder(final boolean onlyOnePointPerYCoordinate) {
75+
this(-1, onlyOnePointPerYCoordinate);
76+
}
77+
6278
/**
6379
* Add two long integer coordinates
6480
*

0 commit comments

Comments
 (0)