Package org.tensorics.core.lang
Class Tensorics
- java.lang.Object
-
- org.tensorics.core.lang.Tensorics
-
public final class Tensorics extends java.lang.Object
The main entry point for constructing and structural manipulation of tensorics. If mathematical operations are required, then you should either inherit fromTensoricSupport
(or one of its convenience implementations) or use theusing(ExtendedField)
method (only recommended for one-liners).Additional utilities for supporting classes can be found in the corresponding utility classes. E.g.
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static Position
at(java.lang.Iterable<?> coordinates)
static Position
at(java.lang.Object... coordinates)
static <T> TensorBuilder<T>
builder(java.lang.Class<?>... dimensions)
static <T> TensorBuilder<T>
builder(java.lang.Iterable<java.lang.Class<?>> dimensions)
static <C1,T>
Tensorbacked1dBuilder<C1,T,Tensorbacked1d<C1,T>>builderBacked(java.lang.Class<C1> dimension1)
static <C1,C2,T>
Tensorbacked2dBuilder<C1,C2,T,Tensorbacked2d<C1,C2,T>>builderBacked(java.lang.Class<C1> d1, java.lang.Class<C2> d2)
static <C1,C2,C3,T>
Tensorbacked3dBuilder<C1,C2,C3,T,Tensorbacked3d<C1,C2,C3,T>>builderBacked(java.lang.Class<C1> d1, java.lang.Class<C2> d2, java.lang.Class<C3> d3)
static <C1,C2,C3,C4,T>
Tensorbacked4dBuilder<C1,C2,C3,C4,T,Tensorbacked4d<C1,C2,C3,C4,T>>builderBacked(java.lang.Class<C1> d1, java.lang.Class<C2> d2, java.lang.Class<C3> d3, java.lang.Class<C4> d4)
static <C1,C2,C3,C4,C5,T>
Tensorbacked5dBuilder<C1,C2,C3,C4,C5,T,Tensorbacked5d<C1,C2,C3,C4,C5,T>>builderBacked(java.lang.Class<C1> d1, java.lang.Class<C2> d2, java.lang.Class<C3> d3, java.lang.Class<C4> d4, java.lang.Class<C5> d5)
static <V,TB extends Tensorbacked<V>>
SimpleTensorbackedBuilder<V,TB>builderFor(java.lang.Class<TB> tensorbackedClass)
static <C1,V,TB extends Tensorbacked1d<C1,V>>
Tensorbacked1dBuilder<C1,V,TB>builderFor1D(java.lang.Class<TB> tensorbackedClass)
static <C1,C2,V,TB extends Tensorbacked2d<C1,C2,V>>
Tensorbacked2dBuilder<C1,C2,V,TB>builderFor2D(java.lang.Class<TB> tensorbackedClass)
static <C1,C2,C3,V,TB extends Tensorbacked3d<C1,C2,C3,V>>
Tensorbacked3dBuilder<C1,C2,C3,V,TB>builderFor3D(java.lang.Class<TB> tensorbackedClass)
static <C1,C2,C3,C4,V,TB extends Tensorbacked4d<C1,C2,C3,C4,V>>
Tensorbacked4dBuilder<C1,C2,C3,C4,V,TB>builderFor4D(java.lang.Class<TB> tensorbackedClass)
static <C1,C2,C3,C4,C5,V,TB extends Tensorbacked5d<C1,C2,C3,C4,C5,V>>
Tensorbacked5dBuilder<C1,C2,C3,C4,C5,V,TB>builderFor5D(java.lang.Class<TB> tensorbackedClass)
static <T> TensorBuilder<T>
builderFrom(Tensor<T> tensor)
static <S> OngoingCompletion<S>
complete(Tensor<S> tensor)
static <S,TB extends Tensorbacked<S>>
OngoingTensorbackedCompletion<TB,S>complete(TB tensorbacked)
static <V,TB extends Tensorbacked<V>>
OngoingTensorbackedConstruction<V,TB>construct(java.lang.Class<TB> tensorbackedClass)
static <S> Tensor<QuantifiedValue<S>>
convertToQuantified(Tensor<S> tensor, Unit unit)
Deprecated.use renamed methodquantityTensorOf(Tensor, Unit)
static <T> Tensor<T>
copyOf(Tensor<T> tensor)
static <S> Tensor<S>
createFrom(Shape shape, java.util.function.Function<Position,S> function)
Deprecated.static <S> Tensor<S>
createFrom(Shape shape, java.util.function.Supplier<S> supplier)
Deprecated.static <TB extends Tensorbacked<?>>
intdimensionalityOf(TB tensorbacked)
static java.util.Set<java.lang.Class<?>>
dimensionsOf(Tensor<?> tensor)
static java.util.Set<java.lang.Class<?>>
dimensionsOf(Tensorbacked<?> tensorbacked)
static <V> Tensor<V>
empty(java.lang.Class<?>... dimensions)
static <V,TB extends Tensorbacked<V>>
TBempty(java.lang.Class<TB> tensorbackedClass)
static <V> Tensor<V>
empty(java.lang.Iterable<java.lang.Class<?>> dimensions)
static <S> Tensor<com.google.common.base.Optional<S>>
errorsOf(Tensor<QuantifiedValue<S>> tensor)
static <S> Tensor<com.google.common.base.Optional<S>>
errorsOf(Tensorbacked<QuantifiedValue<S>> tensorbacked)
static <S> Tensor<S>
errorsOfOr(Tensor<QuantifiedValue<S>> tensor, S defaultValue)
static <S> OngoingTensorFiltering<S>
filter(Tensor<S> tensor)
static <V,TB extends Tensorbacked<V>>
OngoingTensorbackedFiltering<V,TB>filter(TB tensorbacked)
static <S> OngoingFlattening<S>
flatten(Tensor<S> tensor)
static <S> OngoingFlattening<S>
flatten(Tensorbacked<S> tensorbacked)
static <S> void
forEach(Tensor<S> tensor, java.util.function.BiConsumer<Position,S> consumer)
static <S> void
forEach(Tensor<S> tensor, java.util.function.Consumer<S> consumer)
static <S> void
forEach(Tensorbacked<S> tensorBacked, java.util.function.BiConsumer<Position,S> consumer)
static <S> void
forEach(Tensorbacked<S> tensorBacked, java.util.function.Consumer<S> consumer)
static <V> OngoingTensorManipulation<V>
from(Tensor<V> tensor)
static <V> OngoingTensorManipulation<V>
from(Tensorbacked<V> tensorbacked)
static <T> Tensor<T>
fromMap(java.lang.Iterable<java.lang.Class<?>> dimensions, java.util.Map<Position,T> map)
static <S,T>
Tensor<T>map(Tensor<S> tensor, java.util.function.BiFunction<Position,S,T> function)
static <S,T>
Tensor<T>map(Tensor<S> tensor, java.util.function.Function<S,T> function)
static <V> java.util.Map<Position,V>
mapFrom(Tensor<V> tensor)
static <E> Tensor<E>
merge(java.lang.Iterable<Tensor<E>> tensors)
static <E> Tensor<E>
mergeContextIntoShape(Tensor<E> tensor)
static java.util.Set<Position>
positionsOf(Tensor<?> tensor)
static java.util.Set<Position>
positionsOf(Tensorbacked<?> tensorbacked)
static <V> ImmutableQuantifiedValue<V>
quantityOf(V value, javax.measure.unit.Unit<?> unit)
Convenience method to create a quantity directly from a jscience base.static <V> ImmutableQuantifiedValue<V>
quantityOf(V value, Unit unit)
static <S> Tensor<QuantifiedValue<S>>
quantityTensorOf(Tensor<S> tensor, javax.measure.unit.Unit<?> unit)
static <S> Tensor<QuantifiedValue<S>>
quantityTensorOf(Tensor<S> tensor, Unit unit)
static <V> OngoingResamplingStart<V>
resample(Tensor<V> tensor)
static <S> Tensor<S>
sameValues(Shape shape, S value)
static <T> ImmutableScalar<T>
scalarOf(T value)
static <S> Tensor<S>
setContext(Tensor<S> tensor, Position context)
static <V,TB extends Tensorbacked<V>>
TBsetContext(TB tensorbacked, Position context)
static Shape
shapeOf(Tensorbacked<?> tensorbacked)
static <TB extends Tensorbacked<?>>
java.lang.Iterable<Shape>shapesOf(java.lang.Iterable<TB> tensorbackeds)
static int
sizeOf(Tensor<?> tensor)
static <TB extends Tensorbacked<?>>
intsizeOf(TB tensorbacked)
static <S> java.util.stream.Stream<java.util.Map.Entry<Position,S>>
stream(Tensor<S> tensor)
static <S> java.util.stream.Stream<java.util.Map.Entry<Position,S>>
stream(Tensorbacked<S> tensorBacked)
static <S> Tensor<S>
stripContext(Tensor<S> tensor)
static <V,TB extends Tensorbacked<V>>
TBstripContext(TB tensorbacked)
static <S> Tensor<S>
tensor(Shape shape, java.util.function.Function<Position,S> function)
static <S> Tensor<S>
tensor(Shape shape, java.util.function.Supplier<S> supplier)
static <S> java.lang.Iterable<Tensor<S>>
tensorsOf(java.lang.Iterable<? extends Tensorbacked<S>> tensorbackeds)
static <S,T>
Tensor<T>transformEntries(Tensor<S> tensor, java.util.function.Function<java.util.Map.Entry<Position,S>,T> function)
Deprecated.usemap(Tensor, BiFunction)
insteadstatic <S> Unit
unitOf(Tensor<QuantifiedValue<S>> tensor)
static <S> Unit
unitOf(Tensorbacked<QuantifiedValue<S>> tensorbacked)
static <E> TensoricSupport<E>
using(ExtendedField<E> field)
Creates an instance of a 'support' type class, which provides methods as starting points for the 'fluent' API for tensor manipulation.static <S> Tensor<java.lang.Boolean>
validitiesOf(Tensor<QuantifiedValue<S>> tensor)
static <S> Tensor<java.lang.Boolean>
validitiesOf(Tensorbacked<QuantifiedValue<S>> tensorbacked)
static <S> Tensor<S>
valuesOf(Tensor<QuantifiedValue<S>> tensor)
static <S> Tensor<S>
valuesOf(Tensorbacked<QuantifiedValue<S>> tensorbacked)
static Scalar<QuantifiedValue<java.lang.Double>>
zeroDimensionalOf(double value, javax.measure.unit.Unit<?> unit)
static Scalar<QuantifiedValue<java.lang.Double>>
zeroDimensionalOf(double value, Unit unit)
-
-
-
Method Detail
-
using
public static <E> TensoricSupport<E> using(ExtendedField<E> field)
Creates an instance of a 'support' type class, which provides methods as starting points for the 'fluent' API for tensor manipulation.- Type Parameters:
E
- the types of values in the field- Parameters:
field
- the (mathematical construct) field which defines the operations for the tensor elements.- Returns:
- a tensoric support, which provides the starting methods for the tensoric fluent API.
-
builder
public static <T> TensorBuilder<T> builder(java.lang.Iterable<java.lang.Class<?>> dimensions)
- See Also:
ImmutableTensor.builder(Iterable)
-
builder
public static <T> TensorBuilder<T> builder(java.lang.Class<?>... dimensions)
- See Also:
ImmutableTensor.builder(Class...)
-
builderBacked
public static <C1,T> Tensorbacked1dBuilder<C1,T,Tensorbacked1d<C1,T>> builderBacked(java.lang.Class<C1> dimension1)
-
builderBacked
public static <C1,C2,T> Tensorbacked2dBuilder<C1,C2,T,Tensorbacked2d<C1,C2,T>> builderBacked(java.lang.Class<C1> d1, java.lang.Class<C2> d2)
-
builderBacked
public static <C1,C2,C3,T> Tensorbacked3dBuilder<C1,C2,C3,T,Tensorbacked3d<C1,C2,C3,T>> builderBacked(java.lang.Class<C1> d1, java.lang.Class<C2> d2, java.lang.Class<C3> d3)
-
builderBacked
public static <C1,C2,C3,C4,T> Tensorbacked4dBuilder<C1,C2,C3,C4,T,Tensorbacked4d<C1,C2,C3,C4,T>> builderBacked(java.lang.Class<C1> d1, java.lang.Class<C2> d2, java.lang.Class<C3> d3, java.lang.Class<C4> d4)
-
builderBacked
public static <C1,C2,C3,C4,C5,T> Tensorbacked5dBuilder<C1,C2,C3,C4,C5,T,Tensorbacked5d<C1,C2,C3,C4,C5,T>> builderBacked(java.lang.Class<C1> d1, java.lang.Class<C2> d2, java.lang.Class<C3> d3, java.lang.Class<C4> d4, java.lang.Class<C5> d5)
-
fromMap
public static <T> Tensor<T> fromMap(java.lang.Iterable<java.lang.Class<?>> dimensions, java.util.Map<Position,T> map)
- See Also:
ImmutableTensor.fromMap(Iterable, Map)
-
copyOf
public static <T> Tensor<T> copyOf(Tensor<T> tensor)
- See Also:
ImmutableTensor.copyOf(Tensor)
-
builderFrom
public static <T> TensorBuilder<T> builderFrom(Tensor<T> tensor)
- See Also:
ImmutableTensor.builderFrom(Tensor)
-
scalarOf
public static <T> ImmutableScalar<T> scalarOf(T value)
- See Also:
ImmutableScalar.of(Object)
-
quantityOf
public static <V> ImmutableQuantifiedValue<V> quantityOf(V value, Unit unit)
-
quantityOf
public static <V> ImmutableQuantifiedValue<V> quantityOf(V value, javax.measure.unit.Unit<?> unit)
Convenience method to create a quantity directly from a jscience base.- Parameters:
value
- the of the quantityunit
- the base of the quantity- Returns:
- a new instance of the quantity
- See Also:
quantityOf(Object, Unit)
-
builderFor
public static <V,TB extends Tensorbacked<V>> SimpleTensorbackedBuilder<V,TB> builderFor(java.lang.Class<TB> tensorbackedClass)
- See Also:
Tensorbackeds.builderFor(Class)
-
builderFor1D
public static <C1,V,TB extends Tensorbacked1d<C1,V>> Tensorbacked1dBuilder<C1,V,TB> builderFor1D(java.lang.Class<TB> tensorbackedClass)
- See Also:
Tensorbackeds.builderFor1D(Class)
-
builderFor2D
public static <C1,C2,V,TB extends Tensorbacked2d<C1,C2,V>> Tensorbacked2dBuilder<C1,C2,V,TB> builderFor2D(java.lang.Class<TB> tensorbackedClass)
- See Also:
Tensorbackeds.builderFor2D(Class)
-
builderFor3D
public static <C1,C2,C3,V,TB extends Tensorbacked3d<C1,C2,C3,V>> Tensorbacked3dBuilder<C1,C2,C3,V,TB> builderFor3D(java.lang.Class<TB> tensorbackedClass)
- See Also:
Tensorbackeds.builderFor3D(Class)
-
builderFor4D
public static <C1,C2,C3,C4,V,TB extends Tensorbacked4d<C1,C2,C3,C4,V>> Tensorbacked4dBuilder<C1,C2,C3,C4,V,TB> builderFor4D(java.lang.Class<TB> tensorbackedClass)
- See Also:
Tensorbackeds.builderFor4D(Class)
-
builderFor5D
public static <C1,C2,C3,C4,C5,V,TB extends Tensorbacked5d<C1,C2,C3,C4,C5,V>> Tensorbacked5dBuilder<C1,C2,C3,C4,C5,V,TB> builderFor5D(java.lang.Class<TB> tensorbackedClass)
- See Also:
Tensorbackeds.builderFor5D(Class)
-
sizeOf
public static <TB extends Tensorbacked<?>> int sizeOf(TB tensorbacked)
- See Also:
Tensorbackeds.sizeOf(Tensorbacked)
-
sizeOf
public static int sizeOf(Tensor<?> tensor)
-
dimensionalityOf
public static <TB extends Tensorbacked<?>> int dimensionalityOf(TB tensorbacked)
-
empty
public static <V,TB extends Tensorbacked<V>> TB empty(java.lang.Class<TB> tensorbackedClass)
- See Also:
Tensorbackeds.empty(Class)
-
empty
public static <V> Tensor<V> empty(java.lang.Iterable<java.lang.Class<?>> dimensions)
-
empty
public static <V> Tensor<V> empty(java.lang.Class<?>... dimensions)
-
validitiesOf
public static <S> Tensor<java.lang.Boolean> validitiesOf(Tensorbacked<QuantifiedValue<S>> tensorbacked)
- See Also:
Tensorbackeds.validitiesOf(Tensorbacked)
-
valuesOf
public static <S> Tensor<S> valuesOf(Tensorbacked<QuantifiedValue<S>> tensorbacked)
- See Also:
Tensorbackeds.valuesOf(Tensorbacked)
-
errorsOf
public static <S> Tensor<com.google.common.base.Optional<S>> errorsOf(Tensorbacked<QuantifiedValue<S>> tensorbacked)
- See Also:
Tensorbackeds.errorsOf(Tensorbacked)
-
positionsOf
public static java.util.Set<Position> positionsOf(Tensorbacked<?> tensorbacked)
- See Also:
Tensorbackeds.positionsOf(Tensorbacked)
-
convertToQuantified
@Deprecated public static <S> Tensor<QuantifiedValue<S>> convertToQuantified(Tensor<S> tensor, Unit unit)
Deprecated.use renamed methodquantityTensorOf(Tensor, Unit)
-
quantityTensorOf
public static <S> Tensor<QuantifiedValue<S>> quantityTensorOf(Tensor<S> tensor, Unit unit)
-
quantityTensorOf
public static <S> Tensor<QuantifiedValue<S>> quantityTensorOf(Tensor<S> tensor, javax.measure.unit.Unit<?> unit)
-
unitOf
public static <S> Unit unitOf(Tensor<QuantifiedValue<S>> tensor)
- See Also:
QuantityTensors.unitOf(Tensor)
-
unitOf
public static <S> Unit unitOf(Tensorbacked<QuantifiedValue<S>> tensorbacked)
- See Also:
Tensorbackeds.unitOf(Tensorbacked)
-
shapeOf
public static Shape shapeOf(Tensorbacked<?> tensorbacked)
- See Also:
Tensorbackeds.shapeOf(Tensorbacked)
-
dimensionsOf
public static java.util.Set<java.lang.Class<?>> dimensionsOf(Tensorbacked<?> tensorbacked)
-
from
public static <V> OngoingTensorManipulation<V> from(Tensor<V> tensor)
- See Also:
TensorStructurals.from(Tensor)
-
from
public static <V> OngoingTensorManipulation<V> from(Tensorbacked<V> tensorbacked)
-
dimensionsOf
public static java.util.Set<java.lang.Class<?>> dimensionsOf(Tensor<?> tensor)
-
validitiesOf
public static <S> Tensor<java.lang.Boolean> validitiesOf(Tensor<QuantifiedValue<S>> tensor)
-
valuesOf
public static <S> Tensor<S> valuesOf(Tensor<QuantifiedValue<S>> tensor)
-
errorsOf
public static <S> Tensor<com.google.common.base.Optional<S>> errorsOf(Tensor<QuantifiedValue<S>> tensor)
-
errorsOfOr
public static <S> Tensor<S> errorsOfOr(Tensor<QuantifiedValue<S>> tensor, S defaultValue)
-
flatten
public static <S> OngoingFlattening<S> flatten(Tensor<S> tensor)
-
flatten
public static <S> OngoingFlattening<S> flatten(Tensorbacked<S> tensorbacked)
-
createFrom
@Deprecated public static <S> Tensor<S> createFrom(Shape shape, java.util.function.Supplier<S> supplier)
Deprecated.
-
createFrom
@Deprecated public static <S> Tensor<S> createFrom(Shape shape, java.util.function.Function<Position,S> function)
Deprecated.
-
tensor
public static <S> Tensor<S> tensor(Shape shape, java.util.function.Function<Position,S> function)
-
complete
public static <S> OngoingCompletion<S> complete(Tensor<S> tensor)
-
transformEntries
@Deprecated public static <S,T> Tensor<T> transformEntries(Tensor<S> tensor, java.util.function.Function<java.util.Map.Entry<Position,S>,T> function)
Deprecated.usemap(Tensor, BiFunction)
instead
-
map
public static <S,T> Tensor<T> map(Tensor<S> tensor, java.util.function.Function<S,T> function)
-
map
public static <S,T> Tensor<T> map(Tensor<S> tensor, java.util.function.BiFunction<Position,S,T> function)
-
forEach
public static <S> void forEach(Tensorbacked<S> tensorBacked, java.util.function.Consumer<S> consumer)
-
forEach
public static <S> void forEach(Tensorbacked<S> tensorBacked, java.util.function.BiConsumer<Position,S> consumer)
-
forEach
public static <S> void forEach(Tensor<S> tensor, java.util.function.Consumer<S> consumer)
-
forEach
public static <S> void forEach(Tensor<S> tensor, java.util.function.BiConsumer<Position,S> consumer)
-
zeroDimensionalOf
public static Scalar<QuantifiedValue<java.lang.Double>> zeroDimensionalOf(double value, javax.measure.unit.Unit<?> unit)
-
zeroDimensionalOf
public static Scalar<QuantifiedValue<java.lang.Double>> zeroDimensionalOf(double value, Unit unit)
-
tensorsOf
public static <S> java.lang.Iterable<Tensor<S>> tensorsOf(java.lang.Iterable<? extends Tensorbacked<S>> tensorbackeds)
- See Also:
Tensorbackeds.tensorsOf(Iterable)
-
construct
public static <V,TB extends Tensorbacked<V>> OngoingTensorbackedConstruction<V,TB> construct(java.lang.Class<TB> tensorbackedClass)
- See Also:
Tensorbackeds.construct(Class)
-
stripContext
public static <V,TB extends Tensorbacked<V>> TB stripContext(TB tensorbacked)
- See Also:
Tensorbackeds.stripContext(Tensorbacked)
-
stripContext
public static <S> Tensor<S> stripContext(Tensor<S> tensor)
- See Also:
TensorStructurals.stripContext(Tensor)
-
filter
public static <S> OngoingTensorFiltering<S> filter(Tensor<S> tensor)
- See Also:
TensorStructurals.filter(Tensor)
-
filter
public static <V,TB extends Tensorbacked<V>> OngoingTensorbackedFiltering<V,TB> filter(TB tensorbacked)
- See Also:
Tensorbackeds.filter(Tensorbacked)
-
setContext
public static <V,TB extends Tensorbacked<V>> TB setContext(TB tensorbacked, Position context)
-
stream
public static <S> java.util.stream.Stream<java.util.Map.Entry<Position,S>> stream(Tensor<S> tensor)
- See Also:
TensorStreams.tensorEntryStream(Tensor)
-
stream
public static <S> java.util.stream.Stream<java.util.Map.Entry<Position,S>> stream(Tensorbacked<S> tensorBacked)
- See Also:
TensorStreams.tensorEntryStream(Tensor)
-
shapesOf
public static <TB extends Tensorbacked<?>> java.lang.Iterable<Shape> shapesOf(java.lang.Iterable<TB> tensorbackeds)
- See Also:
Tensorbackeds.shapeOf(Tensorbacked)
-
complete
public static <S,TB extends Tensorbacked<S>> OngoingTensorbackedCompletion<TB,S> complete(TB tensorbacked)
- See Also:
Tensorbackeds.complete(Tensorbacked)
-
mapFrom
public static <V> java.util.Map<Position,V> mapFrom(Tensor<V> tensor)
- See Also:
TensorInternals.mapFrom(Tensor)
-
at
public static Position at(java.lang.Iterable<?> coordinates)
- See Also:
Position.of(Iterable)
-
at
public static Position at(java.lang.Object... coordinates)
- See Also:
Position.of(Object...)
-
resample
public static <V> OngoingResamplingStart<V> resample(Tensor<V> tensor)
- See Also:
TensorStructurals.resample(Tensor)
-
-