Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pmd-exclude.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,14 @@ com.thealgorithms.dynamicprogramming.WineProblem=UselessParentheses
com.thealgorithms.maths.BinomialCoefficient=UselessParentheses
com.thealgorithms.maths.Complex=UselessParentheses
com.thealgorithms.maths.DistanceFormulaTest=UnnecessaryFullyQualifiedName
com.thealgorithms.maths.FibonacciJavaStreamsTest=BigIntegerInstantiation
com.thealgorithms.maths.Gaussian=UselessParentheses
com.thealgorithms.maths.GcdSolutionWrapper=UselessParentheses
com.thealgorithms.maths.HeronsFormula=UselessParentheses
com.thealgorithms.maths.KaprekarNumbers=UselessParentheses
com.thealgorithms.maths.KeithNumber=UselessParentheses
com.thealgorithms.maths.LeonardoNumber=UselessParentheses
com.thealgorithms.maths.LinearDiophantineEquationsSolver=UselessParentheses
com.thealgorithms.maths.MatrixUtil=BigIntegerInstantiation,UselessParentheses
com.thealgorithms.maths.MatrixUtil=UselessParentheses
com.thealgorithms.maths.RomanNumeralUtil=UselessParentheses
com.thealgorithms.maths.SecondMinMax=UselessParentheses
com.thealgorithms.maths.SecondMinMaxTest=UnnecessaryFullyQualifiedName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static Optional<BigDecimal> calculate(final BigDecimal index) {
return Optional.of(BigDecimal.ZERO);
}

if (index.compareTo(new BigDecimal(2)) < 0) {
if (index.compareTo(BigDecimal.TWO) < 0) {
return Optional.of(BigDecimal.ONE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ public void testWithNegativeIndexShouldThrowException() {
public void testCheckTheFirst4SequenceElements() {
checkElement(BigDecimal.ZERO, BigDecimal.ZERO);
checkElement(BigDecimal.ONE, BigDecimal.ONE);
checkElement(new BigDecimal(2), BigDecimal.ONE);
checkElement(new BigDecimal(3), new BigDecimal(2));
checkElement(BigDecimal.TWO, BigDecimal.ONE);
checkElement(new BigDecimal(3), BigDecimal.TWO);
}

@Test
public void testCheck10thSequenceElement() {
checkElement(new BigDecimal(10), new BigDecimal(55));
checkElement(BigDecimal.TEN, new BigDecimal(55));
}

@Test
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/com/thealgorithms/maths/MatrixUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ class MatrixUtilTest {
@Test
void add() {
final BigDecimal[][] matrix1 = {
{new BigDecimal(3), new BigDecimal(2)},
{new BigDecimal(3), BigDecimal.TWO},
{BigDecimal.ZERO, BigDecimal.ONE},
};

final BigDecimal[][] matrix2 = {
{BigDecimal.ONE, new BigDecimal(3)},
{new BigDecimal(2), BigDecimal.ZERO},
{BigDecimal.TWO, BigDecimal.ZERO},
};

final BigDecimal[][] actual = MatrixUtil.add(matrix1, matrix2).orElseThrow(() -> new AssertionError("Could not compute matrix!"));

final BigDecimal[][] expected = {
{new BigDecimal(4), new BigDecimal(5)},
{new BigDecimal(2), BigDecimal.ONE},
{BigDecimal.TWO, BigDecimal.ONE},
};

assertTrue(Objects.deepEquals(actual, expected));
Expand All @@ -37,7 +37,7 @@ void subtract() {
};

final BigDecimal[][] matrix2 = {
{new BigDecimal(2), BigDecimal.ZERO},
{BigDecimal.TWO, BigDecimal.ZERO},
{new BigDecimal(-2), new BigDecimal(-3)},
};

Expand All @@ -55,13 +55,13 @@ void subtract() {
void multiply() {

final BigDecimal[][] matrix1 = {
{BigDecimal.ONE, new BigDecimal(2), new BigDecimal(3)},
{BigDecimal.ONE, BigDecimal.TWO, new BigDecimal(3)},
{new BigDecimal(4), new BigDecimal(5), new BigDecimal(6)},
{new BigDecimal(7), new BigDecimal(8), new BigDecimal(9)},
};

final BigDecimal[][] matrix2 = {
{BigDecimal.ONE, new BigDecimal(2)},
{BigDecimal.ONE, BigDecimal.TWO},
{new BigDecimal(3), new BigDecimal(4)},
{new BigDecimal(5), new BigDecimal(6)},
};
Expand Down