div property Null safety
final
Implementation
static final NormalOperation div = NormalOperation.floatOnly(
floatCalc: (Model m) {
final matX = m.x.asMatrix;
if (matX != null && m.y.asMatrix == null) {
// Page 179: x is matrix, y is scalar
final result = (m as Model15).matrices[m.resultMatrix];
result.copyFrom(m, m.matrices[matX]);
linalg.invert(result);
final y = m.yF;
result.visit((final int r, c) {
result.setF(r, c, result.getF(r, c) * y);
});
} else {
_scalarOrMatrix(m, scalar: (x, y) {
if (x == 0) {
throw CalculatorError(0);
}
return y / x;
}, matrix: (m, x, y, r) {
if (x != r) {
r.resize(m, y.rows, y.columns);
}
try {
linalg.solve(x, y, r);
} on linalg.MatrixOverflow {
m.floatOverflow = true;
}
});
}
m.needsSave = true;
},
complexCalc: (Model m) {
if (m.x.asMatrix != null || m.y.asMatrix != null) {
div.floatCalc!(m);
} else if (m.xC == Complex.zero) {
throw CalculatorError(0);
} else {
m.popSetResultXC = m.yC / m.xC;
}
},
name: '/');