title: cv::repeat() data or header only?
body: <p>I want to do basic math operation on a couple of matrices.</p>
  <p>In the beginning i was using a <code>cv::parallel_for_</code></p>
  <pre class="lang-cpp prettyprint-override"><code>cv::Mat A(307200, 100, CV_32F);
  cv::Mat B(307200, 100, CV_32F);
  cv::Mat C(307200, 1, CV_32F);
  
  cv::parallel_for_(cv::Range(0,A.cols),[&amp;](const cv::Range&amp; range){
      for (int r = range.start; r &lt; range.end; ++r) {
          B.col(r) = A.col(r) - C;
      }
  });
  </code></pre>
  <p>By using <code>cv::repeat()</code> to adjust the sizes accordingly, i was able to speed it up quite a bit</p>
  <pre class="lang-cpp prettyprint-override"><code>cv::Mat A(307200, 100, CV_32F);
  cv::Mat B(307200, 100, CV_32F);
  cv::Mat C(307200, 1, CV_32F);
  
  cv::Mat D = cv::repeat(C,1,100)
  
  cv::subtract(A,D,B);
  </code></pre>
  <p>In the <a href="https://docs.opencv.org/3.4/d2/de8/group__core__array.html#ga496c3860f3ac44c40b48811333cfda2d" rel="nofollow noreferrer">Docs</a> it states that <code>cv::repeat()</code> copies the input array</p>
  <blockquote>
  <p>Fills the output array with repeated copies of the input array.</p>
  </blockquote>
  <p>Is it actually copying the data or just the header?
  In numpy there is <a href="https://numpy.org/doc/stable/reference/generated/numpy.broadcast_to.html" rel="nofollow noreferrer">broadcast_to</a> which does not copy the data</p>
  <blockquote>
  <p>... more than one element of a broadcasted array may refer to a single memory location.</p>
  </blockquote>
  <p>Any way to replicate the with <code>opencv</code> only?</p>
  <p>Could my code be sped up even further?</p>