[Question]
  [
**Objective**
Given a grid of numbers, fill in the inequalities.
**Assumptions**
The number of columns and rows in the grid are equal.  
The maximum size of the grid is 12x12.  
The grid only consists of integers 0-9.  
The output may contain a trailing newline.  
The input is exactly as written below, including spaces and newlines.
**Example Input**
```
4 2 3 1
6 2 3 1
6 9 2 1
0 2 1 6
```
**Example Output**
```
4>2<3>1
^ " " "
6>2<3>1
" ^ v "
6<9>2>1
v v v ^
0<2>1<6
```
**Example Input (2)**
```
1 2 3 4 5
5 4 3 2 1
0 0 0 3 2
3 2 0 0 0
2 1 3 1 5
```
**Example Output (2)**
```
1<2<3<4<5
^ ^ " v v
5>4>3>2>1
v v v ^ ^
0=0=0<3>2
^ ^ " v v
3>2>0=0=0
v v ^ ^ ^
2>1<3>1<5
```
**Example Input (3)**
```
8
```
**Example Output (3)**
```
8
```
**Example Input (4)**
```
0 0 0 0 0 0 0 0 0 0 0 0
0 1 1 1 1 1 1 1 1 1 1 0
0 1 2 3 4 5 6 7 8 9 1 0
0 1 3 9 8 7 6 5 4 8 1 0
0 1 4 8 9 8 7 6 5 7 1 0
0 1 5 7 8 9 9 7 6 6 1 0
0 1 6 6 7 9 9 8 7 5 1 0
0 1 7 5 6 7 8 9 8 4 1 0
0 1 8 4 5 6 7 8 9 3 1 0
0 1 9 8 7 6 5 4 3 2 1 0
0 1 1 1 1 1 1 1 1 1 1 0
0 0 0 0 0 0 0 0 0 0 0 0
```
**Example Output (4)**
```
0=0=0=0=0=0=0=0=0=0=0=0
" ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ "
0<1=1=1=1=1=1=1=1=1=1>0
" " ^ ^ ^ ^ ^ ^ ^ ^ " "
0<1<2<3<4<5<6<7<8<9>1>0
" " ^ ^ ^ ^ " v v v " "
0<1<3<9>8>7>6>5>4<8>1>0
" " ^ v ^ ^ ^ ^ ^ v " "
0<1<4<8<9>8>7>6>5<7>1>0
" " ^ v v ^ ^ ^ ^ v " "
0<1<5<7<8<9=9>7>6=6>1>0
" " ^ v v " " ^ ^ v " "
0<1<6=6<7<9=9>8>7>5>1>0
" " ^ v v v v ^ ^ v " "
0<1<7>5<6<7<8<9>8>4>1>0
" " ^ v v v v v ^ v " "
0<1<8>4<5<6<7<8<9>3>1>0
" " ^ ^ ^ " v v v v " "
0<1<9>8>7>6>5>4>3>2>1>0
" " v v v v v v v v " "
0<1=1=1=1=1=1=1=1=1=1>0
" v v v v v v v v v v "
0=0=0=0=0=0=0=0=0=0=0=0
```
  
[Answer]
# CJam, 52 bytes
```
qN%::~_z_2{{_1>.-W<:g}%\z}*@@..{'=+}.{N@"\"v^"f=S*N}
```
Try it online in the [CJam interpreter](http://cjam.aditsu.net/#code=qN%25%3A%3A~_z_2%7B%7B_1%3E.-W%3C%3Ag%7D%25%5Cz%7D*%40%40..%7B'%3D%2B%7D.%7BN%40%22%5C%22v%5E%22f%3DS*N%7D&input=0%200%200%200%200%200%200%200%200%200%200%200%0A%0A0%201%201%201%201%201%201%201%201%201%201%200%0A%0A0%201%202%203%204%205%206%207%208%209%201%200%0A%0A0%201%203%209%208%207%206%205%204%208%201%200%0A%0A0%201%204%208%209%208%207%206%205%207%201%200%0A%0A0%201%205%207%208%209%209%207%206%206%201%200%0A%0A0%201%206%206%207%209%209%208%207%205%201%200%0A%0A0%201%207%205%206%207%208%209%208%204%201%200%0A%0A0%201%208%204%205%206%207%208%209%203%201%200%0A%0A0%201%209%208%207%206%205%204%203%202%201%200%0A%0A0%201%201%201%201%201%201%201%201%201%201%200%0A%0A0%200%200%200%200%200%200%200%200%200%200%200).
*Thanks to @CroCo for pointing out a bug in revision 3.*
*Thanks to @Pyrrha for pointing out a bug in revision 6.*
### How it works
```
qN%        e# Read all input and split it at runs of linefeeds.
::~        e# Evaluate each character separately.
           e# This turns non-empty lines into arrays of integers.
_z_        e# Copy, transpose rows and columns, and copy again.
2{         e# Do the following twice:
  {        e#   For each row:
    _1>    e#     Copy the row and remove the copy's first element.
    .-     e#     Perform vectorized subtraction.
    W<     e#     Remove the last element.
           e#     This pushes the array of increments of the row.
    :g     e#     Replace each difference with its sign (-1, 0 or 1).
  }%       e#
  \        e#   Swap the two topmost arrays on the stack.
  z        e#   Transpose rows and columns of the topmost array.
}*         e#
           e# The topmost result has been transposed before and after computing
           e# the increments of its rows. It holds the increments of it columns.
           e# The result below it has been transposed twice (therefore not at
           e# all) before computing the increments of its rows.
@@         e# Rotate the number array and the row increment array on top.
..{        e# For each number and the corresponding increment, push both; then:
  '=+      e#   Add the increment to the character '='.
}          e#
.{         e# For each row of the column increment array and corresponding row
           e# of the last result, push both rows; then:
  N@       e#   Push a linefeed and rotate the column increments on top.
  "\"v^"f= e#   For each, select the appropriate comparison character.
  S*       e#   Join those characters, separated by spaces.
  N        e#   Push another linefeed.
 }         e#
```
[Answer]
# Python 2, ~~207~~ 197 bytes
```
f=lambda a:''.join(['=><'[cmp(a[i-1],a[i+1])]if c==' 'else'\n'+' '.join('"v^'[cmp(a[j-a.index('\n')],a[j+2])]for j in range(i,i+a.index('\n'),2))if a[i:i+2]=='\n\n'else c for i,c in enumerate(a)])
```
This one creates a function **f** which takes the grid of numbers as a string and returns the corresponding string with filled inequalities.
The function iterates over each character in the string. If the character is a space, it is replaced with the inequality for the numbers on either side. If the character and the next character are newlines, the whole line is replaced with the inequalities for all the numbers above and below.
Here is the output of the function for each of the examples in the question, except the really long one:
```
>>> print f("""\
... 4 2 3 1
...
... 6 2 3 1
...
... 6 9 2 1""")
4>2<3>1
^ " " "
6>2<3>1
" ^ v "
6<9>2>1
>>> print f("""\
... 1 2 3 4 5
...
... 5 4 3 2 1
...
... 0 0 0 3 2
...
... 3 2 0 0 0
...
... 2 1 3 1 5""")
1<2<3<4<5
^ ^ " v v
5>4>3>2>1
v v v ^ ^
0=0=0<3>2
^ ^ " v v
3>2>0=0=0
v v ^ ^ ^
2>1<3>1<5
>>> print f("8")
8
```
[Answer]
# Pyth, 46 bytes
```
juCms.iJ-d\ m.x@H._-FsMk\ .:J2Gc2"=><\"v^"%2.z
```
Try it online: [Demonstration](http://pyth.herokuapp.com/?code=juCms.iJ-d%5C%20m.x%40H._-FsMk%5C%20.%3AJ2Gc2%22%3D%3E%3C%5C%22v%5E%22%252.z&input=4%202%203%201%0A%0A6%202%203%201%0A%0A6%209%202%201%0A%0A0%202%201%206)
[Answer]
## C, ~~552~~ 408 bytes
This is a mess, but it does work with the test cases (for the solo `8`, the input has to be followed by a newline to work properly)
```
#define P putchar
main(n,z)char**z;{char*t=*++z;n=0;while(*(*z)++!=10)if(**z!=32)n++;char a[n][n];int r=-1,c=0;n--;do*t>32?c?:r++,a[c][r]=*t:*t==10?c=0:c++;while(*++t);r=c=0;do{int j=a[c][r],s=61,k=a[c+1][r];P(j);if (c==n){if(r==n)break;c=0;r++;P(10);for(int t=a[c][r-1],b=a[c][r];c<n+1;t=a[c][r-1],b=a[c][r])s=t>b?118:t<b?94:34,printf("%c ",s),c++;c=0;P(10);continue;}s=j>k?62:j<k?60:s;P(s);c++;}while(1);}
```
Here's the expanded version; I'd love to here ways on how I could golf this more effectively. I know that there is much to be improved on here.
```
#define P putchar
main(n,z)char**z; {
    char *t = *++z;
    n = 0;
    while (*(*z)++!=10)
        if (**z!=32)
            n++;
    char a[n][n];
    int c,r=c=0;
    r = -1,n--;
    do
        *t>32?c?:r++, a[c][r] = *t:*t==10?c=0:c++; //32 is ASCII for space
    while (*++t);
    r=c=0;
    do {
        int j = a[c][r],s=61,k = a[c+1][r];P(j);
        if (c==n)
        {
            if (r==n)break;
            c=0;r++;P(10);
            for (int t=a[c][r-1],b=a[c][r];c<n+1; t = a[c][r-1],b = a[c][r])
                s=t>b?118:t<b?94:34,printf("%c ",s),c++;
            c = 0;
            P(10);
            continue;
        }
        s=j>k?62:j<k?60:s;
    
        P(s);
        c++;
    } while (1);
}
```
[Answer]
# JavaScript (ES6) 162
```
f=s=>(s=s.split`
`).map((r,i)=>r?(w=r).replace(/ /g,(c,j)=>x('<=>',r[j-1]-r[j+1])):w.replace(/\d/g,(c,j)=>x('^"v', c-s[i+1][j]))  ,x=(y,v)=>y[-~(v>0)-(v<0)]).join`
`
// more readeable 
u=s=>(
  x=(y,v)=>y[-~(v>0)-(v<0)],
  s=s.split`\n`,
  s.map((r,i)=>r
    ?(w=r).replace(/ /g,(c,j)=>x('<=>',r[j-1]-r[j+1]))
    :w.replace(/\d/g,(c,j)=>x('^"v', c-s[i+1][j]))
  ).join`\n`
)
//TEST
console.log=x=>O.innerHTML+=x+'\n'
;[
 '4 2 3 1\n\n6 2 3 1\n\n6 9 2 1\n\n0 2 1 6'
,'1 2 3 4 5\n\n5 4 3 2 1\n\n0 0 0 3 2\n\n3 2 0 0 0\n\n2 1 3 1 5'
,'8',  
,'0 0 0 0 0 0 0 0 0 0 0 0\n\n0 1 1 1 1 1 1 1 1 1 1 0\n\n0 1 2 3 4 5 6 7 8 9 1 0\n\n0 1 3 9 8 7 6 5 4 8 1 0\n\n0 1 4 8 9 8 7 6 5 7 1 0\n\n0 1 5 7 8 9 9 7 6 6 1 0\n\n0 1 6 6 7 9 9 8 7 5 1 0\n\n0 1 7 5 6 7 8 9 8 4 1 0\n\n0 1 8 4 5 6 7 8 9 3 1 0\n\n0 1 9 8 7 6 5 4 3 2 1 0\n\n0 1 1 1 1 1 1 1 1 1 1 0\n\n0 0 0 0 0 0 0 0 0 0 0 0'  
].forEach(t=>console.log(t+'\n\n'+f(t)+'\n\n'))
```
```
<pre id=O></pre>
```
[Answer]
# Haskell, 201 bytes
```
import Data.List
t=transpose
g=mapM_ putStrLn.t.map(h 1).t.map(h 0).lines
h n s@(a:_:b:r)|'/'<a&&a<':'=a:(o n a b):h n(b:r)
 |0<1=s
h n r=r
f=fromEnum
o n a b=l!!n!!(1+signum(f a-f b))
l=["<=>","^\"v"]
```
`g` expects a string.
]