The `result` matrix should be created with given factory. See other methods from `AbstractMatrix` for example.