libflame  revision_anchor
Functions
bl1_set_contig_strides.c File Reference

(r)

Functions

void bl1_set_contig_strides (int m, int n, int *rs, int *cs)
 

Function Documentation

◆ bl1_set_contig_strides()

void bl1_set_contig_strides ( int  m,
int  n,
int *  rs,
int *  cs 
)

Referenced by bl1_ccreate_contigm(), bl1_ccreate_contigmr(), bl1_ccreate_contigmt(), bl1_dcreate_contigm(), bl1_dcreate_contigmr(), bl1_dcreate_contigmt(), bl1_screate_contigm(), bl1_screate_contigmr(), bl1_screate_contigmt(), bl1_zcreate_contigm(), bl1_zcreate_contigmr(), and bl1_zcreate_contigmt().

14 {
15  // Default to column-major order.
16  *rs = 1;
17  *cs = m;
18 
19  // Handle special cases first.
20  // Check the strides, and modify them if needed.
21  if ( *rs == 1 && *cs == 1 )
22  {
23  // If both strides are unit, we are probably trying to create a
24  // 1-by-n matrix in column-major order, or an m-by-1 matrix in
25  // row-major order. We have decided to "reserve" the case where
26  // rs == cs == 1 for scalars only, as having unit strides can
27  // upset the BLAS error checking when attempting to induce a
28  // row-major operation.
29  if ( m > 1 && n == 1 )
30  {
31  // Set the column stride to indicate that this is an m-by-1
32  // matrix (or vector) stored in column-major order. This is
33  // necessary because, in some cases, we have to satisfy error
34  // checking in the underlying BLAS library, which expects the
35  // leading dimension to be set to at least m, even if it will
36  // never be used for indexing since there is only one column
37  // of data. Note that rs is already set to 1.
38  *cs = m;
39  }
40  else if ( m == 1 && 1 < n )
41  {
42  // Set the row stride to indicate that this is a 1-by-n matrix
43  // stored in row-major order. Note that cs is already set to 1.
44  *rs = n;
45  }
46  else
47  {
48  // If m == n == 1, then we are dealing with a scalar. Since rs
49  // and cs do not exceed m and n, we don't have to do anything.
50  }
51  }
52 }