mul_ function
Tensor
mul_(
- dynamic a,
- dynamic b
)
Implementation
Tensor mul_(dynamic a, dynamic b) {
if (a is num) {
return mul_(b, a);
} else if (a is Tensor) {
if (b is Tensor) {
Tensor_mul_(a._tensorPtr, b._tensorPtr);
final errorMsg = _get_and_reset_last_err();
if (errorMsg != nullptr) {
final errorString = errorMsg.cast<Utf8>().toDartString();
throw Exception(errorString);
}
final tensor = Tensor._internal(a._tensorPtr);
return tensor;
} else if (b is num) {
if (b is int) {
final rightScalar = int32_to_scalar(b);
Tensor_mul_scalar_(a._tensorPtr, rightScalar.scalarPtr);
final errorMsg = _get_and_reset_last_err();
if (errorMsg != nullptr) {
final errorString = errorMsg.cast<Utf8>().toDartString();
throw Exception(errorString);
}
final tensor = Tensor._internal(a._tensorPtr);
return tensor;
} else if (b is double) {
final rightScalar = float64_to_scalar(b);
Tensor_mul_scalar_(a._tensorPtr, rightScalar.scalarPtr);
final errorMsg = _get_and_reset_last_err();
if (errorMsg != nullptr) {
final errorString = errorMsg.cast<Utf8>().toDartString();
throw Exception(errorString);
}
final tensor = Tensor._internal(a._tensorPtr);
return tensor;
} else {
throw Exception("wrong data type");
}
} else {
throw Exception("wrong data type.");
}
} else {
throw Exception("wrong data type.");
}
}