Skip to content

Commit fd80a8a

Browse files
committed
add withWeight method to Matches
1 parent 630d6ef commit fd80a8a

File tree

1 file changed

+14
-0
lines changed
  • render-app/src/main/java/org/janelia/alignment/match

1 file changed

+14
-0
lines changed

render-app/src/main/java/org/janelia/alignment/match/Matches.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import java.io.Serializable;
2222
import java.util.ArrayList;
23+
import java.util.Arrays;
2324
import java.util.List;
2425

2526
import javax.xml.bind.annotation.XmlAccessType;
@@ -152,6 +153,19 @@ public List<RealPoint> getQList() {
152153
return buildPointList(getQs());
153154
}
154155

156+
@JsonIgnore
157+
public Matches withWeight(final double w) {
158+
final double [][] newPs = new double[this.p.length][];
159+
final double [][] newQs = new double[this.q.length][];
160+
for (int d = 0; d < this.p.length; ++d) {
161+
newPs[d] = Arrays.copyOf(this.p[d], this.p[d].length);
162+
newQs[d] = Arrays.copyOf(this.q[d], this.q[d].length);
163+
}
164+
final double[] newWeights = new double[this.w.length];
165+
Arrays.fill(newWeights, w);
166+
return new Matches(newPs, newQs, newWeights);
167+
}
168+
155169
private static List<RealPoint> buildPointList(final double[][] locations) {
156170
final double[] xLocations = locations[0];
157171
final double[] yLocations = locations[1];

0 commit comments

Comments
 (0)