[BAEL-2996] Added la4j library example
This commit is contained in:
parent
4b14001cb3
commit
082aa7d0a6
|
@ -60,6 +60,11 @@
|
||||||
<artifactId>colt</artifactId>
|
<artifactId>colt</artifactId>
|
||||||
<version>${colt.version}</version>
|
<version>${colt.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.la4j</groupId>
|
||||||
|
<artifactId>la4j</artifactId>
|
||||||
|
<version>${la4j.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter</artifactId>
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
@ -121,5 +126,6 @@
|
||||||
<spring-boot-starter.version>2.1.4.RELEASE</spring-boot-starter.version>
|
<spring-boot-starter.version>2.1.4.RELEASE</spring-boot-starter.version>
|
||||||
<ejml.version>0.37.1</ejml.version>
|
<ejml.version>0.37.1</ejml.version>
|
||||||
<colt.version>1.2.0</colt.version>
|
<colt.version>1.2.0</colt.version>
|
||||||
|
<la4j.version>0.6.0</la4j.version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
class DoubleMatrix2DUniTest {
|
class DoubleMatrix2DUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenTwoMatrices_whenMultiply_thenMultiplicatedMatrix() {
|
void givenTwoMatrices_whenMultiply_thenMultiplicatedMatrix() {
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.baeldung.la4j;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.la4j.Matrix;
|
||||||
|
import org.la4j.matrix.dense.Basic2DMatrix;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
class Basic2DMatrixUnitTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void givenTwoMatrices_whenMultiply_thenMultiplicatedMatrix() {
|
||||||
|
Matrix firstMatrix = new Basic2DMatrix(
|
||||||
|
new double[][]{
|
||||||
|
new double[]{1d, 5d},
|
||||||
|
new double[]{2d, 3d},
|
||||||
|
new double[]{1d, 7d}
|
||||||
|
});
|
||||||
|
|
||||||
|
Matrix secondMatrix = new Basic2DMatrix(
|
||||||
|
new double[][]{
|
||||||
|
new double[]{1d, 2d, 3d, 7d},
|
||||||
|
new double[]{5d, 2d, 8d, 1d}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
Matrix expected = new Basic2DMatrix(
|
||||||
|
new double[][]{
|
||||||
|
new double[]{26d, 12d, 43d, 12d},
|
||||||
|
new double[]{17d, 10d, 30d, 17d},
|
||||||
|
new double[]{36d, 16d, 59d, 14d}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
Matrix actual = firstMatrix.multiply(secondMatrix);
|
||||||
|
|
||||||
|
assertThat(actual).isEqualTo(expected);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue