What is a matrix?

A matrix is ​​data that is lined up in rows and columns.

# queue
14
twenty five
3 6

The above is a 3-by-2 matrix.

Column priority matrix and row priority matrix

When you programmatically represent a matrix, you have the data as an array. The method of expressing a matrix that arranges data in the column direction is called a column-priority matrix, and the method of expressing a matrix that arranges data in the row direction is called a row-priority matrix.

#Column-first matrix representation
my $mat_column_major = {
  rows_length => 3,
  columns_length => 2,
  values ​​=> [1, 2, 3, 4, 5, 6],
};;

# Row-first matrix representation
my $mat_row_major = {
  rows_length => 3,
  columns_length => 2,
  values ​​=> [1, 4, 2, 5, 3, 6],
};;

An introduction to deep learning uses column-first matrix representations. This is to make it easier to call the BLAS library for matrix calculations later when using C or cuda / GPU to speed up matrix calculations.

Associated Information