Skip to content

Refactor mul! - #9

Merged
timholy merged 1 commit into
masterfrom
teh/mul
Apr 28, 2026
Merged

timholy merged 1 commit into
masterfrom
teh/mul

Conversation

@timholy

@timholy timholy commented Apr 28, 2026

Copy link
Copy Markdown
Member

The previous implementation of mul! had several problems:

  • No combination of FM * FM was well-supported: some combinations errored, and the rest fell through to generic mul! methods that were not optimized for FactoredMatrix.
  • The errors were error("not defined"), which is worse than a MethodError.
  • Some arguments were bizarrely typed as ::Array{T,N} which was both too specific (why restrict to Array?) and too general (why allow any N?).

This refactors the design of mul! to support all combinations of FM and AbstractMatrix while also:

  • supporting any AbstractMatrix type for the U and V fields of FactoredMatrix
  • adding new methods of Workspace and enhancing its documentation
  • renaming the fields of Workspace to be more memorable

Claude wrote the tests but wasn't useful for the implementation, which required careful attention to dispatch ambiguity.

The previous implementation of `mul!` had several problems:
- No combination of `FM * FM` was well-supported: some combinations
  errored, and the rest fell through to generic `mul!` methods that were
  not optimized for `FactoredMatrix`.
- The errors were `error("not defined")`, which is worse than a
  `MethodError`.
- Some arguments were bizarrely typed as `::Array{T,N}` which was both
  too specific (why restrict to `Array`?) and too general (why allow any
  `N`?).

This refactors the design of `mul!` to support all combinations of `FM`
and `AbstractMatrix` while also:
- supporting any `AbstractMatrix` type for the `U` and `V` fields of
  `FactoredMatrix`
- adding new methods of `Workspace` and enhancing its documentation
- renaming the fields of `Workspace` to be more memorable

Claude wrote the tests but wasn't useful for the implementation, which
required careful attention to dispatch ambiguity.
@timholy
timholy merged commit 6da47d7 into master Apr 28, 2026
2 checks passed
@timholy
timholy deleted the teh/mul branch April 28, 2026 10:29
timholy added a commit that referenced this pull request Apr 28, 2026
Formerly `getindex` was supported for `Adjoint{FactoredMatrix}` and
`Transpose{FactoredMatrix}`, but not `FactoredMatrix` itself. Since
`getindex` should not be supported by `Factorization` objects, just
delete these methods. This is a breaking change, so the version
is bumped to 1.0.0.

Also makes the lowercase `adjoint(A)` and `transpose(A)` return
`FactoredMatrix` objects. This was made possible by #9 which generalized
the types for `U` and `V`. Note the uppercase `Adjoint` and `Transpose`
type-wrappers still return the expected types.

* Bump to v1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant