{"record":{"id":"ff24f7a6193426b8","repo":"Yalantis/uCrop","slug":"solve-lapack-library-function-dgetrs-returne","errorCode":null,"errorMessage":"solve(): LAPACK library function dgetrs_() returned error code %d.","messagePattern":"solve\\(\\): LAPACK library function dgetrs_\\(\\) returned error code (.+?)\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":33024,"sourceCode":"        char TRANS = 'N';\n        int INFO, N = _height, LWORK = 4*N, *const IPIV = new int[N];\n        Ttfloat\n          *const lapA = new Ttfloat[N*N],\n          *const lapB = new Ttfloat[N],\n          *const WORK = new Ttfloat[LWORK];\n        cimg_forXY(A,k,l) lapA[k*N + l] = (Ttfloat)(A(k,l));\n        cimg_forX(*this,i) {\n          cimg_forY(*this,j) lapB[j] = (Ttfloat)((*this)(i,j));\n          cimg::getrf(N,lapA,IPIV,INFO);\n          if (INFO)\n            cimg::warn(_cimg_instance\n                       \"solve(): LAPACK library function dgetrf_() returned error code %d.\",\n                       cimg_instance,\n                       INFO);\n          else {\n            cimg::getrs(TRANS,N,lapA,IPIV,lapB,INFO);\n            if (INFO)\n              cimg::warn(_cimg_instance\n                         \"solve(): LAPACK library function dgetrs_() returned error code %d.\",\n                         cimg_instance,\n                         INFO);\n          }\n          if (!INFO) cimg_forY(*this,j) (*this)(i,j) = (T)(lapB[j]); else cimg_forY(*this,j) (*this)(i,j) = (T)0;\n        }\n        delete[] IPIV; delete[] lapA; delete[] lapB; delete[] WORK;\n#else\n        CImg<Ttfloat> lu(A,false);\n        CImg<Ttfloat> indx;\n        bool d;\n        lu._LU(indx,d);\n        CImg<T> res(_width,A._width);\n        cimg_pragma_openmp(parallel for cimg_openmp_if_size(_width*_height,16))\n        cimg_forX(*this,i) res.draw_image(i,get_column(i)._solve(lu,indx));\n        res.move_to(*this);\n#endif\n      } else { // Least-square solution for non-square systems","sourceCodeStart":33006,"sourceCodeEnd":33042,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L33006-L33042","documentation":"After factoring A, CImg::solve() applies LAPACK dgetrs_() to compute the solution; nonzero INFO indicates an invalid argument (bad TRANS/N/LDA/LDB or pivot array) rather than singularity, since dgetrf_ already succeeded. CImg warns and zero-fills the affected solution column.","triggerScenarios":"Calling solve() when the internal call to dgetrs_ receives inconsistent parameters — typically from dimension mismatches between this (B) and the coefficient matrix A, or a broken LAPACK build.","commonSituations":"Mixed-shape inputs (B rows != A rows) in code that was not type-checked; linking a partial LAPACK in an Android NDK build with a different ABI for dgetrs_.","solutions":["Validate that B.height() == A.height() and A is square before calling solve()","Link a complete, consistent LAPACK build in the NDK project","Check the result for the zero-fill fallback and retry with the LU-invert path or sgels","Print matrix dimensions before the call to catch shape mismatches"],"exampleFix":"// before\nCImg<float> x = B.solve(A);\n// after\nif (B.height() != A.height()) throw std::runtime_error(\"solve: row mismatch between B and A\");\nCImg<float> x = B.solve(A);","handlingStrategy":"validation","validationCode":"bool shapesConsistent(const CImg<float>& A, const CImg<float>& B) {\n  return A.width() == A.height() && B.height() == A.height();\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Assert B.height() == A.height() before every solve()","Log matrix dimensions around LAPACK calls in NDK builds","Use one consistent LAPACK build for all dget* routines","Check outputs for the zero-fill fallback pattern"],"tags":["cimg","lapack","linear-system"],"backgroundTag":"lapack-solver-failed","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}