From a745b5570ead1b21d76dfd039b35023a7705f3c6 Mon Sep 17 00:00:00 2001 From: michielstock Date: Tue, 24 Mar 2026 11:37:25 +0100 Subject: [PATCH 1/2] :wrench: cleanup with Claude --- Project.toml | 1 - README.md | 2 +- docs/src/examples/introduction-to-hdc.jl | 9 +- docs/src/index.md | 4 +- ext/UnicodePlotting.jl | 4 +- scripts/concept.jl | 163 ----------------------- src/HyperdimensionalComputing.jl | 4 +- src/encoding.jl | 10 +- src/learning.jl | 30 ----- src/operations.jl | 8 +- src/predictors.jl | 35 ----- src/representations.jl | 1 - src/types.jl | 17 ++- test/benchmarking.jl | 32 ----- 14 files changed, 25 insertions(+), 295 deletions(-) delete mode 100644 scripts/concept.jl delete mode 100644 src/learning.jl delete mode 100644 src/predictors.jl delete mode 100644 test/benchmarking.jl diff --git a/Project.toml b/Project.toml index fd76718..7b07c28 100644 --- a/Project.toml +++ b/Project.toml @@ -4,7 +4,6 @@ authors = ["Carlos Vigil-Vásquez", "Dimi Boeckaerts", "Michiel Stock", "Steff T version = "0.1.0" [deps] -Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" diff --git a/README.md b/README.md index c24269b..f9e2dc3 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Hyperdimensional computing in Julia [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://michielstock.github.io/HyperdimensionalComputing.jl/stable) [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://michielstock.github.io/HyperdimensionalComputing.jl/dev) -[![Build Status](https://github.com/dimiboeckaerts/HyperdimensionalComputing.jl/workflows/CI/badge.svg)](https://github.com/dimiboeckaerts/HyperdimensionalComputing.jl/actions) +[![Build Status](https://github.com/MichielStock/HyperdimensionalComputing.jl/workflows/CI/badge.svg)](https://github.com/MichielStock/HyperdimensionalComputing.jl/actions) [![code style: runic](https://img.shields.io/badge/code_style-%E1%9A%B1%E1%9A%A2%E1%9A%BE%E1%9B%81%E1%9A%B2-black)](https://github.com/fredrikekre/Runic.jl) This package implements special types of vectors and associated methods for hyperdimensional diff --git a/docs/src/examples/introduction-to-hdc.jl b/docs/src/examples/introduction-to-hdc.jl index f82b9db..803bc59 100644 --- a/docs/src/examples/introduction-to-hdc.jl +++ b/docs/src/examples/introduction-to-hdc.jl @@ -1,4 +1,3 @@ -using Handcalcs #hide # # Introduction # @@ -64,7 +63,7 @@ h₃ = BipolarHV(; D = 8); # ## Bundling # # Bundling (also known as superposition) combines multiple hypervectors to create a new hypervector -# that is similar to it's constituyents. +# that is similar to it's constituents. # # $$u = [h_1 + h_2 + h_3]$$ # @@ -86,7 +85,7 @@ bundle([h₁, h₂, h₃]) h₁ + h₂ + h₃ -# This operation generates a hypervector that is similar to all it's contituyent hypervectors, +# This operation generates a hypervector that is similar to all it's constituent hypervectors, # such that # # $$h₁ \sim u, h₂ \sim u, h₃ \sim u$$ @@ -97,7 +96,7 @@ h₁ + h₂ + h₃ # ## Binding # # Binding combines multiple hypervectors to create a new hypervector that is dissimilar to it's -# constituyents, such that: +# constituents, such that: # # $$v = [h₁ \times h₂ \times h₃]$$ # @@ -111,7 +110,7 @@ bind([h₁, h₂, h₃]) h₁ * h₂ * h₃ -# This operation generates a hypervector that is similar to all it's contituyent hypervectors, +# This operation generates a hypervector that is similar to all it's constituent hypervectors, # such that # # $$h₁ \nsim v, h₂ \nsim v, h₃ \nsim v$$ diff --git a/docs/src/index.md b/docs/src/index.md index a335976..1c63bf7 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -4,11 +4,11 @@ CurrentModule = HyperdimensionalComputing # HyperdimensionalComputing.jl -Documentation for [HyperdimensionalComputing](https://github.com/dimiboeckaerts/HyperdimensionalComputing.jl). +Documentation for [HyperdimensionalComputing](https://github.com/MichielStock/HyperdimensionalComputing.jl). ## Overview -HyperdimensionalComputing.jl provides... +HyperdimensionalComputing.jl provides types and operations for hyperdimensional computing (HDC), a brain-inspired computational paradigm that represents and manipulates information using high-dimensional vectors. The package supports multiple vector symbolic architectures (BSC, MAP, FHRR, graded) with composable encoding strategies for sets, sequences, key-value pairs, graphs, and numeric levels. ## Manual diff --git a/ext/UnicodePlotting.jl b/ext/UnicodePlotting.jl index 57b98fc..7b64d68 100644 --- a/ext/UnicodePlotting.jl +++ b/ext/UnicodePlotting.jl @@ -24,10 +24,8 @@ function Base.show(io::IO, mime::MIME"text/plain", hv::AbstractHV) end function Base.show(io::IO, mime::MIME"text/plain", hv::Union{BinaryHV, BipolarHV}) - counts = Dict(e => count(==(e), hv) for e in unique(hv)) - #n = hv isa BinaryHV ? 0 : -1 # negative element + counts = Dict(string(e) => count(==(e), hv) for e in unique(hv)) println(io, "$(length(hv))-element $(typeof(hv))") - #println(io, "1 / $n : $(count(hv.v)) / $(length(hv) - count(hv.v))") println(io, barplot(counts)) return println(io, unicodeheatmap(hv)) end diff --git a/scripts/concept.jl b/scripts/concept.jl deleted file mode 100644 index ee990e6..0000000 --- a/scripts/concept.jl +++ /dev/null @@ -1,163 +0,0 @@ -#= -# Hyperdimensional computing interface - -date: 21 October 2021 - -author: Michiel Stock - -In this document, I present a Julia interface for computing with hyperdimensional -vectors (HDV). These are vectors of large dimensionality (typically 10,000) that -allow for distributed and holographic representing, storing and computing with patterns. - -## Hypervectors - -We first define a root abstract `AbstractHDV` type as a subtype of `AbstractVector`, -meaning we inherit all behaviour expected from a vector. -=# - -using LinearAlgebra - -abstract type AbstractHDV{T} <: AbstractVector{T} end - -Base.getindex(hdv::AbstractHDV, i) = hdv.v[(i + hdv.offset) % length(hdv) + 1] -Base.size(hdv::AbstractHDV) = size(hdv.v) -Base.setindex!(hdv::AbstractHDV, val, i) = (hdv.v[(i + hdv.offset) % length(hdv) + 1] = val) -normalize!(::AbstractHDV) = nothing ## vectors have no normalization by default - -# The first concrete type is `BipolarHDV`, which stores patterns with values $\{-1, 0, 1\}$. -# All concrete type store a vector with the values and an offset, allowing for inplace -# permutations. - -mutable struct BipolarHDV <: AbstractHDV{Int} - v::Vector{Int} - offset::Int - BipolarHDV(v::Vector, offset = 0) = new(v, offset) -end - -# We always provide a constructor with optinal dimensionality (n=10,000 by default) and -# a method `similar`. - -BipolarHDV(n::Int = 10_000) = BipolarHDV(rand((-1, 1), n)) -Base.similar(hdv::BipolarHDV) = BipolarHDV(similar(hdv.v)) - -normalize!(hdv::BipolarHDV) = (hdv.v .= sign.(hdv.v)) - -# `BinaryHDV` contain binary vectors. - -mutable struct BinaryHDV <: AbstractHDV{Bool} - v::Vector{Bool} - offset::Int - BinaryHDV(v::AbstractVector, offset = 0) = new(v, offset) -end - -BinaryHDV(n::Int = 10_000) = BinaryHDV(rand(Bool, n)) -Base.similar(hdv::BinaryHDV) = BinaryHDV(similar(hdv.v)) - -# GradedBipolarHDV are vectors in $[-1, 1]^n$, allowing for graded relations. - - -mutable struct GradedBipolarHDV{T <: Real} <: AbstractHDV{T} - v::Vector{T} - offset::Int - GradedBipolarHDV(v::AbstractVector, offset = 0) = new{eltype(v)}(v, offset) -end - -GradedBipolarHDV(T::Type, n::Int = 10_000) = GradedBipolarHDV(2rand(T, n) .- 1) -GradedBipolarHDV(n::Int = 10_000) = GradedBipolarHDV(Float32, n) - -Base.similar(hdv::GradedBipolarHDV) = GradedBipolarHDV(similar(hdv.v)) - -normalize!(hdv::GradedBipolarHDV) = (hdv.v .= camp.(hdv.v, -1, 1)) - -# Finally, `RealHDV` contain real values, drawn from a standard normal distribution -# by default. - -mutable struct RealHDV{T <: Real} <: AbstractHDV{T} - v::Vector{T} - offset::Int - RealHDV(v::Vector{T}, offset = 0) where {T} = new{T}(v, offset) -end - -RealHDV(n::Int = 10_000) = RealHDV(randn(n), 1.0) - -normalize!(hdv::RealHDV) = (hdv.v .*= √(length(hdv) / sum(abs2, hdv.v))) - -Base.similar(hdv::RealHDV) = RealHDV(similar(hdv.v)) - -#= -## Computing with HDV - -The following table contains the basic operations (two binary and one unary) that -are used to calculate with HDV. Important is that all these representations need to -be *reversible*. - -| Operation | symbol | remark | -| -------------------- | ------ | --------------------------------------------------------------------------------------------------------------- | -| Bundling/aggregating | `+` | combines the information of two vectors into a new vector similar to both | -| Binding | `*` | mapping, combines the two vectors in something different from both, preserves distance, distributes of bundling | -| Shifting | `Π` | Permutation (in practice cyclic shifting), distributes over addition, conserves distance | - -There are many options possible, so we use type-based dispatch to give the user control. - -### Aggregation - -Aggregation is at the highest level represented by `+`. (Question: should we introduce a specific symbol?) -=# - -aggr(hdv1::AbstractHDV, hdv2::AbstractHDV) = aggr!(similar(hdv1), hdv1, hdv2) - -Base.:+(hdv1::AbstractHDV, hdv2::AbstractHDV) = aggr(hdv1, hdv2) - -aggr!(r::BipolarHDV, hdv1::BipolarHDV, hdv2::BipolarHDV) = (r .= hdv1 .+ hdv2) -aggr!(r::BinaryHDV, hdv1::BinaryHDV, hdv2::BinaryHDV) = (r .= hdv1 .& hdv2) ## Conservative - - -function aggr!(r::RealHDV, hdv1::RealHDV, hdv2::RealHDV) - r .= hdv1 .+ hdv2 - r.norm = hdv1.norm + hdv2.norm - return r -end - -aggr!(r::GradedBipolarHDV, x::GradedBipolarHDV, y::GradedBipolarHDV) = (@. r = x * y / (x * y) + (1 - x) * (1 - y)) - -#= - -### Binding - -=# - -bind(hdv1::AbstractHDV, hdv2::AbstractHDV) = bind!(similar(hdv1), hdv1, hdv2) -Base.:*(hdv1::AbstractHDV, hdv2::AbstractHDV) = bind(hdv1, hdv2) - -bind!(r::BipolarHDV, hdv1::BipolarHDV, hdv2::BipolarHDV) = (r .= hdv1 .* hdv2) -bind!(r::RealHDV, hdv1::RealHDV, hdv2::RealHDV) = (r .= hdv1 .* hdv2) -bind!(r::BinaryHDV, hdv1::BinaryHDV, hdv2::BinaryHDV) = (r .= hdv1 .⊻ hdv2) -bind!(r::GradedBipolarHDV, x::GradedBipolarHDV, y::GradedBipolarHDV) = (@. r = x + y - x * y) - -#= -### Permutation - -Vectors can be permuted by performing a cyclic shift. -=# - -Base.circshift!(hdv::AbstractHDV, k) = (hdv.offset += k) - -function Base.circshift(hdv::AbstractHDV, k) - hdv = copy(hdv) - hdv.offset += k - return hdv -end - -Π(hdv::AbstractHDV, k) = circshift(hdv, k) - -#= - -## Inference and comparision - -To perform inference, one has to compute (dis)similarity between vectors. -=# - - -cos_sim(x::HDV, y::HDV) where {HDV <: AbstractHDV} = (x ⋅ y) / (norm(x.v) * norm(x.v)) - -jaccard(x::HDV, y::HDV) where {HDV <: BinaryHDV} = sum(xᵢ & yᵢ for (xᵢ, yᵢ) in zip(x, y)) / sum(xᵢ | yᵢ for (xᵢ, yᵢ) in zip(x, y)) diff --git a/src/HyperdimensionalComputing.jl b/src/HyperdimensionalComputing.jl index 7ef4d7d..f6a6356 100644 --- a/src/HyperdimensionalComputing.jl +++ b/src/HyperdimensionalComputing.jl @@ -1,6 +1,6 @@ module HyperdimensionalComputing -using Distances, Random, Distributions, LinearAlgebra +using Random, Distributions, LinearAlgebra include("types.jl") export AbstractHV, @@ -45,6 +45,4 @@ export similarity, nearest_neighbor -#include("learning.jl") - end diff --git a/src/encoding.jl b/src/encoding.jl index 1400eab..4676367 100644 --- a/src/encoding.jl +++ b/src/encoding.jl @@ -466,12 +466,12 @@ This encoding is based on the following mathematical notation: *Undirected graphs* ```math -\\otimes_{i=1}^{m} S_i \\otimes T_i +\\oplus_{i=1}^{m} S_i \\otimes T_i ``` *Directed graphs* ```math -\\otimes_{i=1}^{m} S_i \\otimes \\Pi(T_i) +\\oplus_{i=1}^{m} S_i \\otimes \\Pi(T_i) ``` where `K` and `V` are the key and value hypervector collections, `m` is the size of the @@ -598,12 +598,12 @@ decodelevel(HV, numvalues; testbound = false) = decodelevel(level(HV, length(num convertlevel(hvlevels, numvals..., kwargs...) convertlevel(HV::AbstractHV, numvals..., kwargs...) -Creates the `encoder` and `decoder` for a level incoding in one step. See `encodelevel` +Creates the `encoder` and `decoder` for a level encoding in one step. See `encodelevel` and `decodelevel` for their respective documentations. """ -convertlevel(hvlevels, numvals...; kwargs...) = encodelevel(hvlevels, numvals...; kwargs...), decodelevel(hvlevels, numvals..., kwargs...) +convertlevel(hvlevels, numvals...; kwargs...) = encodelevel(hvlevels, numvals...; kwargs...), decodelevel(hvlevels, numvals...; kwargs...) -convertlevel(hv::AbstractHV, numvals...; kwargs...) = encodelevel(hv, numvals...; kwargs...), decodelevel(hv, numvals..., kwargs...) +convertlevel(hv::AbstractHV, numvals...; kwargs...) = encodelevel(hv, numvals...; kwargs...), decodelevel(hv, numvals...; kwargs...) # levels using FHRR diff --git a/src/learning.jl b/src/learning.jl deleted file mode 100644 index 7fdd3f5..0000000 --- a/src/learning.jl +++ /dev/null @@ -1,30 +0,0 @@ -#= -learning.jl; Provides the basic functions to do learning. -=# - -train(y, hdvs) = Dict(c => aggregate(hdvs[y .== c]) for c in unique(y)) - -predict(v::AbstractHDV, centers) = maximum((similarity(v, xcᵢ), yᵢ) for (yᵢ, xcᵢ) in centers)[2] - -predict(hdvs::Vector{<:AbstractHDV}, centers) = [maximum((similarity(v, xcᵢ), yᵢ) for (yᵢ, xcᵢ) in centers)[2] for v in hdvs] - -function retrain!(centers, y, hdvs; niters = 10, verbose = true) - @assert length(y) == length(hdvs) - n_obs = length(y) - wrong = zeros(Bool, n_obs) - for iter in 1:niters - verbose && print("Iteration $iter of $niters ...") - # check all wrongly classified classes - for (i, (yᵢ, hdv)) in enumerate(zip(y, hdvs)) - (predict(hdv, centers) != yᵢ) && (wrong[i] = true) - end - n_errors = sum(wrong) - verbose && println(" found $n_errors classification errors") - # aggregate all the mistaken vectors again in the centers - for (yₖ, cₖ) in centers - aggregatewith!(cₖ, hdvs[(y .== yₖ) .& wrong]) - end - fill!(wrong, false) - end - return centers -end diff --git a/src/operations.jl b/src/operations.jl index 2de0640..8059d44 100644 --- a/src/operations.jl +++ b/src/operations.jl @@ -2,8 +2,6 @@ operations.jl; This file implements operations that can be done on hypervectors to enable them to encode text-based data. =# -# Remark: use element-wise reduce, maybe using LazyArrays? - #= | Operation | symbol | remark | @@ -219,7 +217,7 @@ Base.isequal(v::AbstractHV, u::AbstractHV) = v.v == u.v """ Base.isapprox(u::AbstractHV, v::AbstractHV, atol=length(u)/100, ptol=0.01) -Measurures when two hypervectors are similar (have more elements in common than expected +Measures when two hypervectors are similar (have more elements in common than expected by chance). One can specify either: @@ -239,12 +237,12 @@ end """ Base.isapprox(u::AbstractHV, v::AbstractHV, atol=length(u)/100, ptol=0.01) -Measurures when two hypervectors are similar (have more elements in common than expected +Measures when two hypervectors are similar (have more elements in common than expected by chance) using the Hamming distance. Uses a bootstrap to construct a null distribution. One can specify either: - `ptol=1e-10` threshold for seeing that many matches due to chance -- `N_bootstap=200` number of samples for bootstrapping +- `N_bootstrap=200` number of samples for bootstrapping """ function Base.isapprox(u::T, v::T; ptol = 1.0e-10, N_bootstrap = 500) where {T <: AbstractHV} @assert length(u) == length(v) "Vectors have to be of equal length" diff --git a/src/predictors.jl b/src/predictors.jl deleted file mode 100644 index b3f323b..0000000 --- a/src/predictors.jl +++ /dev/null @@ -1,35 +0,0 @@ -#= -predictors.jl; This file implements methods to compare encoded strings to references and to make predictions from this comparison. -=# - - -### Cosine distance predictor -""" -This function makes predictions for the given encodings by finding the closest class encoding in terms of cosine distance.\n -Input: - - a vector of encoded test sequences.\n - - a dictionary of encoded reference sequences with their class a key.\n -Output: a vector of class predictions in the same order as the input test encodings.\n - -DISCLAIMER: Currently every test encoding given to this function will be classified to the closest class, even when the true class is not in the train encodings. -=> ALLE KLASSES EVEN VER VAN EXAMPLE => UNCLASSIFIED -""" -function cosine_predict(test_encodings::Vector, train_encodings::Dict) - predictions = Vector{String}() - for hv in test_encodings - closest_distance = Inf - match = missing - for (k, v) in train_encodings - dist = cosine_dist(hv, v) - if (dist < closest_distance) - closest_distance = dist - match = k - end - end - push!(predictions, match) - end - return predictions -end - - -### Naive bayes predictor diff --git a/src/representations.jl b/src/representations.jl index 0e8d301..b8c261e 100644 --- a/src/representations.jl +++ b/src/representations.jl @@ -11,7 +11,6 @@ function Base.show(io::IO, mime::MIME"text/plain", hv::AbstractHV) end function Base.show(io::IO, mime::MIME"text/plain", hv::Union{BinaryHV, BipolarHV}) - counts = Dict(e => count(==(e), hv) for e in unique(hv)) n = hv isa BinaryHV ? 0 : -1 # negative element println(io, "$(length(hv))-element $(typeof(hv))") return println(io, "1 / $n : $(count(hv.v)) / $(length(hv) - count(hv.v))") diff --git a/src/types.jl b/src/types.jl index 6f1b6cb..5b49c47 100644 --- a/src/types.jl +++ b/src/types.jl @@ -18,8 +18,6 @@ Every hypervector HV has the following basic functionality TODO: - [ ] SparseHV -- [ ] complex HDC -- [ ] support for different types =# # ----------------------------------------------------------------------------------- AbstractHV @@ -47,7 +45,7 @@ end function BipolarHV(; D::Integer = 10_000, - seed::Union{Number, Nothing} = nothing, + seed::Union{Integer, Nothing} = nothing, rng = MersenneTwister ) rng_instance = isnothing(seed) ? rng() : rng(seed) @@ -80,7 +78,7 @@ eldist(::Type{BipolarHV}) = 2Bernoulli(0.5) - 1 A ternary hypervector type based on the Multiply-Add-Permute (MAP) vector symbolic architecture (Gayler, 1998). -Represents a hypervector with elements in `(-1, 1)`. +Represents a hypervector with elements in `{-1, +1}`. # Extended help @@ -116,11 +114,12 @@ end LinearAlgebra.normalize!(hv::TernaryHV) = clamp!(hv.v, -1, 1) LinearAlgebra.normalize(hv::TernaryHV) = TernaryHV(clamp.(hv, -1, 1)) eldist(::Type{TernaryHV}) = 2Bernoulli(0.5) - 1 + # ------------------------------------------------------------------------------------ BinaryHV """ BinaryHV -A ternary hypervector type based on the Binary Splatter Code (BSC) vector symbolic architecture +A binary hypervector type based on the Binary Spatter Code (BSC) vector symbolic architecture (Kanerva, 1994; Kanerva, 1995; Kanerva, 1996; Kanerva, 1997). Represents a hypervector boolean elements, i.e. `(false, true)`. @@ -239,7 +238,7 @@ end # Helpers Base.copy(hv::GradedHV) = GradedHV(copy(hv.v), hv.distr) -Base.similar(hv::GradedHV) = GradedHV(; D = length(hv), distr = eldist(GradedHV)) +Base.similar(hv::GradedHV) = GradedHV(; D = length(hv), distr = hv.distr) Base.zeros(hv::GradedHV) = fill!(similar(hv.v), one(eltype(hv.v)) / 2) LinearAlgebra.normalize!(hv::GradedHV) = clamp!(hv.v, 0, 1) eldist(::Type{<:GradedHV}) = Beta(1, 1) @@ -285,8 +284,8 @@ Base.similar(hv::GradedBipolarHV) = GradedBipolarHV(; D = length(hv), distr = hv LinearAlgebra.normalize!(hv::GradedBipolarHV) = clamp!(hv.v, -1, 1) eldist(::Type{<:GradedBipolarHV}) = 2Beta(1, 1) - 1 -# Fourier Holographically Reduced Represenetations -# ------------------------------------------------ +# Fourier Holographic Reduced Representations +# -------------------------------------------- struct FHRR{T <: Complex} <: AbstractHV{T} v::Vector{T} @@ -311,7 +310,7 @@ Base.similar(hv::FHRR{<:Complex{R}}) where {R} = FHRR(exp.(2π * im .* rand(R, l """ LinearAlgebra.normalize!(hv::FHRR) -A Fourier Holographically Reduced Represenetation is normalized by +A Fourier Holographic Reduced Representation is normalized by setting the norm of each complex element to 1. """ function LinearAlgebra.normalize!(hv::FHRR) diff --git a/test/benchmarking.jl b/test/benchmarking.jl deleted file mode 100644 index e1c902c..0000000 --- a/test/benchmarking.jl +++ /dev/null @@ -1,32 +0,0 @@ -using HyperdimensionalComputing - -# get the different types -println("The time to encode a 4-letter alphabet as bipolar or binary hypervectors, respectively:") -@time bip = encode_alphabet(['A', 'C', 'T', 'G']) -@time bin = encode_alphabet(['A', 'C', 'T', 'G'], vectortype = "binary") -println() - -# benchmark multiplication -println("The time to combine two bipolar or binary hypervectors, respectively, into a new one that is highly dissimilar:") -@time multiply(bip['A'], bip['C']) -@time multiply(bin['A'], bin['C']) -println() - -# benchmark aggregation -println("The time to combine two bipolar or binary hypervectors, respectively, into a new one that is highly similar:") -@time add(bip['A'], bip['C']) -@time add(bin['A'], bin['C']) -println() - -# benchmark rotation -println("The time to rotate/permute bipolar or binary hypervectors, respectively:") -@time rotate(bip['A'], 1) -@time rotate(bin['A'], 1) -println() - -# benchmark sequence encoding -seq = "ATCGATAGCA" -println("The time to encode a 10-letter sequence as bipolar or binary hypervectors, respectively:") -@time encode_sequence(seq, bip, k = 3) -@time encode_sequence(seq, bin, k = 3) -println() From cb2912b27ddeae7ea8c392cf6f200f404b584bc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Vigil-V=C3=A1squez?= Date: Tue, 24 Mar 2026 12:25:38 +0100 Subject: [PATCH 2/2] style: format with Runic Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- docs/src/examples/introduction-to-hdc.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/src/examples/introduction-to-hdc.jl b/docs/src/examples/introduction-to-hdc.jl index 803bc59..c96e517 100644 --- a/docs/src/examples/introduction-to-hdc.jl +++ b/docs/src/examples/introduction-to-hdc.jl @@ -1,4 +1,3 @@ - # # Introduction # # Hyperdimensional Computing (HDC) is a brain-inspired computational paradigm that represents