// C++: Mat Mat::mul(Mat m, double scale = 1)
//
- // javadoc: Mat::mul(m, scale)
+ /**
+ * Element-wise multiplication with scale factor
+ * @param m operand with with which to perform element-wise multiplication
+ * @param scale scale factor
+ */
public Mat mul(Mat m, double scale) {
return new Mat(n_mul(nativeObj, m.nativeObj, scale));
}
- // javadoc: Mat::mul(m)
+ /**
+ * Element-wise multiplication
+ * @param m operand with with which to perform element-wise multiplication
+ */
public Mat mul(Mat m) {
return new Mat(n_mul(nativeObj, m.nativeObj));
}
+ /**
+ * Matrix multiplication
+ * @param m operand with with which to perform matrix multiplication
+ * @see Core#gemm(Mat, Mat, double, Mat, double, Mat, int)
+ */
+ public Mat matMul(Mat m) {
+ return new Mat(n_matMul(nativeObj, m.nativeObj));
+ }
+
//
// C++: static Mat Mat::ones(int rows, int cols, int type)
//
private static native long n_mul(long nativeObj, long m_nativeObj);
+ private static native long n_matMul(long nativeObj, long m_nativeObj);
+
// C++: static Mat Mat::ones(int rows, int cols, int type)
private static native long n_ones(int rows, int cols, int type);
--- /dev/null
+package org.opencv.core
+
+operator fun Mat.times(other: Mat): Mat = this.matMul(other)
assertMatEqual(truth, dst, EPS);
}
+ public void testMatMulMat() {
+ Mat m1 = new Mat(2, 2, CvType.CV_32F, new Scalar(2));
+ Mat m2 = new Mat(2, 2, CvType.CV_32F, new Scalar(3));
+
+ dst = m1.matMul(m2);
+
+ truth = new Mat(2, 2, CvType.CV_32F, new Scalar(12));
+ assertMatEqual(truth, dst, EPS);
+ }
+
public void testOnesIntIntInt() {
dst = Mat.ones(matSize, matSize, CvType.CV_32F);
- (BOOL)isSubmatrix;
- (void)locateROI:(Size2i*)wholeSize ofs:(Point2i*)offset NS_SWIFT_NAME(locateROI(wholeSize:offset:));
- (Mat*)mul:(Mat*)mat scale:(double)scale;
+/**
+ Performs element-wise multiplication
+ @param mat operand with with which to perform element-wise multiplication
+*/
- (Mat*)mul:(Mat*)mat;
+/**
+ Performs matrix multiplication
+ @param mat operand with with which to perform matrix multiplication
+ @see `Core.gemm(...)`
+*/
+- (Mat*)matMul:(Mat*)mat;
+ (Mat*)ones:(int)rows cols:(int)cols type:(int)type NS_SWIFT_NAME(ones(rows:cols:type:));
+ (Mat*)ones:(Size2i*)size type:(int)type NS_SWIFT_NAME(ones(size:type:));
+ (Mat*)onesEx:(NSArray<NSNumber*>*)sizes type:(int)type NS_SWIFT_NAME(ones(sizes:type:));
return [[Mat alloc] initWithNativeMat:new cv::Mat(_nativePtr->mul(*(cv::Mat*)mat.nativePtr))];
}
+- (Mat*)matMul:(Mat*)mat {
+ cv::Mat temp = self.nativeRef * mat.nativeRef;
+ return [Mat fromNative:temp];
+}
+
+ (Mat*)ones:(int)rows cols:(int)cols type:(int)type {
return [[Mat alloc] initWithNativeMat:new cv::Mat(cv::Mat::ones(rows, cols, type))];
}
return MatAt(mat: self, indices: indices)
}
}
+
+public extension Mat {
+ static func *(lhs:Mat, rhs: Mat) -> Mat {
+ return lhs.matMul(rhs)
+ }
+}
try assertMatEqual(truth!, dst, OpenCVTestCase.EPS)
}
+ func testMatMulMat() throws {
+ let m1 = Mat(rows: 2, cols: 2, type: CvType.CV_32F, scalar: Scalar(2))
+ let m2 = Mat(rows: 2, cols: 2, type: CvType.CV_32F, scalar: Scalar(3))
+
+ dst = m1.matMul(m2)
+
+ truth = Mat(rows: 2, cols: 2, type: CvType.CV_32F, scalar: Scalar(12))
+ try assertMatEqual(truth!, dst, OpenCVTestCase.EPS)
+ }
+
func testOnesIntIntInt() throws {
dst = Mat.ones(rows: OpenCVTestCase.matSize, cols: OpenCVTestCase.matSize, type: CvType.CV_32F)
}
+//
+// Mat Mat Mat::matMul(Mat m)
+//
+
+JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1matMul__JJ
+ (JNIEnv* env, jclass, jlong self, jlong m_nativeObj);
+
+JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_n_1matMul__JJ
+ (JNIEnv* env, jclass, jlong self, jlong m_nativeObj)
+{
+ static const char method_name[] = "Mat::n_1matMul__JJ()";
+ try {
+ LOGD("%s", method_name);
+ Mat* me = (Mat*) self; //TODO: check for NULL
+ Mat& m = *((Mat*)m_nativeObj);
+ Mat _retval_ = (*me) * m;
+ return (jlong) new Mat(_retval_);
+ } catch(const std::exception &e) {
+ throwJavaException(env, &e, method_name);
+ } catch (...) {
+ throwJavaException(env, 0, method_name);
+ }
+
+ return 0;
+}
+
//
// static Mat Mat::ones(int rows, int cols, int type)