Skip to content

Add VectorElement: scalar view of a RealVector element#61

Merged
rbouckaert merged 2 commits intomasterfrom
vector-element
Apr 8, 2026
Merged

Add VectorElement: scalar view of a RealVector element#61
rbouckaert merged 2 commits intomasterfrom
vector-element

Conversation

@alexeid
Copy link
Copy Markdown
Member

@alexeid alexeid commented Apr 7, 2026

Summary

  • Adds VectorElement<D extends Real> to beast.base.spec.inference.parameter — a CalculationNode that implements RealScalar<D> by delegating to a single element of a RealVector<D>
  • Registers VectorElement in module-info.java for BEAST's class loader
  • Includes tests for value access, domain inheritance, vector mutation tracking, bounds checking, and initByName construction

Motivation

This enables the "vector + slice" pattern: create a single RealVectorParam state node and use VectorElement to provide scalar views wherever RealScalar is required (e.g., per-partition SiteModel.mutationRate).

This replaces the inverse pattern of creating individual scalar parameters and joining them with Concatenate, and serves as the beast3 successor to beastlabs.core.util.Slice with proper spec type support.

Fixes #60

Test plan

  • VectorElementTest — 5 tests covering get, domain, mutation tracking, bounds, initByName

🤖 Generated with Claude Code

alexeid added 2 commits April 6, 2026 21:37
Add optional shape input to KeyVectorParam that allows flat vector
storage to be interpreted as a multi-dimensional array. When shape
is set (e.g. shape="3 4" for a 3x4 matrix), rank() and shape()
reflect the tensor dimensions, and get(int... idx) supports
multi-dimensional indexing via row-major strides.

Wired up in both RealVectorParam and IntVectorParam. Backward
compatible: vectors without shape behave exactly as before.

Replaces the deprecated minordimension on Parameter.Base.
Provides a RealScalar view of a single element in a RealVector,
enabling vector parameters to be used wherever a scalar is required
(e.g. per-partition mutation rates from a single vector state node).
alexeid added a commit to LinguaPhylo/LPhyBeast that referenced this pull request Apr 7, 2026
Replace the Concatenate+Slice pattern with single RealVectorParam +
VectorElement for element access. This is a cleaner design: create the
whole vector, then slice to get parts (instead of building parts and
joining them).

Changes:
- Add VectorSlice for multi-element range slicing (array[0:5])
- Add WeightedDirichletValueToBEAST (RealVectorParam + delta exchange)
- Move SliceDoubleArrayToBEAST from feast to core
- Replace all Slice usage with VectorElement in BEASTContext
- Replace ScalarSlice with VectorElement in ExpMarkovChainToBEAST
- Use spec DeltaExchangeOperator instead of deprecated Bactrian version
- Simplify FeastValueHandler (remove Concatenate methods)
- Delete: ScalarSlice, SliceFactory, feast DoubleArrayValueToBEAST
- Delete lphybeast/lib/ (25 unused system-scope JARs)
- Update BEAST3-MIGRATION.md Phase 2/3 status

Depends on beast3 VectorElement (CompEvol/beast3#61).
@rbouckaert rbouckaert merged commit adf19ef into master Apr 8, 2026
1 check passed
@alexeid alexeid deleted the vector-element branch April 9, 2026 13:29
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.

Add VectorElement: scalar view of a RealVector element

2 participants