1181{
1182 bool ret = true;
1183 int size =
static_cast<int>(A->
numRows());
1184 int bsize =
static_cast<int>(b->
numColumns());
1185 int info;
1186
1187
1188 if (size !=
static_cast<int>(A->
numColumns()))
1189 {
1190 ERROR(
"expected a square matrix");
1191 return false;
1192 }
1193
1194
1196 {
1197 ERROR(
"expected matrices to have same number of rows");
1198 return false;
1199 }
1200
1201 if (size == 0)
1202 {
1203 x->resize(size, bsize);
1204 return true;
1205 }
1206
1207 int* permutation = new int[size];
1210
1211 zgesv_(&size, &bsize, copyA.data(), &size, permutation, copyb.data(), &size, &info);
1212
1213 if (info > 0)
1214 {
1215 ERROR(
"according to zgesv, matrix is singular");
1216 ret = false;
1217 }
1218 else if (info < 0)
1219 {
1220 ERROR(
"argument passed to zgesv had an illegal value");
1221 ret = false;
1222 }
1223 else
1224 {
1225 x->resize(size, bsize);
1227 }
1228
1229 delete [] permutation;
1230 return ret;
1231}
size_t numColumns() const
std::vector< double > make_lapack_array(const DMatRR &mat)
void fill_from_lapack_array(const std::vector< double > &doubles, DMatRR &mat)
int zgesv_(int *n, int *nrhs, double *a, int *lda, int *ipiv, double *b, int *ldb, int *info)