Dear Gitlab users, as announced previously (and here), we will be downgrading this Gitlab instance delayed to the Community edition on Thursday, 25.08.22, at 5 pm. You may ignore the (upcoming) banner below displayed by Gitlab.

where $f_j = f(x_j)$ are the values of $f$ at equidistant sampling points $(x_j)_{j=1}^{N-1}$ with distance $h = x_1 - x_0$. As a matrix, this can simply be written as

$$V = h \begin{pmatrix}

1 & 0 & 0 & 0 & \ldots & 0 \\

1 & 1 & 0 & 0 & \ldots & 0 \\

1 & 1 & 1 & 0 & \ldots & 0 \\

\vdots & & & \ddots & & \\

1 & 1 & 1 & 1 & \ldots & 1

\end{pmatrix}$$

- Implement the Volterra operator with a parameter `h :: Double` as an instance of the `Operator` type class from the lecture, but with the `Arr` type alias replaced by

```haskell

typeArrr=ArrayrDIM1Double

```

Though it is possible to do this using a matrix formulation and e.g. `mmultS`, this unneccessarily inefficient. A better possibility is to note the connection between the Volterra operator and Haskell's `scanl` function. Moreover, there is an implementation of `scanl` for unboxed `Vector`s from `Data.Vector.Unboxed` (*not* HMatrix's `Numeric.Container`) as well as conversion functions `toUnboxed` and `fromUnboxed` for Repa `U` arrays to and from these `Vector`s. Use these to implement the operator.

- Implement the Volterra operator with parameter `h :: Double` and its adjoint.

Though it is possible to do this using a matrix formulation and e.g. `mmultS`, this unneccessarily inefficient. A better possibility is to note the connection between the Volterra operator and Haskell's `scanl` function. Moreover, there is an implementation of `scanl` for unboxed `Vector`s from `Data.Vector.Unboxed` as well as O(1) conversion functions `toUnboxed` and `fromUnboxed` for Repa `U` arrays to and from these `Vector`s. Use these to implement the operator.

*Note*: The adjoint (i.e. transpose) of the operator can be found most easily by noting the similarity between the Volterra matrix above and its transpose: the adjoint simply proceeds in the opposite direction.

- Use the regularized CG implementation from the lecture to compute regularized *derivatives* of the functions

$$\begin{align}

f_1(x) &= e^{-x^2} \\

f_2(x) &= \text{sgn}(x) = \begin{cases} -1 & x < 0 \\ 1 & x \geq 0 \end{cases}

\end{align}$$

sampled at 200 points between -2 and 2 and distorted by random noise between -0.1 and 0.1. The CG tolerance should be set suffieciently low (e.g. 1e-6).

- Plot the results together with the noisy functions and, in the case of $f_1$, the analytical derivative.

where $f_j = f(x_j)$ are the values of $f$ at equidistant sampling points $(x_j)_{j=1}^{N-1}$ with distance $h = x_1 - x_0$. As a matrix, this can simply be written as

$$V = h \begin{pmatrix}

1 & 0 & 0 & 0 & \ldots & 0 \\

1 & 1 & 0 & 0 & \ldots & 0 \\

1 & 1 & 1 & 0 & \ldots & 0 \\

\vdots & & & \ddots & & \\

1 & 1 & 1 & 1 & \ldots & 1

\end{pmatrix}$$

- Implement the Volterra operator with a parameter `h :: Double` as an instance of the `Operator` type class from the lecture, but with the `Arr` type alias replaced by

```haskell

typeArrr=ArrayrDIM1Double

```

Though it is possible to do this using a matrix formulation and e.g. `mmultS`, this unneccessarily inefficient. A better possibility is to note the connection between the Volterra operator and Haskell's `scanl` function. Moreover, there is an implementation of `scanl` for unboxed `Vector`s from `Data.Vector.Unboxed` (*not* HMatrix's `Numeric.Container`) as well as conversion functions `toUnboxed` and `fromUnboxed` for Repa `U` arrays to and from these `Vector`s. Use these to implement the operator.

- Implement the Volterra operator with parameter `h :: Double` and its adjoint.

Though it is possible to do this using a matrix formulation and e.g. `mmultS`, this unneccessarily inefficient. A better possibility is to note the connection between the Volterra operator and Haskell's `scanl` function. Moreover, there is an implementation of `scanl` for unboxed `Vector`s from `Data.Vector.Unboxed` as well as O(1) conversion functions `toUnboxed` and `fromUnboxed` for Repa `U` arrays to and from these `Vector`s. Use these to implement the operator.

*Note*: The adjoint (i.e. transpose) of the operator can be found most easily by noting the similarity between the Volterra matrix above and its transpose: the adjoint simply proceeds in the opposite direction.

- Use the regularized CG implementation from the lecture to compute regularized *derivatives* of the functions

$$\begin{align}

f_1(x) &= e^{-x^2} \\

f_2(x) &= \text{sgn}(x) = \begin{cases} -1 & x < 0 \\ 1 & x \geq 0 \end{cases}

\end{align}$$

sampled at 200 points between -2 and 2 and distorted by random noise between -0.1 and 0.1. The CG tolerance should be set suffieciently low (e.g. 1e-6).

- Plot the results together with the noisy functions and, in the case of $f_1$, the analytical derivative.

%% Cell type:code id: tags:

``` haskell

{-# LANGUAGE BangPatterns #-}

{-# LANGUAGE ScopedTypeVariables #-}

importControl.Monad.Identity

importData.Array.RepaasRhiding((++))

importData.Array.RepaasR

importqualifiedData.Vector.UnboxedasV

importData.Array.Repa.Helpers(runCGreg)

importData.Random.Normal(normalsIO')

importNumeric.LinearAlgebra.Helpers(linspace)

```

%% Cell type:code id: tags:

``` haskell

-- Copied from the lecture, except for changing DIM2 to DIM1 in the type Arr