MCPcopy Create free account
hub / github.com/creatale/node-dv / solve

Method solve

deps/opencv/modules/core/src/lapack.cpp:1190–1461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1188\****************************************************************************************/
1189
1190bool cv::solve( InputArray _src, InputArray _src2arg, OutputArray _dst, int method )
1191{
1192 bool result = true;
1193 Mat src = _src.getMat(), _src2 = _src2arg.getMat();
1194 int type = src.type();
1195 bool is_normal = (method & DECOMP_NORMAL) != 0;
1196
1197 CV_Assert( type == _src2.type() && (type == CV_32F || type == CV_64F) );
1198
1199 method &= ~DECOMP_NORMAL;
1200 CV_Assert( (method != DECOMP_LU && method != DECOMP_CHOLESKY) ||
1201 is_normal || src.rows == src.cols );
1202
1203 // check case of a single equation and small matrix
1204 if( (method == DECOMP_LU || method == DECOMP_CHOLESKY) && !is_normal &&
1205 src.rows <= 3 && src.rows == src.cols && _src2.cols == 1 )
1206 {
1207 _dst.create( src.cols, _src2.cols, src.type() );
1208 Mat dst = _dst.getMat();
1209
1210 #define bf(y) ((float*)(bdata + y*src2step))[0]
1211 #define bd(y) ((double*)(bdata + y*src2step))[0]
1212
1213 uchar* srcdata = src.data;
1214 uchar* bdata = _src2.data;
1215 uchar* dstdata = dst.data;
1216 size_t srcstep = src.step;
1217 size_t src2step = _src2.step;
1218 size_t dststep = dst.step;
1219
1220 if( src.rows == 2 )
1221 {
1222 if( type == CV_32FC1 )
1223 {
1224 double d = det2(Sf);
1225 if( d != 0. )
1226 {
1227 double t;
1228 d = 1./d;
1229 t = (float)(((double)bf(0)*Sf(1,1) - (double)bf(1)*Sf(0,1))*d);
1230 Df(1,0) = (float)(((double)bf(1)*Sf(0,0) - (double)bf(0)*Sf(1,0))*d);
1231 Df(0,0) = (float)t;
1232 }
1233 else
1234 result = false;
1235 }
1236 else
1237 {
1238 double d = det2(Sd);
1239 if( d != 0. )
1240 {
1241 double t;
1242 d = 1./d;
1243 t = (bd(0)*Sd(1,1) - bd(1)*Sd(0,1))*d;
1244 Dd(1,0) = (bd(1)*Sd(0,0) - bd(0)*Sd(1,0))*d;
1245 Dd(0,0) = t;
1246 }
1247 else

Callers

nothing calls this directly

Calls 13

alignSizeFunction · 0.85
alignPtrFunction · 0.85
MatClass · 0.85
LUFunction · 0.85
CholeskyFunction · 0.85
JacobiFunction · 0.85
JacobiSVDFunction · 0.85
SVBkSbFunction · 0.85
getMatMethod · 0.45
typeMethod · 0.45
createMethod · 0.45
allocateMethod · 0.45

Tested by

no test coverage detected