nareshmlx/opencv-pr huggingface dataset:
**File:** cmake/OpenCVCompilerOptimizations.cmake
**Change Type:** modified
**Context:** PR #14261: core:unv improve and split SSE into multiple files - - [x] types - [x] memory - [x] operators - [x] arithmetic - [x] math - [x] reorder - [...
**Review Line:** 181

**Code Changes:**
```diff
   ocv_update(CPU_AVX_512F_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx512.cpp")
@@ -177,6 +178,7 @@ if(X86 OR X86_64)
     ocv_update(CPU_FMA3_FORCE "") # Don't force other optimizations
     ocv_update(CPU_FP16_IMPLIES "AVX")
     ocv_update(CPU_FP16_FORCE "") # Don't force other optimizations
+    ocv_update(CPU_XOP_IMPLIES "AVX")
     ocv_update(CPU_AVX_IMPLIES "SSE4_2")
     ocv_update(CPU_SSE4_2_IMPLIES "SSE4_1;POPCNT")
     ocv_update(CPU_POPCNT_IMPLIES "SSE4_1")
@@ -207,6 +209,7 @@ if(X86 OR X86_64)
     ocv_intel_compiler_optimization_option(AVX "-mavx" "/arch:AVX")
```

Review comment:
There is wiki page: https://en.wikipedia.org/wiki/XOP_instruction_set `_mm_comge_epu32` can be emulated via SSE2 too. [Example](http://sseplus.sourceforge.net/group__emulated___s_s_e2.html#g17da283c41a855ae9c34c4782bbce9d9).
**File:** cmake/OpenCVCompilerOptimizations.cmake
**Change Type:** modified
**Context:** PR #14261: core:unv improve and split SSE into multiple files - - [x] types - [x] memory - [x] operators - [x] arithmetic - [x] math - [x] reorder - [...

**Code Changes:**
```diff
@@ -33,7 +33,7 @@
 #
 # CPU_{opt}_ENABLED_DEFAULT=ON/OFF - has compiler support without additional flag (CPU_BASELINE_DETECT=ON only)
 
-set(CPU_ALL_OPTIMIZATIONS "SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;FP16;AVX2;FMA3;AVX_512F;AVX512_SKX")
+set(CPU_ALL_OPTIMIZATIONS "SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;XOP;FP16;AVX2;FMA3;AVX_512F;AVX512_SKX")
 list(APPEND CPU_ALL_OPTIMIZATIONS NEON VFPV3 FP16)
 list(APPEND CPU_ALL_OPTIMIZATIONS VSX VSX3)
 list(REMOVE_DUPLICATES CPU_ALL_OPTIMIZATIONS)
@@ -152,7 +152,7 @@ elseif(" ${CMAKE_CXX_FLAGS} " MATCHES " -march=native | -xHost | /QxHost ")
```

Review comment:
This is list of legacy options (`ENABLE_XOP` doesn't exist before).
**File:** modules/core/include/opencv2/core/cvdef.h
**Change Type:** modified
**Context:** PR #14261: core:unv improve and split SSE into multiple files - - [x] types - [x] memory - [x] operators - [x] arithmetic - [x] math - [x] reorder - [...

**Code Changes:**
```diff
@@ -250,6 +250,8 @@ namespace cv { namespace debug_build_guard { } using namespace debug_build_guard
 #define CV_CPU_AVX_512VBMI      20
 #define CV_CPU_AVX_512VL        21
 
+#define CV_CPU_XOP              99
+
 #define CV_CPU_NEON             100
 
 #define CV_CPU_VSX              200
@@ -288,6 +290,7 @@ enum CpuFeatures {
```

Review comment:
Could you add link with wiki page here? ``` CPU_XOP = 99, //!< https://en.wikipedia.org/wiki/XOP_instruction_set ```
**File:** cmake/OpenCVCompilerOptimizations.cmake
**Change Type:** modified
**Context:** PR #14261: core:unv improve and split SSE into multiple files - - [x] types - [x] memory - [x] operators - [x] arithmetic - [x] math - [x] reorder - [...
**Review Line:** 181

**Code Changes:**
```diff
   ocv_update(CPU_AVX_512F_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx512.cpp")
@@ -177,6 +178,7 @@ if(X86 OR X86_64)
     ocv_update(CPU_FMA3_FORCE "") # Don't force other optimizations
     ocv_update(CPU_FP16_IMPLIES "AVX")
     ocv_update(CPU_FP16_FORCE "") # Don't force other optimizations
+    ocv_update(CPU_XOP_IMPLIES "AVX")
     ocv_update(CPU_AVX_IMPLIES "SSE4_2")
     ocv_update(CPU_SSE4_2_IMPLIES "SSE4_1;POPCNT")
     ocv_update(CPU_POPCNT_IMPLIES "SSE4_1")
@@ -207,6 +209,7 @@ if(X86 OR X86_64)
     ocv_intel_compiler_optimization_option(AVX "-mavx" "/arch:AVX")
```

Review comment:
There's no any AVX intrinsics involved only SSE. The reason of implies AVX its because all AMD CPUs that support XOP also support AVX and MSVC requires AVX too
**File:** modules/calib3d/src/stereosgbm.cpp
**Change Type:** modified
**Context:** PR #14261: core:unv improve and split SSE into multiple files - - [x] types - [x] memory - [x] operators - [x] arithmetic - [x] math - [x] reorder - [...
**Review Line:** 708

**Code Changes:**
```diff
@@ -705,7 +705,7 @@ static void computeDisparitySGBM( const Mat& img1, const Mat& img2,
                                 L0 = L0 + v_load(Sp + d);
                                 v_store(Sp + d, L0);
 
-                                v_int16x8 mask = _minS > L0;
+                                v_int16x8 mask = v_int16x8::fromMask(_minS > L0);
                                 _minS = v_min(_minS, L0);
                                 _bestDisp = _bestDisp ^ ((_bestDisp ^ _d8) & mask);
                                 _d8 += _8;
@@ -721,7 +721,7 @@ static void computeDisparitySGBM( const Mat& img1, const Mat& img2,
                             minS = std::min(v_reduce_min(min32L), v_reduce_min(min32H));
```

Review comment:
I think we can't that will break dispatch headers and there's no need to workaround it since ::fromMask only reinterpret mask types for SIMD/128&256. So we're not expecting any performance cost and of course I will provide performance testing results to make sure that everything is okay. BTW I moved AVX512 compatibility commits into separate PR #14331 and this PR should be merge after #14232 and backport of #14331.
**File:** modules/highgui/src/window_QT.cpp
**Change Type:** modified
**Context:** PR #14226: QString => const QString& - Fix function argument type from QString to const QString& to avoid copy-constructor call in window_QT.h && wind...
**Review Line:** 1636

**Code Changes:**
```diff
@@ -1633,7 +1633,7 @@ CvWinProperties::~CvWinProperties()
 // CvWindow
 
 
-CvWindow::CvWindow(QString name, int arg2)
+CvWindow::CvWindow(const QString& name, int arg2)
 {
     type = type_CvWindow;
 
@@ -1837,13 +1837,13 @@ void CvWindow::updateImage(void* arr)
 }
```

Review comment:
There is no corresponding change in the header.
**File:** modules/highgui/src/window_QT.cpp
**Change Type:** modified
**Context:** PR #14226: QString => const QString& - Fix function argument type from QString to const QString& to avoid copy-constructor call in window_QT.h && wind...
**Review Line:** 1636

**Code Changes:**
```diff
@@ -1633,7 +1633,7 @@ CvWinProperties::~CvWinProperties()
 // CvWindow
 
 
-CvWindow::CvWindow(QString name, int arg2)
+CvWindow::CvWindow(const QString& name, int arg2)
 {
     type = type_CvWindow;
 
@@ -1837,13 +1837,13 @@ void CvWindow::updateImage(void* arr)
 }
```

Review comment:
OK，I will check it again and build through locally
**File:** modules/highgui/src/window_QT.h
**Change Type:** modified
**Context:** PR #14226: QString => const QString& - Fix function argument type from QString to const QString& to avoid copy-constructor call in window_QT.h && wind...
**Review Line:** 145

**Code Changes:**
```diff
+    double getWindowVisible(const QString& name);
+    double getRatioWindow(const QString& name);
+    void setRatioWindow(const QString& name, double arg2 );
+    void saveWindowParameters(const QString& name);
+    void loadWindowParameters(const QString& name);
+    void putText(void* arg1, const QString& text, QPoint org, void* font);
+    void addButton(const QString& button_name, int button_type, int initial_button_state , void* on_change, void* userdata);
     void enablePropertiesButtonEachWindow();
 
-    void setOpenGlDrawCallback(QString name, void* callback, void* userdata);
-    void setOpenGlContext(QString name);
```

Review comment:
const QPoint& org
**File:** modules/videoio/src/cap_dshow.cpp
**Change Type:** modified
**Context:** PR #13550: fix mingw build direct show backend -  resolves #13549 ### This pullrequest changes  MinGW sprintf is would be defined as non stdio one. So...
**Review Line:** 108

**Code Changes:**
```diff
 #include <stdlib.h>
+#if !defined(__MINGW32__) && !defined(__MINGW64__)
+// MinGW sprintf is would be defined as non stdio one. So 
+// include this later after dshow.h declaration, otherwise compile failure 
+// because mingw dshow sprintf has it's own declaration that is different from the standard
 #include <stdio.h>
+#endif
 #include <math.h>
 #include <string.h>
 #include <wchar.h>
@@ -115,6 +120,10 @@ Thanks to:
```

Review comment:
Mentioned header has been included by precomp.hpp before that. So this condition looks useless. Please provide (fill issue): - error message from compiler without patch - used version of MinGW installation (with link)
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #14327: fix integer overflow for p.x when step is large -  resolves #14326 ### This pullrequest changes Add a cast to `long` for integer arithmetri...
**Review Line:** 4906

**Code Changes:**
```diff
@@ -4903,7 +4903,7 @@ Point LineIterator::pos() const
 {
     Point p;
     p.y = (int)((ptr - ptr0)/step);
-    p.x = (int)(((ptr - ptr0) - p.y*step)/elemSize);
+    p.x = (int)(((ptr - ptr0) - (long)p.y*step)/elemSize);
     return p;
 }
 
```

Review comment:
`long` is still [32-bit on Win32](https://en.cppreference.com/w/cpp/language/types). Consider using `int64` here (or `long long int`).
**File:** doc/tutorials/introduction/desktop_java/java_dev_intro.markdown
**Change Type:** modified
**Context:** PR #14621: java: add CascadeClassifier(File) constructor - As discussed in #5080 This change adds a constructor to `CascadeClassifier` with `File` par...
**Review Line:** 279

**Code Changes:**
```diff
     // Create a face detector from the cascade file in the resources
     // directory.
-    CascadeClassifier faceDetector = new CascadeClassifier(getClass().getResource("/lbpcascade_frontalface.xml").getPath());
+    File file = new File(getClass().getResource("/lbpcascade_frontalface.xml").getFile());
+    CascadeClassifier faceDetector = new CascadeClassifier(file);
     Mat image = Imgcodecs.imread(getClass().getResource("/lena.png").getPath());
 
     // Detect faces in the image.
```

Review comment:
I believe, `imread()` call has exactly the same problem (with other similar hits in the codebase). --- Actually "File" approach may not work well with packaged applications (.jar/.war or .apk on Android). I believe robust way is passing `InputStream` via `.getResourceAsStream()` / `.openRawResource()` calls. But it requires extra design work (proper "stream" reader on C++ side (`std::istream`) and proper wrappers for Java->C++ streams in bindings).
**File:** modules/imgproc/src/imgwarp.cpp
**Change Type:** modified
**Context:** PR #1289: Add IPP support in resize, warpAffine, warpPerspective functions
**Review Line:** 1686

**Code Changes:**
```diff
+
+      virtual void operator() (const Range& range) const
+      {
+          int cn = src.channels();
+          IppiRect srcroi = { 0, range.start, src.cols, range.end - range.start };
+          int dsty = CV_IMIN(cvRound(range.start * inv_scale_y), dst.rows);
+          int dstwidth = CV_IMIN(cvRound(src.cols * inv_scale_x), dst.cols);
+          int dstheight = CV_IMIN(cvRound(range.end * inv_scale_y), dst.rows);
+          IppiRect dstroi = { 0, dsty, dstwidth, dstheight - dsty };
+          int bufsize;
+          ippiResizeGetBufSize( srcroi, dstroi, cn, mode, &bufsize );
```

Review comment:
please, use std::min and std::max instead, CV_IMIN,IMAX are obsolete and might be removed in 3.0
**File:** modules/imgproc/src/imgwarp.cpp
**Change Type:** modified
**Context:** PR #1289: Add IPP support in resize, warpAffine, warpPerspective functions
**Review Line:** 1700

**Code Changes:**
```diff
+          if( func( src.data, ippiSize(src.cols, src.rows), (int)src.step[0], srcroi, dst.data, (int)dst.step[0], dstroi, inv_scale_x, inv_scale_y, 0, 0, mode, buf ) < 0 )
+              *ok = false;
+          ippsFree(buf);
+      }
+private:
+    Mat &src;
+    Mat &dst;
+    double inv_scale_x;
+    double inv_scale_y;
+    int mode;
+    ippiResizeSqrPixelFunc func;
```

Review comment:
it's bad practice to use references as class members. pointers or simply Mat's are better (I use pointers). Then the hidden copy constructor could be removed too.
**File:** modules/imgproc/src/imgwarp.cpp
**Change Type:** modified
**Context:** PR #1289: Add IPP support in resize, warpAffine, warpPerspective functions
**Review Line:** 1693

**Code Changes:**
```diff
+          int dstheight = CV_IMIN(cvRound(range.end * inv_scale_y), dst.rows);
+          IppiRect dstroi = { 0, dsty, dstwidth, dstheight - dsty };
+          int bufsize;
+          ippiResizeGetBufSize( srcroi, dstroi, cn, mode, &bufsize );
+          Ipp8u *buf;
+          buf = ippsMalloc_8u( bufsize );
+          IppStatus sts;
+          if( func( src.data, ippiSize(src.cols, src.rows), (int)src.step[0], srcroi, dst.data, (int)dst.step[0], dstroi, inv_scale_x, inv_scale_y, 0, 0, mode, buf ) < 0 )
+              *ok = false;
+          ippsFree(buf);
+      }
```

Review comment:
manual memory handling is error-prone, we try to avoid it by all means. Use std::vector or cv::AutoBuffer. The buffer may not be well-aligned, so make it slightly bigger and then use alignPtr() before passing the pointer to fund().
**File:** modules/imgproc/src/imgwarp.cpp
**Change Type:** modified
**Context:** PR #1289: Add IPP support in resize, warpAffine, warpPerspective functions
**Review Line:** 3401

**Code Changes:**
```diff
+#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
+class IPPwarpAffineInvoker :
+    public ParallelLoopBody
+{
+public:
+    IPPwarpAffineInvoker(Mat &_src, Mat &_dst, double (&_coeffs)[2][3], int &_interpolation, int &_borderType, const Scalar &_borderValue, ippiWarpAffineBackFunc _func, bool *_ok) :
+      ParallelLoopBody(), src(_src), dst(_dst), mode(_interpolation), coeffs(_coeffs), borderType(_borderType), borderValue(_borderValue), func(_func), ok(_ok)
+      {
+          *ok = true;
+      }
+
```

Review comment:
it's much more convenient to use Matx23d instead of double (&_coeffs)[2][3].
**File:** modules/imgproc/src/imgwarp.cpp
**Change Type:** modified
**Context:** PR #1289: Add IPP support in resize, warpAffine, warpPerspective functions
**Review Line:** 3511

**Code Changes:**
```diff
+            flags == INTER_NEAREST ? IPPI_INTER_NN :
+            flags == INTER_CUBIC ? IPPI_INTER_CUBIC : 
+            0;
+        if( mode && ippFunc )
+        {
+            double coeffs[2][3];
+            for( int i = 0; i < 2; i++ )
+            {
+                for( int j = 0; j < 3; j++ )
+                {
+                    coeffs[i][j] = matM.at<double>(i, j);
```

Review comment:
if you go with Matx23d, set coeffs using <pre> Matx23d coeffs(matM.ptr&lt;double&gt;()); </pre> no loop is needed
**File:** modules/imgproc/src/imgwarp.cpp
**Change Type:** modified
**Context:** PR #1289: Add IPP support in resize, warpAffine, warpPerspective functions
**Review Line:** 3641

**Code Changes:**
```diff
+#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
+class IPPwarpPerspectiveInvoker :
+    public ParallelLoopBody
+{
+public:
+    IPPwarpPerspectiveInvoker(Mat &_src, Mat &_dst, double (&_coeffs)[3][3], int &_interpolation, int &_borderType, const Scalar &_borderValue, ippiWarpPerspectiveBackFunc _func, bool *_ok) : 
+      ParallelLoopBody(), src(_src), dst(_dst), mode(_interpolation), coeffs(_coeffs), borderType(_borderType), borderValue(_borderValue), func(_func), ok(_ok)
+      {
+          *ok = true;
+      }
+
```

Review comment:
same thing about coeffs.
**File:** modules/imgproc/src/imgwarp.cpp
**Change Type:** modified
**Context:** PR #1289: Add IPP support in resize, warpAffine, warpPerspective functions
**Review Line:** 3668

**Code Changes:**
```diff
+          }
+          if( func(src.data, srcsize, (int)src.step[0], srcroi, dst.data, (int)dst.step[0], dstroi, coeffs, mode) < 0)
+              *ok = false;
+      }
+private:
+    Mat &src;
+    Mat &dst;
+    double (&coeffs)[3][3];
+    int mode;
+    int borderType;
+    const Scalar borderValue;
```

Review comment:
same thing about references and hidden copy constructor
**File:** modules/contrib/src/spinimages.cpp
**Change Type:** modified
**Context:** PR #609: Support for compiling with Clang c++11 - Allows compiling with Clang on OS X 10.8.2 with the following configuration: cmake -DBUILD_opencv_ja...
**Review Line:** 49

**Code Changes:**
```diff
@@ -46,6 +46,7 @@
 #include <functional>
 #include <fstream>
 #include <limits>
+#include <numeric>
 #include <set>
 
 using namespace cv;
```

Review comment:
All the changes but this one resolve C++11 narrowing errors (http://www.stroustrup.com/C++11FAQ.html#narrowing). This change is needed to use `iota`.
**File:** modules/gpu/perf/perf_imgproc.cpp
**Change Type:** modified
**Context:** PR #609: Support for compiling with Clang c++11 - Allows compiling with Clang on OS X 10.8.2 with the following configuration: cmake -DBUILD_opencv_ja...

**Code Changes:**
```diff
@@ -260,8 +260,8 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpPerspective,
     declare.in(src, WARMUP_RNG);
 
     const double aplha = CV_PI / 4;
-    double mat[3][3] = { {std::cos(aplha), -std::sin(aplha), src.cols / 2},
-                         {std::sin(aplha),  std::cos(aplha), 0},
+    double mat[3][3] = { {std::cos(aplha), -std::sin(aplha), (double)(src.cols / 2)},
+                         {std::sin(aplha),  std::cos(aplha), 0.0},
                          {0.0,              0.0,             1.0}};
     const cv::Mat M(3, 3, CV_64F, (void*) mat);
```

Review comment:
this change is not valid. if src.cols == 3, the original variant will give 1, the new one will give 1.5. Not sure which one was meant here, but the results are different
**File:** modules/calib3d/test/test_undistort_badarg.cpp
**Change Type:** modified
**Context:** PR #609: Support for compiling with Clang c++11 - Allows compiling with Clang on OS X 10.8.2 with the following configuration: cmake -DBUILD_opencv_ja...

**Code Changes:**
```diff
@@ -101,7 +101,7 @@ void CV_UndistortPointsBadArgTest::run(int)
     img_size.height = 600;
     double cam[9] = {150.f, 0.f, img_size.width/2.f, 0, 300.f, img_size.height/2.f, 0.f, 0.f, 1.f};
     double dist[4] = {0.01,0.02,0.001,0.0005};
-    double s_points[N_POINTS2] = {img_size.width/4,img_size.height/4};
+    double s_points[N_POINTS2] = {(double)(img_size.width/4),(double)(img_size.height/4)};
     double d_points[N_POINTS2];
     double p[9] = {155.f, 0.f, img_size.width/2.f+img_size.width/50.f, 0, 310.f, img_size.height/2.f+img_size.height/50.f, 0.f, 0.f, 1.f};
     double r[9] = {1,0,0,0,1,0,0,0,1};
```

Review comment:
this change is not valid. it should be (double)(ing_size.width/4), (double)(img_size.height/4)
**File:** modules/optim/src/lpsolver.cpp
**Change Type:** added
**Context:** PR #1192: Optim ds - I'm working on generic numerical optimization module for openCV within the Google Summer of Code 2013 initiative (mentor: Vadim P...
**Review Line:** 190

**Code Changes:**
```diff
+    return 0;
+}
+
+static int inner_simplex(Mat_<double>& c, Mat_<double>& b,double& v,vector<int>& N,vector<int>& B){
+    int count=0;
+    while(1){
+        dprintf(("iteration #%d\n",count));
+        count++;
+
+        static MatIterator_<double> pos_ptr;
+        int e=-1,pos_ctr=0,min_var=INT_MAX;
```

Review comment:
please, replace while(1) with for(;;) to avoid warnings from some compilers
**File:** modules/optim/src/simplex.cpp
**Change Type:** added
**Context:** PR #1192: Optim ds - I'm working on generic numerical optimization module for openCV within the Google Summer of Code 2013 initiative (mentor: Vadim P...
**Review Line:** 2

**Code Changes:**
```diff
@@ -0,0 +1,406 @@
+#include "precomp.hpp"
+#define ALEX_DEBUG
+#include "debug.hpp"
+
+namespace cv{namespace optim{
+    static double _cvDownhillSimplex_( 
+        double*    x,
```

Review comment:
this should be commented off
**File:** modules/optim/src/simplex.cpp
**Change Type:** added
**Context:** PR #1192: Optim ds - I'm working on generic numerical optimization module for openCV within the Google Summer of Code 2013 initiative (mentor: Vadim P...
**Review Line:** 57

**Code Changes:**
```diff
+            raw_x=(double*)proxy_x.data;
+        }else{
+            raw_x=(double*)x_mat.data;
+        }
+
+        double res=_cvDownhillSimplex_(raw_x,(double*)_step.data,_step.cols,_termcrit.epsilon,_termcrit.epsilon,&count,_Function,_termcrit.maxCount);
+        dprintf(("%d iterations done\n",count));
+
+        if(x_mat.rows>1){
+            Mat(x_mat.rows, 1, CV_64F, raw_x).copyTo(x_mat);
+        }
```

Review comment:
expand the "_cvDownhillSimplex_" function body here. We want this code to deviate as much as possible from the original
**File:** modules/optim/src/simplex.cpp
**Change Type:** added
**Context:** PR #1192: Optim ds - I'm working on generic numerical optimization module for openCV within the Google Summer of Code 2013 initiative (mentor: Vadim P...
**Review Line:** 61

**Code Changes:**
```diff
+
+        double res=_cvDownhillSimplex_(raw_x,(double*)_step.data,_step.cols,_termcrit.epsilon,_termcrit.epsilon,&count,_Function,_termcrit.maxCount);
+        dprintf(("%d iterations done\n",count));
+
+        if(x_mat.rows>1){
+            Mat(x_mat.rows, 1, CV_64F, raw_x).copyTo(x_mat);
+        }
+        return res;
+    }
+    DownhillSolverImpl::DownhillSolverImpl(){
+        _Function=Ptr<Function>();
```

Review comment:
this is incorrect code; replace .copyTo(x_mat) with .copyTo(x);
**File:** modules/optim/src/simplex.cpp
**Change Type:** added
**Context:** PR #1192: Optim ds - I'm working on generic numerical optimization module for openCV within the Google Summer of Code 2013 initiative (mentor: Vadim P...
**Review Line:** 86

**Code Changes:**
```diff
+    }
+    // both minRange & minError are specified by termcrit.epsilon; In addition, user may specify the number of iterations that the algorithm does.
+    Ptr<DownhillSolver> createDownhillSolver(const Ptr<Solver::Function>& f, InputArray initStep, TermCriteria termcrit){
+        DownhillSolver *DS=new DownhillSolverImpl();
+        DS->setFunction(f);
+        cv::Mat step=initStep.getMat();
+        DS->setInitStep(initStep);
+        DS->setTermCriteria(termcrit);
+        return Ptr<DownhillSolver>(DS);
+    }
+    void DownhillSolverImpl::getInitStep(OutputArray step)const{
```

Review comment:
no need in such conversion. pass initStep directly to setInitStep
**File:** modules/optim/src/simplex.cpp
**Change Type:** added
**Context:** PR #1192: Optim ds - I'm working on generic numerical optimization module for openCV within the Google Summer of Code 2013 initiative (mentor: Vadim P...
**Review Line:** 103

**Code Changes:**
```diff
+        if(MIN(m.cols,m.rows)==1 && m.type()==CV_64FC1){
+            int ndim=MAX(m.cols,m.rows);
+            if(ndim!=_step.cols){
+                _step=Mat_<double>(1,ndim);
+            }
+            for(Mat_<double>::iterator it1=m.begin<double>(),it2=_step.begin<double>();it1<m.end<double>();it1++,it2++){
+                *it2=*it1;
+            }
+        }
+    }
+
```

Review comment:
please, avoid such loops and use transposition as in the minimize() method.
**File:** modules/optim/src/simplex.cpp
**Change Type:** added
**Context:** PR #1192: Optim ds - I'm working on generic numerical optimization module for openCV within the Google Summer of Code 2013 initiative (mentor: Vadim P...
**Review Line:** 152

**Code Changes:**
```diff
+        double fac1,fac2,ytry,*ptry;
+        Mat_<double> matbuf;
+        
+        if(ndim>BUF_SIZE)
+        {
+    ////        ptry=(double*)cvAlloc(ndim*sizeof(double));
+            matbuf.create(1,ndim);
+            ptry=(double*)matbuf.data;
+        }
+        else
+        {
```

Review comment:
please, remove the commented-off code
**File:** .gitignore
**Change Type:** modified
**Context:** PR #1192: Optim ds - I'm working on generic numerical optimization module for openCV within the Google Summer of Code 2013 initiative (mentor: Vadim P...
**Review Line:** 9

**Code Changes:**
```diff
@@ -6,3 +6,4 @@ OpenCV4Tegra/
 .sw[a-z]
 .*.swp
 tags
+build/
```

Review comment:
Good practice is to use out-of-source build. Please, remove "build/".