Commit eb471442 authored by Davis King's avatar Davis King

Added a column_major_layout for the matrix.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402748
parent 55f1fcca
......@@ -311,7 +311,7 @@ namespace dlib
long num_rows = 0,
long num_cols = 0,
typename mem_manager = memory_manager<char>::kernel_1a,
typename layout = default_matrix_layout
typename layout = row_major_layout
>
class matrix : public matrix_exp<matrix<T,num_rows,num_cols,mem_manager,layout> >
{
......@@ -357,7 +357,7 @@ namespace dlib
unrolling which can result in substantially faster code.
Also note that the elements of this matrix are laid out in memory by the layout
object supplied as a template argument to this class. The default_matrix_layout
object supplied as a template argument to this class. The row_major_layout
sets elements down contiguously in memory and in row major order. Additionally,
all memory allocations are performed using the memory manager object supplied as
a template argument to this class.
......
This diff is collapsed.
......@@ -10,7 +10,7 @@ namespace dlib
// ----------------------------------------------------------------------------------------
struct default_matrix_layout
struct row_major_layout
{
/*!
This is the default matrix layout. Any matrix object that uses this
......@@ -20,6 +20,17 @@ namespace dlib
!*/
};
// ----------------------------------------------------------------------------------------
struct column_major_layout
{
/*!
Any matrix object that uses this layout will be laid out in memory in
column major order. Additionally, all elements are contiguous (e.g.
there isn't any padding at the ends of rows or anything like that)
!*/
};
// ----------------------------------------------------------------------------------------
}
......
......@@ -595,7 +595,7 @@ namespace dlib
const static long NR = OP::NR;
const static long NC = OP::NC;
const static long cost = OP::cost;
typedef default_matrix_layout layout_type;
typedef row_major_layout layout_type;
};
template <
......@@ -682,7 +682,7 @@ namespace dlib
const static long NR = OP::NR;
const static long NC = OP::NC;
const static long cost = OP::cost;
typedef default_matrix_layout layout_type;
typedef row_major_layout layout_type;
};
template <
......@@ -761,7 +761,7 @@ namespace dlib
const static long NR = OP::NR;
const static long NC = OP::NC;
const static long cost = OP::cost;
typedef default_matrix_layout layout_type;
typedef row_major_layout layout_type;
};
template <
......@@ -924,7 +924,7 @@ namespace dlib
const static long NR = 0;
const static long NC = 1;
const static long cost = 1;
typedef default_matrix_layout layout_type;
typedef row_major_layout layout_type;
};
template <
......@@ -1004,7 +1004,7 @@ namespace dlib
{
typedef typename M::type type;
typedef typename M::mem_manager_type mem_manager_type;
typedef default_matrix_layout layout_type;
typedef row_major_layout layout_type;
const static long NR = 0;
const static long NC = 1;
const static long cost = 1;
......@@ -1087,7 +1087,7 @@ namespace dlib
{
typedef typename M::type type;
typedef typename M::mem_manager_type mem_manager_type;
typedef default_matrix_layout layout_type;
typedef row_major_layout layout_type;
const static long NR = 0;
const static long NC = 0;
const static long cost = 1;
......@@ -1265,7 +1265,7 @@ namespace dlib
{
typedef long type;
typedef memory_manager<char>::kernel_1a mem_manager_type;
typedef default_matrix_layout layout_type;
typedef row_major_layout layout_type;
const static long NR = 0;
const static long NC = 1;
const static long cost = 1;
......@@ -1361,7 +1361,7 @@ namespace dlib
const static long NR = tabs<(end - start)>::value/inc_ + 1;
const static long NC = 1;
const static long cost = 1;
typedef default_matrix_layout layout_type;
typedef row_major_layout layout_type;
};
template <long start, long inc_, long end>
......
......@@ -10,7 +10,7 @@ namespace dlib
// ----------------------------------------------------------------------------------------
struct default_matrix_layout;
struct row_major_layout;
// ----------------------------------------------------------------------------------------
......@@ -19,7 +19,7 @@ namespace dlib
long num_rows = 0,
long num_cols = 0,
typename mem_manager = memory_manager<char>::kernel_1a,
typename layout = default_matrix_layout
typename layout = row_major_layout
>
class matrix;
......
......@@ -47,7 +47,7 @@ namespace
}
{
matrix<double,5,5> m(5,5);
matrix<double,5,5,MM,column_major_layout> m(5,5);
for (long r = 0; r < m.nr(); ++r)
{
......@@ -123,7 +123,7 @@ namespace
{
matrix<double,5,2> m;
matrix<double,5,2,MM,column_major_layout> m;
for (long r = 0; r < m.nr(); ++r)
{
......@@ -164,12 +164,12 @@ namespace
{
matrix<long> a1(5,1);
matrix<long,0,0,MM> a2(1,5);
matrix<long,0,0,MM,column_major_layout> a2(1,5);
matrix<long,5,1> b1(5,1);
matrix<long,1,5> b2(1,5);
matrix<long,0,1> c1(5,1);
matrix<long,1,0> c2(1,5);
matrix<long,0,1,MM> d1(5,1);
matrix<long,0,1,MM,column_major_layout> d1(5,1);
matrix<long,1,0,MM> d2(1,5);
for (long i = 0; i < 5; ++i)
......@@ -322,7 +322,7 @@ namespace
}
{
matrix<double> a(6,7);
matrix<double,0,0,MM,column_major_layout> a(6,7);
for (long r = 0; r < a.nr(); ++r)
{
......@@ -428,7 +428,7 @@ namespace
}
{
matrix<long,5,5> m1, res;
matrix<long,5,5,MM,column_major_layout> m1, res;
matrix<long,2,2> m2;
set_all_elements(m1,0);
......
......@@ -368,7 +368,7 @@ namespace
DLIB_CASSERT(sum(abs(sigmoid(dm10) -sigmoid(m10))) < 1e-10,sum(abs(sigmoid(dm10) -sigmoid(m10))) );
matrix<double, 7, 7,MM> m7;
matrix<double, 7, 7,MM,column_major_layout> m7;
matrix<double> dm7(7,7);
for (long r= 0; r< dm7.nr(); ++r)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment