Macaulay2 Engine
Loading...
Searching...
No Matches

◆ solveLinear() [1/2]

bool ffpackInterface::solveLinear ( const DMatZZpFFPACK & A,
const DMatZZpFFPACK & B,
bool right_side,
DMatZZpFFPACK & X,
bool declare_A_is_invertible )

Definition at line 183 of file dmat.cpp.

188{
189 // std::cerr << "inside FFpackSolveLinear" << std::endl;
190 (void) declare_A_is_invertible;
191 size_t a_rows = A.numRows();
192 size_t a_cols = A.numColumns();
193
194 size_t b_rows = B.numRows();
195 size_t b_cols = B.numColumns();
196
197 DMatZZpFFPACK copyA(A);
198 DMatZZpFFPACK copyB(B);
199
200 // preallocate the space for the solutions:
201 size_t x_rows = (right_side ? a_cols : b_rows);
202 size_t x_cols = (right_side ? b_cols : a_rows);
203
204 X.resize(x_rows, x_cols); // sets it to 0 too.
205
206 int info = 0; // >0 if the system is inconsistent, ==0 means success
207
208 FFPACK::fgesv(A.ring().field(),
209 (right_side ? FFLAS::FflasLeft : FFLAS::FflasRight),
210 a_rows,
211 a_cols,
212 (right_side ? b_cols : b_rows),
213 copyA.rowMajorArray(),
214 a_cols, // leading dim of A
215 X.rowMajorArray(),
216 x_cols,
217 copyB.rowMajorArray(),
218 b_cols,
219 &info);
220
221 if (info > 0)
222 {
223 // the system is inconsistent
224 return false;
225 }
226
227 return true;
228}
#define DMatZZpFFPACK

References DMatZZpFFPACK.