I'm looking for a mathematical notation for the following algorithm where $D$ is a diagonal square matrix and $w$ a scalar value.
- Sort $D$ by the diagonal entries ascending
- for the first entry $D_{1,1}$ $w_{1}$ = 1, for the second $w_{2}$ = 2 if $D_{2,2} > D_{1,1}$ and $w_{2}$ = 1 if $D_{2,2} = D_{1,1}$, for the i-th entry $w_{i}$ = $w_{i-1} + 1$ if $D_{i,i} > D_{i-1,i-1}$ and $w_{i}$ = $w_{i}$ if $D_{i,i} = D_{i-1,i-1}$
Here is an example:
i D_i,i w_i
1 : 1 => 1
2 : 1 => 1
3 : 2 => 2
4 : 2 => 2
5 : 4 => 3
What is a clean notation for this algorithm of type $w_{i} = f(D_{i,i})$?
You can just define the operation on tuples you want. Let $f: \{1, …, n\} \to \mathbb{N}$ be an $n$-tuple. Define recursively $f': \{1, …, n\} \to \mathbb{N}$ as \begin{align} f'(1) &= f(1), \\ f'(n + 1) &= \begin{cases} f'(n) + 1 & \text{if }f(n + 1) > f(n),\\ f'(n) & \text{else}. \end{cases} \end{align}
Now you can define $F$ operatin on tuples as $F(f) := f'$. So you end with function realizing your algorithm.