# Translation of the ribbon matrix into the normal

• We need to change the ribbons. http://num-anal.srcc.msu.ru/lib_na/org/org_matr.htm (a) The matrices are routine. I don't want to invent a bike. Maybe who knows the libraries/algorithms to make such a transformation?

• What bike? There's a code for a couple lines.

Here, I put on my knee the transformation into ribbon and back:

``````using static System.Console;
static void Main ()
{
const int N = 5;
const int KL = 2, KU = 1, B = KL + KU + 1;
var a = new int[N, N] {
{ 11, 12, 00, 00, 00 },
{ 21, 22, 23, 00, 00 },
{ 31, 32, 33, 34, 00 },
{ 00, 42, 43, 44, 45 },
{ 00, 00, 53, 54, 55 }
};

var b = new int[N, B];
for (int i = 0; i &lt; N; i++) {
for (int j = 0; j &lt; B; j++) {
int y = i + j - KL;
b[i, j] = y &gt;= 0 &amp;&amp; y &lt; N ? a[i, y] : 0;
}
}

var c = new int[N, N];
for (int i = 0; i &lt; N; i++) {
for (int j = 0; j &lt; N; j++) {
int y = j - i + KL;
c[i, j] = y &gt;= 0 &amp;&amp; y &lt; B ? b[i, y] : 0;
}
}

Print(a);
Print(b);
Print(c);

}
static void Print (int[,] m)
{
for (int i = 0; i < m.GetLength(0); i++) {
for (int j = 0; j < m.GetLength(1); j++)
Write("{0:00} ", m[i, j]);
WriteLine();
}
WriteLine();
}
``````

Conclusion:

``````11 12 00 00 00
21 22 23 00 00
31 32 33 34 00
00 42 43 44 45
00 00 53 54 55
00 00 11 12
00 21 22 23
31 32 33 34
42 43 44 45
53 54 55 00
11 12 00 00 00
21 22 23 00 00
31 32 33 34 00
00 42 43 44 45
00 00 53 54 55
``````

I can't guarantee no bagov. : But on the example of the article, the transformation works, so you're just gonna have to check that everything works right in every case.

2

2

2

2

2

2

2

2

2

2

2

2

2

2

2