Skip to content

Commit

Permalink
misc: cleanup
Browse files Browse the repository at this point in the history
misc: cleanup
  • Loading branch information
4e6 committed Mar 18, 2021
1 parent e97d0f5 commit f326141
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 99 deletions.
22 changes: 0 additions & 22 deletions distribution/std-lib/Standard/src/Base/Data/Vector.enso
Original file line number Diff line number Diff line change
Expand Up @@ -398,28 +398,6 @@ type Vector
len = Math.min this.length that.length
here.new len i-> function (this.at i) (that.at i)

## Performs a pair-wise operation passed in `function` on consecutive
elements of `this` and `that`. The `function` is applied only when the
corresponding element exists in `that` vector.
The result of this function is a vector of `this` length.
> Example
To pairwise-sum two vectors:
[1, 2, 3].zip_1 [4, 5, 6] (+) == [5, 7, 9]
> Example
To pairwise-sum two vectors, when `this` is longer:
[1, 2, 3, 4].zip_1 [4, 5, 6] (+) == [5, 7, 9, 4]
> Example
To pairwise-sum two vectors, when `that` is longer:
[1, 2, 3].zip_1 [4, 5, 6, 7] (+) == [5, 7, 9]
> Example
To pairwise-sum two vectors, when `that` is empty:
[1, 2, 3].zip_1 [] (+) == [1, 2, 3]
zip_1 : Vector -> (Any -> Any -> Any) -> Vector
zip_1 that function=[_, _] =
that_len = that.length
here.new this.length i->
if that_len <= i then this.at i else function (this.at i) (that.at i)

## Extend `this` vector to the length of `n` appending elements `elem` to
the end. If the new length `n` is less than existing length, `this`
vector is returned.
Expand Down
71 changes: 0 additions & 71 deletions std-bits/src/main/java/org/enso/image/Algorithm.java

This file was deleted.

28 changes: 28 additions & 0 deletions std-bits/src/main/java/org/enso/image/data/Matrix.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ public static double[] get(Mat mat, int row, int column) {
return data;
}

/**
* Per-element addition of two matrices.
*
* @param mat1 the first matrix to add.
* @param mat2 the second matrix to add.
* @param dst the matrix holding the result of the operation.
*/
public static void add(Mat mat1, Mat mat2, Mat dst) {
Core.add(mat1, mat2, dst);
}
Expand All @@ -128,6 +135,13 @@ public static void add(Mat mat, Scalar scalar, Mat dst) {
Core.add(mat, scalar, dst);
}

/**
* Per-element subtraction of two matrices.
*
* @param mat1 the first matrix to subtract from.
* @param mat2 the second matrix to subtract.
* @param dst the matrix holding the result of the operation.
*/
public static void subtract(Mat mat1, Mat mat2, Mat dst) {
Core.subtract(mat1, mat2, dst);
}
Expand All @@ -142,6 +156,13 @@ public static void subtract(Mat mat, Scalar scalar, Mat dst) {
Core.subtract(mat, scalar, dst);
}

/**
* Per-element multiplication of two matrices.
*
* @param mat1 the first matrix to multiply.
* @param mat2 the second matrix to multiply.
* @param dst the matrix holding the result of the operation.
*/
public static void multiply(Mat mat1, Mat mat2, Mat dst) {
Core.multiply(mat1, mat2, dst);
}
Expand All @@ -156,6 +177,13 @@ public static void multiply(Mat mat, Scalar scalar, Mat dst) {
Core.multiply(mat, scalar, dst);
}

/**
* Per-element division of two matrices.
*
* @param mat1 the dividend matrix.
* @param mat2 the divisor matrix.
* @param dst the matrix holding the result of the operation.
*/
public static void divide(Mat mat1, Mat mat2, Mat dst) {
Core.divide(mat1, mat2, dst);
}
Expand Down
6 changes: 0 additions & 6 deletions test/Tests/src/Data/Vector_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,6 @@ spec = Test.group "Vectors" <|
[1, 2, 3].zip [4, 5, 6] (+) . should_equal [5, 7, 9]
[1, 2, 3].zip [4, 5, 6, 7] (+) . should_equal [5, 7, 9]
[].zip [4, 5, 6] (+) . should_equal []
Test.specify "should zip_1 elements" <|
[1, 2, 3].zip_1 [] (+) . should_equal [1, 2, 3]
[1, 2, 3].zip_1 [4] (+) . should_equal [5, 2, 3]
[1, 2, 3].zip_1 [4, 5, 6] (+) . should_equal [5, 7, 9]
[1, 2, 3].zip_1 [4, 5, 6, 7] (+) . should_equal [5, 7, 9]
[].zip_1 [4, 5, 6] (+) . should_equal []
Test.specify "should flat_map elements" <|
[1, 2, 3].flat_map (_ -> []) . should_equal []
[1, 2, 3].flat_map (_ -> [0, 1]) . should_equal [0, 1, 0, 1, 0, 1]
Expand Down

0 comments on commit f326141

Please sign in to comment.