{"record":{"id":"840ef0382818f886","repo":"Yalantis/uCrop","slug":"cimg-appname-math-parser-cimg-s-s-s-size","errorCode":null,"errorMessage":"[cimg_appname_math_parser] CImg<%s>::%s: %s: Size of first argument ('%s') does not match second argument 'nb_cols=%u', in expression '%s'.","messagePattern":"\\[cimg_appname_math_parser\\] CImg<(.+?)>::(.+?): (.+?): Size of first argument \\('(.+?)'\\) does not match second argument 'nb_cols=%u', in expression '(.+?)'\\.","errorType":"exception","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":23871,"sourceCode":"              arg1 = compile(ss6,se1,depth1,0,block_flags);\n              _cimg_mp_check_matrix_square(arg1,1);\n              p1 = (unsigned int)cimg::round(std::sqrt((float)size(arg1)));\n              _cimg_mp_scalar2(mp_trace,arg1,p1);\n            }\n\n            if (!std::strncmp(ss,\"transpose(\",10)) { // Matrix transpose\n              _cimg_mp_op(\"Function 'transpose()'\");\n              s1 = ss + 10; while (s1<se1 && (*s1!=',' || level[s1 - expr._data]!=clevel1)) ++s1;\n              arg1 = compile(ss + 10,s1,depth1,0,block_flags);\n              arg2 = compile(++s1,se1,depth1,0,block_flags);\n              _cimg_mp_check_type(arg1,1,2,0);\n              _cimg_mp_check_const_scalar(arg2,2,3);\n              p1 = size(arg1);\n              p2 = (unsigned int)mem[arg2];\n              p3 = p1/p2;\n              if (p2*p3!=p1) {\n                _cimg_mp_strerr;\n                throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] \"\n                                            \"CImg<%s>::%s: %s: Size of first argument ('%s') does not match \"\n                                            \"second argument 'nb_cols=%u', in expression '%s'.\",\n                                            pixel_type(),_cimg_mp_calling_function,s_op,\n                                            s_type(arg1)._data,p2,s0);\n              }\n              pos = vector(p3*p2);\n              CImg<ulongT>::vector((ulongT)mp_transpose,pos,arg1,p2,p3).move_to(code);\n              return_comp = true;\n              _cimg_mp_return(pos);\n            }\n            break;\n\n          case 'u' :\n            if (!std::strncmp(ss,\"ui2f(\",5)) { // Special uint->float conversion\n              _cimg_mp_op(\"Function 'ui2f()'\");\n              arg1 = compile(ss5,se1,depth1,0,block_flags);\n              if (is_vector(arg1)) _cimg_mp_vector1_v(mp_ui2f,arg1);\n              if (is_const_scalar(arg1))","sourceCodeStart":23853,"sourceCodeEnd":23889,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L23853-L23889","documentation":"An opcode takes a vector plus a constant scalar nb_cols; the parser computes rows = size(first argument)/nb_cols and requires the division to be exact. A non-zero remainder means the vector size is incompatible with the declared column count, so compilation aborts.","triggerScenarios":"Calling the opcode with a first-argument vector of size n and constant nb_cols=c where c*rows != n, e.g. size 7 with nb_cols=3.","commonSituations":"Data resized after the expression was written; hard-coded nb_cols not matching a dynamically sized vector; typo in column count.","solutions":["Change nb_cols to a divisor of size(first argument).","Resize/reshape the vector so its size equals nb_cols*rows.","Compute the column count from the data length rather than hard-coding it."],"exampleFix":"// before: vector size 8\n'build(v,3)'\n// after\n'build(v,4)' // 8/4 = 2 rows","handlingStrategy":"validation","validationCode":"if (v.length % nbCols !== 0) throw new Error('Vector size ' + v.length + ' incompatible with nb_cols=' + nbCols);","typeGuard":null,"tryCatchPattern":"try { img.eval(expr); } catch (e) { if (/does not match second argument 'nb_cols/.test(e.message)) { /* pick a divisor of v.length */ } else throw e; }","preventionTips":["Compute nb_cols as a divisor of the vector length at build time.","Resize vectors to nb_cols*rows before compiling.","Cover opcode calls with size-assertion tests."],"tags":["cimg","math-parser","matrix"],"backgroundTag":"tensor-shape-mismatch","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}