aboutsummaryrefslogtreecommitdiffstats
path: root/vespajlib
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-11-23 00:12:23 +0100
committerJon Bratseth <bratseth@yahoo-inc.com>2016-11-23 00:12:23 +0100
commit79c58529b9e505352cc97942b3d9cf932d622ada (patch)
tree954e664bd0db2c86e83ca134ad7e8e5dbd3115c8 /vespajlib
parent78808c58387ae8cf8b6bd542103a9554fc0e0dc7 (diff)
Remove old functions
Diffstat (limited to 'vespajlib')
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/Tensor.java42
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/TensorDifference.java30
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/TensorMax.java35
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/TensorMin.java33
-rw-r--r--vespajlib/src/main/java/com/yahoo/tensor/TensorSum.java29
5 files changed, 2 insertions, 167 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/Tensor.java b/vespajlib/src/main/java/com/yahoo/tensor/Tensor.java
index b65830a4e4a..380ba9177b2 100644
--- a/vespajlib/src/main/java/com/yahoo/tensor/Tensor.java
+++ b/vespajlib/src/main/java/com/yahoo/tensor/Tensor.java
@@ -96,6 +96,8 @@ public interface Tensor {
default Tensor add(Tensor argument) { return join(argument, (a, b) -> (a + b )); }
default Tensor divide(Tensor argument) { return join(argument, (a, b) -> (a / b )); }
default Tensor subtract(Tensor argument) { return join(argument, (a, b) -> (a - b )); }
+ default Tensor max(Tensor argument) { return join(argument, (a, b) -> (a > b ? a : b )); }
+ default Tensor min(Tensor argument) { return join(argument, (a, b) -> (a < b ? a : b )); }
default Tensor avg(List<String> dimensions) { return reduce(ReduceFunction.Aggregator.avg, dimensions); }
default Tensor count(List<String> dimensions) { return reduce(ReduceFunction.Aggregator.count, dimensions); }
@@ -107,28 +109,6 @@ public interface Tensor {
// ----------------- Old stuff
/**
- * Returns a tensor which contains the cells of both argument tensors, where the value for
- * any <i>matching</i> cell is the min of the two possible values.
- * <p>
- * Two cells are matching if they have the same labels for all dimensions shared between the two argument tensors,
- * and have the value undefined for any non-shared dimension.
- */
- default Tensor min(Tensor argument) {
- return new TensorMin(this, argument).result();
- }
-
- /**
- * Returns a tensor which contains the cells of both argument tensors, where the value for
- * any <i>matching</i> cell is the max of the two possible values.
- * <p>
- * Two cells are matching if they have the same labels for all dimensions shared between the two argument tensors,
- * and have the value undefined for any non-shared dimension.
- */
- default Tensor max(Tensor argument) {
- return new TensorMax(this, argument).result();
- }
-
- /**
* Returns a tensor with the same cells as this and the given function is applied to all its cell values.
*
* @param function the function to apply to all cells
@@ -139,24 +119,6 @@ public interface Tensor {
}
/**
- * Returns a tensor with the given dimension removed and cells which contains the sum of the values
- * in the removed dimension.
- */
- default Tensor sum(String dimension) {
- return new TensorDimensionSum(dimension, this).result();
- }
-
- /**
- * Returns the sum of all the cells of this tensor.
- */
- default double sum() {
- double sum = 0;
- for (Map.Entry<TensorAddress, Double> cell : cells().entrySet())
- sum += cell.getValue();
- return sum;
- }
-
- /**
* Returns true if the given tensor is mathematically equal to this:
* Both are of type Tensor and have the same content.
*/
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/TensorDifference.java b/vespajlib/src/main/java/com/yahoo/tensor/TensorDifference.java
deleted file mode 100644
index ceb003b1615..00000000000
--- a/vespajlib/src/main/java/com/yahoo/tensor/TensorDifference.java
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.tensor;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Takes the difference between two tensors, see {@link Tensor#subtract}
- *
- * @author bratseth
- */
-class TensorDifference {
-
- private final Set<String> dimensions;
- private final Map<TensorAddress, Double> cells = new HashMap<>();
-
- public TensorDifference(Tensor a, Tensor b) {
- this.dimensions = TensorOperations.combineDimensions(a, b);
- cells.putAll(a.cells());
- for (Map.Entry<TensorAddress, Double> bCell : b.cells().entrySet())
- cells.put(bCell.getKey(), a.cells().getOrDefault(bCell.getKey(), 0d) - bCell.getValue());
- }
-
- /** Returns the result of taking this sum */
- public Tensor result() {
- return new MapTensor(dimensions, cells);
- }
-
-}
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/TensorMax.java b/vespajlib/src/main/java/com/yahoo/tensor/TensorMax.java
deleted file mode 100644
index d15e5092476..00000000000
--- a/vespajlib/src/main/java/com/yahoo/tensor/TensorMax.java
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.tensor;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Takes the max of each cell of two tensors, see {@link Tensor#max}
- *
- * @author bratseth
- */
-class TensorMax {
-
- private final Set<String> dimensions;
- private final Map<TensorAddress, Double> cells = new HashMap<>();
-
- public TensorMax(Tensor a, Tensor b) {
- dimensions = TensorOperations.combineDimensions(a, b);
- cells.putAll(a.cells());
- for (Map.Entry<TensorAddress, Double> bCell : b.cells().entrySet()) {
- Double aValue = a.cells().get(bCell.getKey());
- if (aValue == null)
- cells.put(bCell.getKey(), bCell.getValue());
- else
- cells.put(bCell.getKey(), Math.max(aValue, bCell.getValue()));
- }
- }
-
- /** Returns the result of taking this sum */
- public Tensor result() {
- return new MapTensor(dimensions, cells);
- }
-
-}
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/TensorMin.java b/vespajlib/src/main/java/com/yahoo/tensor/TensorMin.java
deleted file mode 100644
index e389dea3883..00000000000
--- a/vespajlib/src/main/java/com/yahoo/tensor/TensorMin.java
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.tensor;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Takes the min of each cell of two tensors, see {@link Tensor#min}
- *
- * @author bratseth
- */
-class TensorMin {
-
- private final Set<String> dimensions;
- private final Map<TensorAddress, Double> cells = new HashMap<>();
-
- public TensorMin(Tensor a, Tensor b) {
- dimensions = TensorOperations.combineDimensions(a, b);
- cells.putAll(a.cells());
- for (Map.Entry<TensorAddress, Double> bCell : b.cells().entrySet()) {
- Double aValue = a.cells().get(bCell.getKey());
- if (aValue == null)
- cells.put(bCell.getKey(), bCell.getValue());
- else
- cells.put(bCell.getKey(), Math.min(aValue, bCell.getValue()));
- }
- }
-
- /** Returns the result of taking this sum */
- public Tensor result() { return new MapTensor(dimensions, cells); }
-
-}
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/TensorSum.java b/vespajlib/src/main/java/com/yahoo/tensor/TensorSum.java
deleted file mode 100644
index 85dfa289bd3..00000000000
--- a/vespajlib/src/main/java/com/yahoo/tensor/TensorSum.java
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.tensor;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Takes the sum of two tensors, see {@link Tensor#add}
- *
- * @author bratseth
- */
-class TensorSum {
-
- private final Set<String> dimensions;
- private final Map<TensorAddress, Double> cells = new HashMap<>();
-
- public TensorSum(Tensor a, Tensor b) {
- dimensions = TensorOperations.combineDimensions(a, b);
- cells.putAll(a.cells());
- for (Map.Entry<TensorAddress, Double> bCell : b.cells().entrySet()) {
- cells.put(bCell.getKey(), a.cells().getOrDefault(bCell.getKey(), 0d) + bCell.getValue());
- }
- }
-
- /** Returns the result of taking this sum */
- public Tensor result() { return new MapTensor(dimensions, cells); }
-
-}