generated from control-toolbox/CTAppTemplate.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
Vectorisation three #204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jbcaillau
wants to merge
11
commits into
main
Choose a base branch
from
vectorisation-three
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Vectorisation three #204
+1,715
−41
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…lgebra support
Refactored test/exa_linalg.jl into a proper Julia module providing trait-based linear algebra extensions for Array{ExaModels.AbstractNode}. Extended operations to include trace, norms, determinant, array addition/subtraction, and diagonal operations. Added comprehensive unit tests in test/test_exa_linalg.jl covering all operation combinations with 164 passing tests.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Contributor
Member
Author
|
close #181 (that has been largely rethought) |
… (wrapper based) extensions, all inside test (no pollution of CTParser / external add-on)
Eliminated all 23 method ambiguities by restricting type parameters to Number or AbstractNode types, preventing conflicts with LinearAlgebra, SparseArrays, and other standard library methods. Changes: - Narrowed Scalar × Vector/Matrix operations to use Number instead of Any - Narrowed Vector/Matrix × Scalar operations to use Number instead of Any - Added explicit methods for AbstractNode × AbstractNode cases - Applied same pattern to dot, matrix-vector, matrix-matrix products - Applied same pattern to vector/matrix addition and subtraction - Applied same pattern to adjoint vector × matrix operations All 164 tests pass, zero ambiguities detected. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Added 43 new tests verifying all ambiguity fixes work correctly. New testset "Method ambiguity fixes" includes: - Scalar × Vector (both AbstractNode) - Vector × Scalar (both AbstractNode) - Scalar × Matrix (both AbstractNode) - Matrix × Scalar (both AbstractNode) - dot product (both AbstractNode) - Matrix × Vector (both AbstractNode) - the originally reported issue! - Matrix × Matrix (both AbstractNode) - Adjoint Vector × Matrix (both AbstractNode) - Vector + Vector (both AbstractNode) - Vector - Vector (both AbstractNode) - Matrix + Matrix (both AbstractNode) - Matrix - Matrix (both AbstractNode) - Mixed operations (no standard library conflicts) All 207 tests pass (increased from 164). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Implement optimization rules for operations involving zero values: - Multiplication: 0 * x and x * 0 return Null(0) - Addition: 0 + x and x + 0 return x (identity) - Subtraction: x - 0 returns x (identity) Added helper functions: - is_zero_value(x): detects zeros in Number, Null, and AbstractNode - zero_node(): returns canonical Null(0) Optimized 24 methods: - 12 scalar-vector/matrix multiplication methods - 6 vector/matrix addition methods - 6 vector/matrix subtraction methods Benefits: - Simpler expression trees (fewer Node2 allocations) - Type stability maintained (all return AbstractNode types) - Proper mathematical identities respected All 287 tests passing (added 43 new optimization tests). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Replace scattered zero checks with unified optimized scalar operations: - Add is_zero/is_one detection using iszero/isone for all numeric types - Use Null(nothing) as canonical zero (per ExaModels graph.jl line 313) - Add Null(1) as canonical one for multiplicative identity - Implement opt_add, opt_sub, opt_mul, opt_sum core operations - Refactor all vector/matrix ops to use these primitives Key optimization: dot([1,0,1,0], [x,y,z,t]) now produces x+z instead of bloated expression tree with unnecessary zero terms. Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add sum(::AbstractArray{<:AbstractNode}) wrapper around opt_sum
- Update convert to return zero_node() for zero values (canonical)
- Keep opt_* functions internal (not exported) following Julia best practices
- Import opt_* explicitly in tests for testing internal functions
- Update module documentation to clarify public vs internal API
- Remove exa_linalg_w files (obsolete)
sum([zero_node(), x, zero_node(), y]) now returns x + y directly,
skipping zeros during summation for optimal expression trees.
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Member
Author
|
@ocots please have a look (still draft) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
From #182