In the above example, the get() method of the tensor was used to get values at a certain position. However, you might notice that the API of
the tensor interface appears to be quite sparse: It contains only the really necessary methods to access the data of the tensor.
The philosophy of the tensorics library in this context is, that all more complicated manipulations are done by the use of static utility methods.
This allows to easily extend the library by new functionality without breaking the core interfaces. Many of this utility methods are
implemented such, that they are starting points for fluent clauses, which allows a (hopefully) very expressive and intuitive usage.
The second reason for this decision is, that in this way it is possible to provide an API with the same syntax for other objects,
like numbers or tensor expressions (To be explained later ;-).
So, instead of the above example, which uses the get() method directly, it is equivalent to write:
double temperature = Tensorics.from(temperatures).get(City.NEW_YORK, Day.APRIL_1_2014);
Together, with static imports for the from() method and the enum constants, this reads even nicer as:
double temperature = from(temperatures).get(NEW_YORK, APRIL_1_2014);
So far, this is of course not very impressive. However, the from(..) clause provides various other methods
which provide access to the data of the tensor. The most important ones of them are:
.Structural Operations
Last built: 2019-07-30 00:16:37 CEST