Lines Matching refs:cols
44 static elem_t* new_matrix(const int rows, const int cols)
47 assert(cols > 0);
48 return malloc(rows * cols * sizeof(elem_t));
58 static void init_matrix(elem_t* const a, const int rows, const int cols)
65 a[i * cols + j] = 1.0 / (1 + abs(i-j));
72 const elem_t* const a, const int rows, const int cols)
78 for (j = 0; j < cols; j++)
80 printf("%g ", a[i * cols + j]);
158 static void gj(elem_t* const a, const int rows, const int cols)
169 if (a[k * cols + i] > a[j * cols + i])
176 for (k = 0; k < cols; k++)
178 const elem_t t = a[i * cols + k];
179 a[i * cols + k] = a[j * cols + k];
180 a[j * cols + k] = t;
184 if (a[i * cols + i] != 0)
186 for (k = cols - 1; k >= 0; k--)
188 a[i * cols + k] /= a[i * cols + i];
202 const elem_t factor = a[j * cols + i];
203 for (k = 0; k < cols; k++)
205 a[j * cols + k] -= a[i * cols + k] * factor;
217 const elem_t factor = a[j * cols + i];
218 for (k = 0; k < cols; k++)
220 a[j * cols + k] -= a[i * cols + k] * factor;