Flypendo
Flypendo

Reputation: 9

Matrix column dimension containing '>' in C

I found a small C function that given a matrix, it removes the line 0 and the column 'i' and then put it in another matrix,

everything in order to calculate the determinant of the simplified matrix , but I have not ever seen a matrix column size like this:

void togli_riga0_colonnai(double mat [][dim], int n, int i, double matreduced[][dim]) 
 {
   int j, l;
  for(j=1;j<n;j++) {
    for(l=0;l<n;l++) {
      if(l!=i)
    matreduced[j-1][l-(l>i)]=mat[j][l];     
    }  
  }
}

within the '>' sign. Can anyone tell me what it could mean and when is it used? Thanks in advance

Upvotes: 0

Views: 25

Answers (1)

Robert Harvey
Robert Harvey

Reputation: 180777

It's just a greater-than sign. The resulting expression returns a boolean value. In C, boolean values are defined as true == 1 and false == 0. So this just looks like a bit of tricky math, equivalent to

matreduced[j-1][l-1]

if l is greater than i, and

matreduced[j-1][l]

if it isn't.

Upvotes: 3

Related Questions