%!TEX root = report.tex % \chapter{Types} \label{chap:types} The grammar of Diderot types is as follows: \begin{Grammar} \TypeRULES{} \end{Grammar}% \section{Value types} Diderot supports four types of concrete values: booleans, integers, strings, and tensors. The grammar of these types is \begin{Grammar} \ValueTypeRULES{} \DimensionsRULES{} \end{Grammar}% The tensor type \mbox{\kw{tensor}\kw{[}$d_1,\ldots{},d_n$\kw{]}} is the of type order-$n$ tensors with shape $d_1,\ldots{},d_n$. Tensors include scalars (order-0) and vectors (order-1). Because these types are frequently used, Diderot supports the following predefined type definitions: \begin{center} \begin{tabular}{r@{$\quad\equiv\quad$}l} \kw{real} & \texttt{\kw{tensor}\kw{[}\kw{]}} \\ \kw{vec2} & \texttt{\kw{tensor}\kw{[}2\kw{]}} \\ \kw{vec3} & \texttt{\kw{tensor}\kw{[}3\kw{]}} \\ \kw{vec4} & \texttt{\kw{tensor}\kw{[}4\kw{]}} \end{tabular} \end{center}% \section{Images} Images are rectangular arrays of tensor data that are used to represent the data sets that Diderot programs are analysing, as well as other data. The syntax of an image type is \begin{center} \kw{image}\kw{(} $n$ \kw{)} \kw{[} $d_1,\ldots{},d_n$ \kw{]} \end{center}% where $n$ is the dimension of the field (typically 2 or 3) and $d_1,\ldots{},d_n$ is the shape of the tensor data (\ie{}, the elements of the image are tensors of type \kw{tensor[}$d_1,\ldots{},d_n$\kw{]}). \section{Fields} Fields are functions from some $n$-dimensional vector space to some tensor type. The syntax of a field type is \begin{center} \kw{field}\kw{\#} $k$ \kw{(} $n$ \kw{)} \kw{[} $d_1,\ldots{},d_n$ \kw{]} \end{center}% where $k \geq 0$ is the number of levels of differentiation supported by the field, $n$ is the dimension of the field (typically 2 or 3), and $d_1,\ldots{},d_n$ is the shape of the field. Probing the field will produce a tensor of type \kw{tensor[}$d_1,\ldots{},d_n$\kw{]}. \section{Kernels} Kernels are abstract types that represent the \emph{convolution kernels} used to reconstruct continuous fields from image data. The syntax of a kernel type is \mbox{\kw{kernel}\kw{\#}$k$}, where $k \geq 0$ gives the number of levels of differentiation supported by the kernel. \section{Type promotion} Diderot's type system supports three kinds of \emph{implicit} type coercions that are added by the type checker when necessary: \begin{enumerate} \item Integer-typed expressions will be implicitly promoted to real-typed expressions. \item Static sequences will be implicitly promoted to dynamic sequences. \item A field-typed expression with continuity $k$ will be implicitly converted to a field with lower continuity. \end{enumerate}%
Click to toggle
does not end with </html> tag
does not end with </body> tag
The output has ended thus: h continuity $k$ will be implicitly converted to a field with lower continuity. \end{enumerate}%