Boost logo

Ublas :

Subject: [ublas] Banded matrix storage
From: Rutger ter Borg (rutger_at_[hidden])
Date: 2012-10-11 04:24:19


Dear Gunter and/or David,

I have a question regarding the banded matrix storage. Suppose we have a
5x5 matrix with 1 upper and 1 lower band,

row 0 [5]( 1, 2, 0, 0, 0)
row 1 [5]( 3, 4, 5, 0, 0)
row 2 [5]( 0, 6, 7, 8, 0)
row 3 [5]( 0, 0, 9,10,11)
row 4 [5]( 0, 0, 0,12,13)

and if we store this in ublas::row_major format, the raw data array
looks like

0: 0
1: 1
2: 3
3: 2
4: 4
5: 6
6: 5
7: 7
8: 9
9: 8
10: 10
11: 12
12: 11
13: 13
14: 0

so far, so good. This looks like what Lapack calls column major format,
i.e., the stuff shown on http://www.netlib.org/lapack/lug/node124.html

But, if I use a band array in ublas::column_major format, the raw data
looks like

0: 0
1: 2
2: 5
3: 8
4: 11
5: 1
6: 4
7: 7
8: 10
9: 13
10: 3
11: 6
12: 9
13: 12
14: 0

which looks like it is storing diagonal-after-diagonal, which is not
compatible with, at least, CBLAS. These libraries expected to read this
data like row_major:

0: 0
1: 1
2: 2
3: 3
4: 4
5: 5
6: 6
7: 7
8: 8
9: 9
10: 10
11: 11
12: 12
13: 13
14: 0

Can this be fixed in ublas?

Thanks,

Rutger