From 1b6ab9b8e43081258ba9a923557883b0e4cf49cf Mon Sep 17 00:00:00 2001 From: Usman Hassan Date: Mon, 8 Sep 2025 02:08:41 -0700 Subject: [PATCH 1/4] Fix method ambiguity in Gaussian complete_compressor - Added specific method for Vector input to reshape to column matrix - Added method for AbstractMatrix input using invoke to resolve ambiguity - All tests now pass (2542/2542) --- src/Compressors/gaussian.jl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Compressors/gaussian.jl b/src/Compressors/gaussian.jl index 73245555..61338c68 100644 --- a/src/Compressors/gaussian.jl +++ b/src/Compressors/gaussian.jl @@ -123,7 +123,7 @@ function GaussianRecipe( return GaussianRecipe(cardinality, compression_dim, n_rows, n_cols, scale, op) end -function complete_compressor(ingredients::Gaussian, A::AbstractMatrix) +function complete_compressor(ingredients::Gaussian, A::AbstractArray) return GaussianRecipe( ingredients.cardinality, ingredients.compression_dim, @@ -132,6 +132,16 @@ function complete_compressor(ingredients::Gaussian, A::AbstractMatrix) ) end +# Handle Vector input by reshaping to column matrix +function complete_compressor(ingredients::Gaussian, v::Vector{T}) where T + complete_compressor(ingredients, reshape(v, :, 1)) +end + +# Resolve ambiguity for AbstractMatrix input +function complete_compressor(ingredients::Gaussian, A::AbstractMatrix) + invoke(complete_compressor, Tuple{Gaussian, AbstractArray}, ingredients, A) +end + # Allocations in this function are entirely due to bitrand call function update_compressor!(S::GaussianRecipe) # Inplace update of sketch_matrix From 0da20abe95c423011992dbfa0a08b1a2c2c4be5f Mon Sep 17 00:00:00 2001 From: Nathaniel pritchard Date: Wed, 17 Sep 2025 09:43:08 +0100 Subject: [PATCH 2/4] updated form of compressor --- src/Compressors.jl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Compressors.jl b/src/Compressors.jl index 92dca566..6dee5ca3 100644 --- a/src/Compressors.jl +++ b/src/Compressors.jl @@ -108,6 +108,26 @@ transpose(A::CompressorAdjoint{<:CompressorRecipe}) = A.parent ################################### # Complete Compressor Interface ################################### +""" + complete_compressor(compressor::Compressor, x::AbstractVector) + +$(comp_method_description[:complete_compressor]) + +# Arguments +- $(comp_arg_list[:compressor]) +- $(comp_arg_list[:x]) + +# Returns +- $(comp_output_list[:compressor_recipe]) + +# Throws +- $(comp_error_list[:complete_compressor]) +""" +function complete_compressor(compressor::Compressor, x::AbstractVector) + # Handle Vector input by reshaping to column matrix + complete_compressor(compressor, reshape(x, :, 1)) +end + """ complete_compressor(compressor::Compressor, A::AbstractMatrix) From 0b12a90b9555fdc7d8717ac5c97e93e922191ff1 Mon Sep 17 00:00:00 2001 From: Nathaniel pritchard Date: Wed, 1 Oct 2025 15:48:12 +0100 Subject: [PATCH 3/4] adjusted correction to be universal --- Project.toml | 11 +---------- src/Compressors/gaussian.jl | 12 +----------- test/Compressors/compressor_abstract_adjoint.jl | 2 +- test/Compressors/compressor_abstract_types.jl | 1 + 4 files changed, 4 insertions(+), 22 deletions(-) diff --git a/Project.toml b/Project.toml index ae1c5790..2394d9af 100644 --- a/Project.toml +++ b/Project.toml @@ -1,18 +1,9 @@ name = "RLinearAlgebra" uuid = "da1d211a-c3bc-43b2-b5d0-ce83f16a0f3a" -authors = [ - "Christian Varner ", - "Daniel Adrian Maldonado ", - "Nathaniel Pritchard ", - "TongTong Jin ", - "Tunan Wang ", - "Vivak Patel " -] +authors = ["Christian Varner ", "Daniel Adrian Maldonado ", "Nathaniel Pritchard ", "TongTong Jin ", "Tunan Wang ", "Vivak Patel "] version = "0.2.4" - [deps] -LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" diff --git a/src/Compressors/gaussian.jl b/src/Compressors/gaussian.jl index 61338c68..73245555 100644 --- a/src/Compressors/gaussian.jl +++ b/src/Compressors/gaussian.jl @@ -123,7 +123,7 @@ function GaussianRecipe( return GaussianRecipe(cardinality, compression_dim, n_rows, n_cols, scale, op) end -function complete_compressor(ingredients::Gaussian, A::AbstractArray) +function complete_compressor(ingredients::Gaussian, A::AbstractMatrix) return GaussianRecipe( ingredients.cardinality, ingredients.compression_dim, @@ -132,16 +132,6 @@ function complete_compressor(ingredients::Gaussian, A::AbstractArray) ) end -# Handle Vector input by reshaping to column matrix -function complete_compressor(ingredients::Gaussian, v::Vector{T}) where T - complete_compressor(ingredients, reshape(v, :, 1)) -end - -# Resolve ambiguity for AbstractMatrix input -function complete_compressor(ingredients::Gaussian, A::AbstractMatrix) - invoke(complete_compressor, Tuple{Gaussian, AbstractArray}, ingredients, A) -end - # Allocations in this function are entirely due to bitrand call function update_compressor!(S::GaussianRecipe) # Inplace update of sketch_matrix diff --git a/test/Compressors/compressor_abstract_adjoint.jl b/test/Compressors/compressor_abstract_adjoint.jl index d841f7a1..5bcb15a4 100644 --- a/test/Compressors/compressor_abstract_adjoint.jl +++ b/test/Compressors/compressor_abstract_adjoint.jl @@ -46,4 +46,4 @@ s_cols = 4 end end -end \ No newline at end of file +end diff --git a/test/Compressors/compressor_abstract_types.jl b/test/Compressors/compressor_abstract_types.jl index 49c6ca6b..80f25227 100644 --- a/test/Compressors/compressor_abstract_types.jl +++ b/test/Compressors/compressor_abstract_types.jl @@ -22,6 +22,7 @@ end x = rand(2) @test_throws ArgumentError complete_compressor(TestCompressor(), A) + @test_throws ArgumentError complete_compressor(TestCompressor(), b) @test_throws ArgumentError complete_compressor(TestCompressor(), A, b) @test_throws ArgumentError complete_compressor(TestCompressor(), x, A, b) @test_throws ArgumentError update_compressor!(TestCompressorRecipe()) From 155329d9b1e2d1f83ffb898f2fbbfdb2d0adfa55 Mon Sep 17 00:00:00 2001 From: Nathaniel pritchard Date: Wed, 1 Oct 2025 15:51:00 +0100 Subject: [PATCH 4/4] added linearalgebra back to project.toml --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index 2394d9af..abfdbd05 100644 --- a/Project.toml +++ b/Project.toml @@ -4,6 +4,7 @@ authors = ["Christian Varner ", "Daniel Adrian Maldonado