multiply<T> method

Mat multiply<T>(
  1. T val, {
  2. bool inplace = false,
})

Multiply

Note: multiply<Mat> is a wrapper for Mat &operator*=(Mat &a, const Mat &b)

Implementation

Mat multiply<T>(T val, {bool inplace = false}) {
  return switch (val) {
    Mat() => multiplyMat(val as Mat, inplace: inplace),
    int() => switch (type.depth) {
        MatType.CV_8U => multiplyU8(val as int, inplace: inplace),
        MatType.CV_8S => multiplyI8(val as int, inplace: inplace),
        MatType.CV_16U => multiplyU16(val as int, inplace: inplace),
        MatType.CV_16S => multiplyI16(val as int, inplace: inplace),
        MatType.CV_32S => multiplyI32(val as int, inplace: inplace),
        _ => throw UnsupportedError("multiply int to ${type.asString()} is not supported!"),
      },
    double() => switch (type.depth) {
        MatType.CV_32F => multiplyF32(val as double, inplace: inplace),
        MatType.CV_64F => multiplyF64(val as double, inplace: inplace),
        // MatType.CV_16F => multiplyF16(val as double, inplace: inplace), // TODO
        _ => throw UnsupportedError("multiply double to ${type.asString()} is not supported!"),
      },
    _ => throw UnsupportedError("Type $T is not supported"),
  };
}