We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7220d28 commit 67df9d5Copy full SHA for 67df9d5
3 files changed
pom.xml
@@ -6,7 +6,7 @@
6
</properties>
7
<groupId>io.shapelets</groupId>
8
<artifactId>khiva</artifactId>
9
- <version>0.2.0</version>
+ <version>0.2.2</version>
10
11
<name>khiva-java</name>
12
<url>https://github.com/shapelets/khiva-java</url>
src/main/java/io/shapelets/khiva/Array.java
@@ -256,6 +256,8 @@ public Array(Array other) {
256
257
private native long[] nativeGetDims();
258
259
+ private native int nativeGetType();
260
+
261
private native long nativePrint();
262
263
private native DoubleComplex[] getDoubleComplexFromArray();
@@ -276,7 +278,7 @@ public Array(Array other) {
276
278
277
279
private native long[] getLongFromArray();
280
- private native int nativeGetType();
281
+ private native long[] join(int dim, long refRhs);
282
283
private native long[] add(long refRhs);
284
@@ -434,6 +436,19 @@ public long[] getDims() {
434
436
return nativeGetDims();
435
437
}
438
439
+ /**
440
+ * Joins this array with the one specified as parameter along the specified dimension.
441
+ *
442
+ * @param dim The dimension along which the join occurs.
443
+ * @param rhs Right-hand side array for the operation.
444
+ * @return The result of joining the given arrays along the specified dimension.
445
+ */
446
+ public Array join(int dim, Array rhs) {
447
+ long[] refs = join(dim, rhs.reference);
448
+ rhs.reference = refs[0];
449
+ return new Array(refs[1]);
450
+ }
451
452
/**
453
* Adds this array with the one passed as parameter.
454
*
src/test/java/io/shapelets/khiva/ArrayTest.java
@@ -485,12 +485,23 @@ public void testGetType() throws Exception {
485
486
487
488
+ @Test
489
+ public void testJoin() throws Exception {
490
+ float[] data1 = {1f, 2f, 3f, 4f};
491
+ float[] data2 = {5f, 6f, 7f, 8f};
492
+ long[] dims = {4, 1, 1, 1};
493
+ try (Array a = new Array(data1, dims); Array b = new Array(data2, dims); Array c = a.join(1, b)) {
494
+ float[] result = c.getData();
495
+ float[] expected = {1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f};
496
+ Assert.assertArrayEquals(result, expected, 1e-6f);
497
498
499
500
@Test
501
public void testAdd() throws Exception {
502
float[] data = {1f, 2f, 3f, 4f};
503
long[] dims = {4, 1, 1, 1};
504
try (Array a = new Array(data, dims); Array b = new Array(data, dims); Array c = a.add(b)) {
-
505
float[] result = c.getData();
506
float[] expected = {2f, 4f, 6f, 8f};
507
Assert.assertArrayEquals(result, expected, 1e-6f);
0 commit comments