25
25
import java .util .Map ;
26
26
import java .util .Map .Entry ;
27
27
import java .util .Set ;
28
+ import java .util .function .BiFunction ;
28
29
import java .util .function .Function ;
29
30
import java .util .function .Supplier ;
30
31
import java .util .stream .Stream ;
@@ -194,6 +195,14 @@ public static <V, TB extends Tensorbacked<V>> TB empty(Class<TB> tensorbackedCla
194
195
return Tensorbackeds .empty (tensorbackedClass );
195
196
}
196
197
198
+ public static <V > Tensor <V > empty (Iterable <Class <?>> dimensions ) {
199
+ return ImmutableTensor .<V > builder (dimensions ).build ();
200
+ }
201
+
202
+ public static <V > Tensor <V > empty (Class <?> ... dimensions ) {
203
+ return ImmutableTensor .<V > builder (dimensions ).build ();
204
+ }
205
+
197
206
/**
198
207
* @see Tensorbackeds#validitiesOf(Tensorbacked)
199
208
*/
@@ -237,6 +246,13 @@ public static <S> Tensor<QuantifiedValue<S>> quantityTensorOf(Tensor<S> tensor,
237
246
return QuantityTensors .quantityTensorOf (tensor , unit );
238
247
}
239
248
249
+ /**
250
+ * @see QuantityTensors#quantityTensorOf(Tensor, javax.measure.unit.Unit)
251
+ */
252
+ public static <S > Tensor <QuantifiedValue <S >> quantityTensorOf (Tensor <S > tensor , javax .measure .unit .Unit <?> unit ) {
253
+ return QuantityTensors .quantityTensorOf (tensor , JScienceUnit .of (unit ));
254
+ }
255
+
240
256
/**
241
257
* @see QuantityTensors#unitOf(Tensor)
242
258
*/
@@ -309,18 +325,38 @@ public static <S> Tensor<S> sameValues(Shape shape, S value) {
309
325
return TensorInternals .sameValues (shape , value );
310
326
}
311
327
328
+ /**
329
+ * @deprecated use {@link #tensor(Shape, Supplier)}
330
+ */
331
+ @ Deprecated
312
332
public static <S > Tensor <S > createFrom (Shape shape , Supplier <S > supplier ) {
333
+ return tensor (shape , supplier );
334
+ }
335
+
336
+ public static <S > Tensor <S > tensor (Shape shape , Supplier <S > supplier ) {
313
337
return TensorInternals .createFrom (shape , supplier );
314
338
}
315
339
340
+ /**
341
+ * @deprecated use {@link #tensor(Shape, Function)}
342
+ */
343
+ @ Deprecated
316
344
public static <S > Tensor <S > createFrom (Shape shape , Function <Position , S > function ) {
345
+ return tensor (shape , function );
346
+ }
347
+
348
+ public static <S > Tensor <S > tensor (Shape shape , Function <Position , S > function ) {
317
349
return TensorInternals .createFrom (shape , function );
318
350
}
319
351
320
352
public static <S > OngoingCompletion <S > complete (Tensor <S > tensor ) {
321
353
return TensorStructurals .complete (tensor );
322
354
}
323
355
356
+ /**
357
+ * @deprecated use {@link #map(Tensor, BiFunction)} instead
358
+ */
359
+ @ Deprecated
324
360
public static <S , T > Tensor <T > transformEntries (Tensor <S > tensor , Function <Entry <Position , S >, T > function ) {
325
361
return TensorStructurals .transformEntries (tensor , function );
326
362
}
@@ -329,6 +365,10 @@ public static <S, T> Tensor<T> map(Tensor<S> tensor, Function<S, T> function) {
329
365
return TensorStructurals .transformScalars (tensor , function );
330
366
}
331
367
368
+ public static <S , T > Tensor <T > map (Tensor <S > tensor , BiFunction <Position , S , T > function ) {
369
+ return TensorStructurals .transformScalars (tensor , function );
370
+ }
371
+
332
372
public static final Scalar <QuantifiedValue <Double >> zeroDimensionalOf (double value ,
333
373
javax .measure .unit .Unit <?> unit ) {
334
374
QuantifiedValue <Double > quantity = quantityOf (value , unit );
0 commit comments