Skip to content

Commit c009010

Browse files
committed
Replaced manual by adopted icalepcs paper
1 parent aa6f4c6 commit c009010

File tree

3 files changed

+454
-84
lines changed

3 files changed

+454
-84
lines changed

build.gradle

+10-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@ buildscript {
5656
dependencies {
5757
classpath 'com.netflix.nebula:nebula-publishing-plugin:5.1.0'
5858
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
59-
}
59+
60+
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:0.7.2'
61+
classpath 'org.asciidoctor:asciidoctorj:1.5.0'
62+
}
63+
64+
6065
}
6166

6267
apply plugin: 'java'
@@ -66,6 +71,10 @@ apply plugin: 'maven-publish'
6671
apply plugin: 'nebula.maven-publish'
6772
apply plugin: 'com.jfrog.bintray'
6873

74+
//if (System.getenv('BUILD_SERVER')) {
75+
apply plugin: 'org.asciidoctor.gradle.asciidoctor'
76+
//}
77+
6978
repositories {
7079
if (CERN_VM) {
7180
maven { url 'http://artifactory.cern.ch/ds-jcenter' }

src/asciidoc/tensorics-manual-old.ad

+190
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
---
2+
layout: default
3+
title: Tensorics Manual
4+
permalink: /projects/tensorics-core/manual/
5+
project: "Tensorics Core"
6+
---
7+
= Tensorics Manual
8+
Kajetan Fuchsberger <[email protected]>, Arkadiusz Gorzawski <[email protected]>
9+
:icons: font
10+
:sectanchors:
11+
:page-liquid:
12+
:source-highlighter: highlightjs
13+
:examplesource: {{ site.tensorics-core-dir }}/src/examples/org/tensorics/core/examples
14+
:sourcecodedir: {{ site.tensorics-core-dir }}/src/java/org/tensorics/core
15+
:javadoc-baseurl: {{ site.tensorics-core-javadoc }}/org/tensorics/core/tensor
16+
17+
Tensorics is a java framework for data processing of multidimensional data.
18+
The core object is a Tensor which represents a collection of values of arbitrary
19+
types, which are addressed by coordinates in an N-dimensional space. The framework
20+
provides several core features, which make it easy to work with big amounts of
21+
numerical data and drastically simplify repetitive tasks:
22+
23+
---
24+
* Tensors of arbitrary dimensionality as central object.
25+
* Tensors can have elements of any (java) type.
26+
* Structural and numerical operations on tensors.
27+
* Java internal DSL (fluent API) for all operations on scalars and tensors.
28+
* Quantities (value - unit pair).
29+
* Full support for Tensors of quantities.
30+
* Error and Validity propagation for quantities and tensors of quantities.
31+
* Scripting of all functionality with deferred execution, which opens the
32+
possibilities for parallel processing and massive distribution of calculations.
33+
34+
---
35+
36+
IMPORTANT: Both, the current implementation as well as this document, are work in progress.
37+
The main purpose of the actual version is provide some functionality of every of the above
38+
mentioned categories and proofing the concepts of their interplay. Still, already the available
39+
subset of features should have useful applications in many contexts. Almost no effort put on
40+
profiling and performance optimization. Therefore, it might well be that some operations are
41+
quite inefficient and/or memory consuming for big objects. Such improvements are definitely planned
42+
for later iterations. Any contributions are welcome.
43+
44+
== Getting Started
45+
46+
=== Tensors
47+
The core object of tensorics is a Tensor.
48+
Therefore, lets start and create one. The simplest Tensor is a tensor of zero dimensions and
49+
exactly one element. This can be created in the simplest
50+
case by
51+
52+
[source,java]
53+
----
54+
include::{examplesource}/TensorCreationExamples.java[tags=zerodimensionalString]
55+
----
56+
57+
More complicated tensors can be created using a builder:
58+
[source,java]
59+
----
60+
Builder<Double> builder = ImmutableTensor.builder(X.class, Y.class); # <1>
61+
62+
builder.at(new X(1.0), new Y(0.0)).put(5.0); # <2>
63+
builder.at(new X(1.0), new Y(1.0)).put(6.0);
64+
65+
Tensor<Double> tensor = builder.build(); # <3>
66+
----
67+
<1> Creating the builder. The dimensions have to be given here. Dimensions are the classes of the coordinates.
68+
<2> Putting values to the builder. For each class, given as dimension, exactly one instance has to be given in the ++at()++ clause.
69+
<3> Creates the real tensor.
70+
71+
=== Coordinates and Dimensions
72+
The above example illustrates already the most important concept of tensorics: Values of a tensor are addressed by
73+
coordinates in an arbitrary N-dimensional space. Each dimension of this space is uniquely coupled to a type of
74+
coordinate (The X and Y classes in the previous example). This might look a bit awkward at a first glance, because
75+
one has to define a class for each dimension. Further, many users might wonder, why we are not using indizes,
76+
like you would expect for a tensor (as in mathematics). This design choice has the following advantages:
77+
78+
* This approach can be considered as a natural generalization of a java map.
79+
* Having a class for each dimension, maps nicely to the way of speaking about multidimensional objects. Thing e.g. of
80+
'At this point, the Y-value is ...' or 'In direction of X ...'.
81+
* While addressing values by indizes might be ok for a small amount of dimensions, it becomes a hassle for many dimensions.
82+
Simply think about multidimensional arrays: How often did you mix up the order of indizes? Having a class per dimension
83+
clearly reveals its purpose.
84+
* This approach makes a tensor much more flexible. Consider the following example: If you would address elements of
85+
a matrix by row/column indizes, you would be forced to have the same number of columns in all the rows. While this
86+
might be preferrable for many applications, sometimes it is simply a too strict constraint for data in real live.
87+
Using a two-dimensional tensor is more flexible in this case - and you can still perform all the mathematical
88+
operations, as you will see later ;-)
89+
90+
=== Working with Tensors
91+
92+
The {javadoc-baseurl}/Tensor.html[Tensor] is the base interface.
93+
94+
== Structural Operations
95+
96+
== Mathematical Operations
97+
98+
== Fields
99+
100+
101+
=== Tensorbackeds
102+
103+
== Tensor manipulations
104+
105+
=== Operation
106+
107+
++Tensorics++ framework gives you an easy access to the most common calculations and operations you need such as:
108+
109+
* adding, subtracting, multiplying and dividing;
110+
* relevant inversion calculation: like negative and 1 over;
111+
* performing a reduction of a tensors with provided behavior:
112+
** we can ++slice++ an input ++tensor++ at given ++coordinate(s)++
113+
** we can ++average++ an input ++tensor++ over specified ++coordinate++
114+
115+
116+
In order to have an operation completed a definition of the ++Shape++ has to be introduced - it is a 'raw' view on the coordinates (keys) in the tensor.
117+
An introduction to basic behaviours can be found in following class.
118+
[source,java]
119+
----
120+
include::{sourcecodedir}/lang/ManipulationOptions.java[tags=classdef]
121+
----
122+
123+
Knowing about ++shapes++ it is possible to set/update a ++strategy++ in the framework such that any of the mentioned above operations can
124+
be performed on a possibly differently shaped tensors for this one has to set proper ++BroadcastingStrategy++. For performing multiplication
125+
a separate strategy ++filTheNameOfTheStrategy++ is foreseen since 2d tensors might be considered as a matrices for which this operation
126+
looks different.
127+
128+
=== Reduction & Merge
129+
Result of such operation will again be a ++tensor++ but with a simplified/improved set of
130+
dimensions (accordingly to provided input). Simple, isn't it?
131+
132+
Going further (we still stay in an example of temperature and pressure) one could imagine a situation when several cities
133+
are sending the data built on a base of ++tensor++ with one ++dimension++ (Time) but containing a special ++context++ field
134+
informing about 'higher order' dimensions it can belongs to (ie. Latitude and Longitude of the city).
135+
A ++Tensorics++ framework gives you and access to ++merge++ utility that will combine all provided tensors into one containing all data.
136+
This all will of course be only done if all provided inputs will be marked with the same 'higher order' dimensions.
137+
138+
Let's consider simple example of three ++dimension++ tensor of temperature and another one (same dimensionality) of an
139+
atmospheric pressure. Let's define those three dimensions as following:
140+
141+
* Time
142+
* Latitude
143+
* Longitude
144+
145+
Let's fill it later with some real data from two decades, with a day sampling for a few European cities.
146+
147+
[source,java]
148+
----
149+
include::{examplesource}/meteo/history/AbstractWeatherHistory.java[tags=import]
150+
----
151+
152+
And let's try to calculate some average temperature at some given latitude. With ++Tensorics++ framework it's easier than you think:
153+
154+
[source,java]
155+
----
156+
include::{examplesource}/meteo/history/WeatherHistoryInEurope.java[tags=import]
157+
----
158+
159+
160+
161+
== Backing up your objects.
162+
163+
Very often there is a need to access the data in unique, special way. You can use ++Tensor<V>++ objects to hold data and expose it in
164+
the way you like and need. The thing you need is called ++TensorBacked<V>++ interface that your class has to implement.
165+
166+
TIP: It is good practice to have only one constructor of you domain object that accepts only ++Tensor<V>++ as an argument.
167+
A special ++@Dimensions++ annotation gives the meta data for the framework to know, what dimensions are held inside.
168+
169+
=== Full support for ++TensorBacked<V>++ objects
170+
171+
The framework gives you a full support to perform all calculations (in direct and deferred way) directly with your customized objects.
172+
The return type of the calculation is always the same as the input type.
173+
174+
Let's again start with instantiation of the framework.
175+
[source,java]
176+
----
177+
fullTensoricSupport = Tensors.using(Structures.doubles());
178+
----
179+
180+
Then let's consider an object for our objects that is ++TensorBacked<Double>++ object and simplifies the access to the data.
181+
It's simple definition looks like the following:
182+
183+
[source,java]
184+
----
185+
include::{examplesource}/MultibeamOrbit.java[tags=classdef]
186+
----
187+
188+
TIP: The ++ Beam.class, Plane.class, Bpm.class++ are the coordinate classes that are declared to be used by ++@Dimensions++ annotation.
189+
190+
Last build: {localdatetime}

0 commit comments

Comments
 (0)