|
| 1 | +/* |
| 2 | + * #%L |
| 3 | + * SciJava Operations: a framework for reusable algorithms. |
| 4 | + * %% |
| 5 | + * Copyright (C) 2016 - 2019 SciJava Ops developers. |
| 6 | + * %% |
| 7 | + * Redistribution and use in source and binary forms, with or without |
| 8 | + * modification, are permitted provided that the following conditions are met: |
| 9 | + * |
| 10 | + * 1. Redistributions of source code must retain the above copyright notice, |
| 11 | + * this list of conditions and the following disclaimer. |
| 12 | + * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 13 | + * this list of conditions and the following disclaimer in the documentation |
| 14 | + * and/or other materials provided with the distribution. |
| 15 | + * |
| 16 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 17 | + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 18 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 19 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE |
| 20 | + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 21 | + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 22 | + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 23 | + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 24 | + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 25 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 26 | + * POSSIBILITY OF SUCH DAMAGE. |
| 27 | + * #L% |
| 28 | + */ |
| 29 | + |
| 30 | +/* |
| 31 | +* This is autogenerated source code -- DO NOT EDIT. Instead, edit the |
| 32 | +* corresponding template in templates/ and rerun bin/generate.groovy. |
| 33 | +*/ |
| 34 | + |
| 35 | +package org.scijava.ops.adapt.lift; |
| 36 | + |
| 37 | +import java.util.function.Function; |
| 38 | + |
| 39 | +import org.scijava.ops.OpField; |
| 40 | +import org.scijava.ops.core.OpCollection; |
| 41 | +import org.scijava.ops.function.Computers; |
| 42 | +import org.scijava.plugin.Plugin; |
| 43 | + |
| 44 | +/** |
| 45 | + * Collection of ops designed to lift {@link Computers} to operate |
| 46 | + * on arrays. TODO: multi-threading support |
| 47 | + * |
| 48 | + * @author Gabriel Selzer |
| 49 | + */ |
| 50 | +@Plugin(type = OpCollection.class) |
| 51 | +public class ComputerToArrays<I, I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11, I12, I13, I14, I15, I16, O> { |
| 52 | + |
| 53 | + private int minLength(Object[]... arrays) { |
| 54 | + int minLength = Integer.MAX_VALUE; |
| 55 | + for (Object[] array : arrays) |
| 56 | + if (array.length < minLength) minLength = array.length; |
| 57 | + return minLength; |
| 58 | + } |
| 59 | + |
| 60 | + @OpField(names = "adapt", params = "fromOp, toOp") |
| 61 | + public final Function<Computers.Arity0<O>, Computers.Arity0<O[]>> liftComputer0 = |
| 62 | + (computer) -> { |
| 63 | + return (out) -> { |
| 64 | + int max = minLength(out); |
| 65 | + for (int i = 0; i < max; i++) { |
| 66 | + computer.compute(out[i]); |
| 67 | + } |
| 68 | + }; |
| 69 | + }; |
| 70 | + |
| 71 | + @OpField(names = "adapt", params = "fromOp, toOp") |
| 72 | + public final Function<Computers.Arity1<I, O>, Computers.Arity1<I[], O[]>> liftComputer1 = |
| 73 | + (computer) -> { |
| 74 | + return (in, out) -> { |
| 75 | + int max = minLength(in, out); |
| 76 | + for (int i = 0; i < max; i++) { |
| 77 | + computer.compute(in[i], out[i]); |
| 78 | + } |
| 79 | + }; |
| 80 | + }; |
| 81 | + |
| 82 | + @OpField(names = "adapt", params = "fromOp, toOp") |
| 83 | + public final Function<Computers.Arity2<I1, I2, O>, Computers.Arity2<I1[], I2[], O[]>> liftComputer2 = |
| 84 | + (computer) -> { |
| 85 | + return (in1, in2, out) -> { |
| 86 | + int max = minLength(in1, in2, out); |
| 87 | + for (int i = 0; i < max; i++) { |
| 88 | + computer.compute(in1[i], in2[i], out[i]); |
| 89 | + } |
| 90 | + }; |
| 91 | + }; |
| 92 | + |
| 93 | + @OpField(names = "adapt", params = "fromOp, toOp") |
| 94 | + public final Function<Computers.Arity3<I1, I2, I3, O>, Computers.Arity3<I1[], I2[], I3[], O[]>> liftComputer3 = |
| 95 | + (computer) -> { |
| 96 | + return (in1, in2, in3, out) -> { |
| 97 | + int max = minLength(in1, in2, in3, out); |
| 98 | + for (int i = 0; i < max; i++) { |
| 99 | + computer.compute(in1[i], in2[i], in3[i], out[i]); |
| 100 | + } |
| 101 | + }; |
| 102 | + }; |
| 103 | + |
| 104 | + @OpField(names = "adapt", params = "fromOp, toOp") |
| 105 | + public final Function<Computers.Arity4<I1, I2, I3, I4, O>, Computers.Arity4<I1[], I2[], I3[], I4[], O[]>> liftComputer4 = |
| 106 | + (computer) -> { |
| 107 | + return (in1, in2, in3, in4, out) -> { |
| 108 | + int max = minLength(in1, in2, in3, in4, out); |
| 109 | + for (int i = 0; i < max; i++) { |
| 110 | + computer.compute(in1[i], in2[i], in3[i], in4[i], out[i]); |
| 111 | + } |
| 112 | + }; |
| 113 | + }; |
| 114 | + |
| 115 | + @OpField(names = "adapt", params = "fromOp, toOp") |
| 116 | + public final Function<Computers.Arity5<I1, I2, I3, I4, I5, O>, Computers.Arity5<I1[], I2[], I3[], I4[], I5[], O[]>> liftComputer5 = |
| 117 | + (computer) -> { |
| 118 | + return (in1, in2, in3, in4, in5, out) -> { |
| 119 | + int max = minLength(in1, in2, in3, in4, in5, out); |
| 120 | + for (int i = 0; i < max; i++) { |
| 121 | + computer.compute(in1[i], in2[i], in3[i], in4[i], in5[i], out[i]); |
| 122 | + } |
| 123 | + }; |
| 124 | + }; |
| 125 | + |
| 126 | + @OpField(names = "adapt", params = "fromOp, toOp") |
| 127 | + public final Function<Computers.Arity6<I1, I2, I3, I4, I5, I6, O>, Computers.Arity6<I1[], I2[], I3[], I4[], I5[], I6[], O[]>> liftComputer6 = |
| 128 | + (computer) -> { |
| 129 | + return (in1, in2, in3, in4, in5, in6, out) -> { |
| 130 | + int max = minLength(in1, in2, in3, in4, in5, in6, out); |
| 131 | + for (int i = 0; i < max; i++) { |
| 132 | + computer.compute(in1[i], in2[i], in3[i], in4[i], in5[i], in6[i], out[i]); |
| 133 | + } |
| 134 | + }; |
| 135 | + }; |
| 136 | + |
| 137 | + @OpField(names = "adapt", params = "fromOp, toOp") |
| 138 | + public final Function<Computers.Arity7<I1, I2, I3, I4, I5, I6, I7, O>, Computers.Arity7<I1[], I2[], I3[], I4[], I5[], I6[], I7[], O[]>> liftComputer7 = |
| 139 | + (computer) -> { |
| 140 | + return (in1, in2, in3, in4, in5, in6, in7, out) -> { |
| 141 | + int max = minLength(in1, in2, in3, in4, in5, in6, in7, out); |
| 142 | + for (int i = 0; i < max; i++) { |
| 143 | + computer.compute(in1[i], in2[i], in3[i], in4[i], in5[i], in6[i], in7[i], out[i]); |
| 144 | + } |
| 145 | + }; |
| 146 | + }; |
| 147 | + |
| 148 | + @OpField(names = "adapt", params = "fromOp, toOp") |
| 149 | + public final Function<Computers.Arity8<I1, I2, I3, I4, I5, I6, I7, I8, O>, Computers.Arity8<I1[], I2[], I3[], I4[], I5[], I6[], I7[], I8[], O[]>> liftComputer8 = |
| 150 | + (computer) -> { |
| 151 | + return (in1, in2, in3, in4, in5, in6, in7, in8, out) -> { |
| 152 | + int max = minLength(in1, in2, in3, in4, in5, in6, in7, in8, out); |
| 153 | + for (int i = 0; i < max; i++) { |
| 154 | + computer.compute(in1[i], in2[i], in3[i], in4[i], in5[i], in6[i], in7[i], in8[i], out[i]); |
| 155 | + } |
| 156 | + }; |
| 157 | + }; |
| 158 | + |
| 159 | + @OpField(names = "adapt", params = "fromOp, toOp") |
| 160 | + public final Function<Computers.Arity9<I1, I2, I3, I4, I5, I6, I7, I8, I9, O>, Computers.Arity9<I1[], I2[], I3[], I4[], I5[], I6[], I7[], I8[], I9[], O[]>> liftComputer9 = |
| 161 | + (computer) -> { |
| 162 | + return (in1, in2, in3, in4, in5, in6, in7, in8, in9, out) -> { |
| 163 | + int max = minLength(in1, in2, in3, in4, in5, in6, in7, in8, in9, out); |
| 164 | + for (int i = 0; i < max; i++) { |
| 165 | + computer.compute(in1[i], in2[i], in3[i], in4[i], in5[i], in6[i], in7[i], in8[i], in9[i], out[i]); |
| 166 | + } |
| 167 | + }; |
| 168 | + }; |
| 169 | + |
| 170 | + @OpField(names = "adapt", params = "fromOp, toOp") |
| 171 | + public final Function<Computers.Arity10<I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, O>, Computers.Arity10<I1[], I2[], I3[], I4[], I5[], I6[], I7[], I8[], I9[], I10[], O[]>> liftComputer10 = |
| 172 | + (computer) -> { |
| 173 | + return (in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, out) -> { |
| 174 | + int max = minLength(in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, out); |
| 175 | + for (int i = 0; i < max; i++) { |
| 176 | + computer.compute(in1[i], in2[i], in3[i], in4[i], in5[i], in6[i], in7[i], in8[i], in9[i], in10[i], out[i]); |
| 177 | + } |
| 178 | + }; |
| 179 | + }; |
| 180 | + |
| 181 | + @OpField(names = "adapt", params = "fromOp, toOp") |
| 182 | + public final Function<Computers.Arity11<I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11, O>, Computers.Arity11<I1[], I2[], I3[], I4[], I5[], I6[], I7[], I8[], I9[], I10[], I11[], O[]>> liftComputer11 = |
| 183 | + (computer) -> { |
| 184 | + return (in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, out) -> { |
| 185 | + int max = minLength(in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, out); |
| 186 | + for (int i = 0; i < max; i++) { |
| 187 | + computer.compute(in1[i], in2[i], in3[i], in4[i], in5[i], in6[i], in7[i], in8[i], in9[i], in10[i], in11[i], out[i]); |
| 188 | + } |
| 189 | + }; |
| 190 | + }; |
| 191 | + |
| 192 | + @OpField(names = "adapt", params = "fromOp, toOp") |
| 193 | + public final Function<Computers.Arity12<I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11, I12, O>, Computers.Arity12<I1[], I2[], I3[], I4[], I5[], I6[], I7[], I8[], I9[], I10[], I11[], I12[], O[]>> liftComputer12 = |
| 194 | + (computer) -> { |
| 195 | + return (in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, in12, out) -> { |
| 196 | + int max = minLength(in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, in12, out); |
| 197 | + for (int i = 0; i < max; i++) { |
| 198 | + computer.compute(in1[i], in2[i], in3[i], in4[i], in5[i], in6[i], in7[i], in8[i], in9[i], in10[i], in11[i], in12[i], out[i]); |
| 199 | + } |
| 200 | + }; |
| 201 | + }; |
| 202 | + |
| 203 | + @OpField(names = "adapt", params = "fromOp, toOp") |
| 204 | + public final Function<Computers.Arity13<I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11, I12, I13, O>, Computers.Arity13<I1[], I2[], I3[], I4[], I5[], I6[], I7[], I8[], I9[], I10[], I11[], I12[], I13[], O[]>> liftComputer13 = |
| 205 | + (computer) -> { |
| 206 | + return (in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, in12, in13, out) -> { |
| 207 | + int max = minLength(in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, in12, in13, out); |
| 208 | + for (int i = 0; i < max; i++) { |
| 209 | + computer.compute(in1[i], in2[i], in3[i], in4[i], in5[i], in6[i], in7[i], in8[i], in9[i], in10[i], in11[i], in12[i], in13[i], out[i]); |
| 210 | + } |
| 211 | + }; |
| 212 | + }; |
| 213 | + |
| 214 | + @OpField(names = "adapt", params = "fromOp, toOp") |
| 215 | + public final Function<Computers.Arity14<I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11, I12, I13, I14, O>, Computers.Arity14<I1[], I2[], I3[], I4[], I5[], I6[], I7[], I8[], I9[], I10[], I11[], I12[], I13[], I14[], O[]>> liftComputer14 = |
| 216 | + (computer) -> { |
| 217 | + return (in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, in12, in13, in14, out) -> { |
| 218 | + int max = minLength(in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, in12, in13, in14, out); |
| 219 | + for (int i = 0; i < max; i++) { |
| 220 | + computer.compute(in1[i], in2[i], in3[i], in4[i], in5[i], in6[i], in7[i], in8[i], in9[i], in10[i], in11[i], in12[i], in13[i], in14[i], out[i]); |
| 221 | + } |
| 222 | + }; |
| 223 | + }; |
| 224 | + |
| 225 | + @OpField(names = "adapt", params = "fromOp, toOp") |
| 226 | + public final Function<Computers.Arity15<I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11, I12, I13, I14, I15, O>, Computers.Arity15<I1[], I2[], I3[], I4[], I5[], I6[], I7[], I8[], I9[], I10[], I11[], I12[], I13[], I14[], I15[], O[]>> liftComputer15 = |
| 227 | + (computer) -> { |
| 228 | + return (in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, in12, in13, in14, in15, out) -> { |
| 229 | + int max = minLength(in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, in12, in13, in14, in15, out); |
| 230 | + for (int i = 0; i < max; i++) { |
| 231 | + computer.compute(in1[i], in2[i], in3[i], in4[i], in5[i], in6[i], in7[i], in8[i], in9[i], in10[i], in11[i], in12[i], in13[i], in14[i], in15[i], out[i]); |
| 232 | + } |
| 233 | + }; |
| 234 | + }; |
| 235 | + |
| 236 | + @OpField(names = "adapt", params = "fromOp, toOp") |
| 237 | + public final Function<Computers.Arity16<I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11, I12, I13, I14, I15, I16, O>, Computers.Arity16<I1[], I2[], I3[], I4[], I5[], I6[], I7[], I8[], I9[], I10[], I11[], I12[], I13[], I14[], I15[], I16[], O[]>> liftComputer16 = |
| 238 | + (computer) -> { |
| 239 | + return (in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, in12, in13, in14, in15, in16, out) -> { |
| 240 | + int max = minLength(in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, in12, in13, in14, in15, in16, out); |
| 241 | + for (int i = 0; i < max; i++) { |
| 242 | + computer.compute(in1[i], in2[i], in3[i], in4[i], in5[i], in6[i], in7[i], in8[i], in9[i], in10[i], in11[i], in12[i], in13[i], in14[i], in15[i], in16[i], out[i]); |
| 243 | + } |
| 244 | + }; |
| 245 | + }; |
| 246 | + |
| 247 | +} |
0 commit comments