VectorWave Developer Guide
Overview
This guide provides essential information for developers working with or contributing to VectorWave.
Build Requirements
- Java 25 or later (must include jdk.incubator.vector module)
- Maven 3.6+
- Git for version control
Java Version Notes
- Compilation: Requires Java 25+ with Vector API module
- Runtime: Vector API is optional (graceful fallback to scalar implementation)
- Structured Concurrency: Uses preview features (requires
--enable-preview)
Building the Project
# Clean build
mvn clean compile
# Run tests
mvn test
# Build with all tests
mvn clean install
# Run specific test
mvn test -Dtest=MODWTTransformTest
# Generate documentation
mvn javadoc:javadoc
Code Style and Conventions
General Guidelines
- Follow existing patterns: When modifying code, match the existing style
- Use existing libraries: Check if functionality exists before adding dependencies
- Prefer composition over inheritance: Use interfaces and composition
- Immutable objects: Prefer immutable data structures where possible
Suppressing Warnings
When using try-with-resources with auto-closeable resources that may throw InterruptedException:
@Test
@SuppressWarnings("try") // close() may throw InterruptedException
void testMethod() throws Exception {
try (StreamingResource resource = new StreamingResource()) {
// Test code
}
}
For explicit close() calls within try-with-resources:
@SuppressWarnings({"resource", "try"}) // Explicit close needed, may throw InterruptedException
Testing Guidelines
Test Structure
@Test
void testFeatureName() {
// Given - setup test data
double[] signal = {1, 2, 3, 4, 5, 6, 7}; // MODWT works with any length!
MODWTTransform transform = new MODWTTransform(new Haar(), PaddingStrategies.PERIODIC);
// When - execute operation
MODWTResult result = transform.forward(signal);
// Then - verify results
assertNotNull(result);
assertEquals(signal.length, result.approximationCoeffs().length);
assertEquals(signal.length, result.detailCoeffs().length);
}
Performance Tests
- Use
@Disabledannotation for performance tests - Include warmup iterations
- Report statistics (min, max, average, standard deviation)
Common Tasks
Adding a New Wavelet
- Implement the appropriate interface (
OrthogonalWavelet,BiorthogonalWavelet, orContinuousWavelet) - Register in
WaveletRegistry - Add comprehensive tests
- Update documentation
Optimizing Performance
- Check Vector API availability: Use
VectorOps.isVectorApiSupported() - Validate signal lengths: Use power-of-2 for best performance
- Use memory pools: For repeated operations
- Profile first: Use JMH benchmarks before optimizing
Biorthogonal Wavelets
Phase Compensation
Biorthogonal wavelets include automatic phase compensation to correct for inherent circular shifts:
- Perfect reconstruction for simple signals (constant, sequential)
- Small reconstruction errors for complex signals (normal behavior)
- Best results with PERIODIC padding strategy
Expected Behavior
// Perfect reconstruction
double[] constant = {1, 1, 1, 1}; // RMSE = 0
// Small errors expected
double[] random = generateRandom(); // RMSE ≈ 1.2
double[] sine = generateSine(); // RMSE ≈ 0.2
Memory Management
Memory Pool Usage
MemoryPool pool = new MemoryPool();
pool.setMaxArraysPerSize(10);
try {
// Borrow arrays for MODWT operations
double[] signal = pool.borrowArray(1777); // Any size!
MODWTTransform transform = new MODWTTransform(wavelet, PaddingStrategies.PERIODIC);
MODWTResult result = transform.forward(signal);
// Operations...
} finally {
pool.returnArray(signal);
}
Thread-Local Cleanup
In server applications or thread pools:
try {
BatchSIMDTransform.haarBatchTransformSIMD(signals, approx, detail);
} finally {
BatchSIMDTransform.cleanupThreadLocals();
}
Debugging Tips
Performance Issues
- Check Vector API is enabled:
--add-modules jdk.incubator.vector - Verify signal length is power-of-2
- Use appropriate wavelet for signal type
- Enable JVM logging:
-Xlog:compilation
Accuracy Issues
- Check padding strategy compatibility
- Verify coefficient normalization
- Test with known signals first
- Compare with reference implementations
Contributing
Pull Request Process
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Write tests for new functionality
- Ensure all tests pass:
mvn test - Update documentation
- Submit pull request with clear description
Commit Messages
Follow conventional commits:
feat:New featurefix:Bug fixdocs:Documentation changestest:Test additions/modificationsperf:Performance improvementsrefactor:Code refactoring
Resources
SIMD Integration (Extensions)
SIMD/Vector API acceleration is part of the optional vectorwave-extensions module (Java 25 + incubator). The core module targets Java 25 scalar portability. To develop with SIMD:
mvn -q -pl vectorwave-extensions -am test \
-DargLine="--add-modules jdk.incubator.vector --enable-preview"