VectorWave API Reference
Module Structure
VectorWave is organized into three Maven modules:
vectorwave-core
Package: com.morphiqlabs.wavelet
- Core wavelet transforms and algorithms
- Scalar implementations with cache optimization
- Zero runtime dependencies
- Works on any Java 25+ platform
vectorwave-extensions
Package: com.morphiqlabs.wavelet.extensions
- SIMD optimizations via Vector API
- Structured concurrency support
- Automatic service discovery
- 2-5x performance improvement
vectorwave-examples
Package: com.morphiqlabs
- Demonstrations and benchmarks
- Usage examples
- Performance tests
Quick Reference
MODWT Transform (Primary)
// Basic transform - works with ANY signal length
MODWTTransform transform = new MODWTTransform(Daubechies.DB4, PaddingStrategies.PERIODIC);
double[] signal = new double[777]; // Any length!
MODWTResult result = transform.forward(signal);
double[] reconstructed = transform.inverse(result);
// Batch processing with automatic SIMD
double[][] signals = new double[32][1000];
MODWTResult[] results = transform.forwardBatch(signals);
// Multi-level decomposition
MultiLevelMODWTTransform mlTransform = new MultiLevelMODWTTransform(
wavelet, PaddingStrategies.PERIODIC);
MultiLevelMODWTResult mlResult = mlTransform.decompose(signal, levels);
double[] reconstructed = mlTransform.reconstruct(mlResult);
SWT (Stationary Wavelet Transform)
// SWT adapter with familiar interface
VectorWaveSwtAdapter swt = new VectorWaveSwtAdapter(Daubechies.DB4, PaddingStrategies.PERIODIC);
// Forward transform with mutable results
MutableMultiLevelMODWTResult result = swt.forward(signal, 4);
// Apply thresholding for denoising
swt.applyUniversalThreshold(result, true); // soft thresholding
double[] denoised = swt.inverse(result);
// Convenience denoising method
double[] clean = swt.denoise(noisySignal, 4, -1, true);
// Extract specific frequency bands
double[] highFreq = swt.extractLevel(signal, 4, 1);
CWT Transform
// Basic CWT analysis
CWTTransform cwt = new CWTTransform(new MorletWavelet());
double[] scales = {1.0, 2.0, 4.0, 8.0, 16.0};
CWTResult result = cwt.analyze(signal, scales);
// Complex analysis with phase information
ComplexCWTResult complexResult = cwt.analyzeComplex(signal, scales);
double[][] magnitude = complexResult.getMagnitude();
double[][] phase = complexResult.getPhase();
// Standard (pycwt-style) coefficients for reconstruction and analysis
MorletWavelet morlet = new MorletWavelet();
double[] fineScales = ScaleSpace.logarithmic(0.125, 64.0, 48);
ComplexNumber[][] standard = StandardCWT.computeStandardComplex(signal, fineScales, morlet);
double[][] real = new double[standard.length][signal.length];
double[][] imag = new double[standard.length][signal.length];
for (int s = 0; s < standard.length; s++) {
for (int t = 0; t < signal.length; t++) {
real[s][t] = standard[s][t].real();
imag[s][t] = standard[s][t].imag();
}
}
CWTResult standardResult = new CWTResult(new ComplexMatrix(real, imag), null, fineScales, morlet);
double[] reconstructed = new InverseCWT(morlet).reconstruct(standardResult);
Parallel CWT Transform (Extensions)
try (ParallelCWTTransform parallel = new ParallelCWTTransform.Builder()
.wavelet(new RickerWavelet())
.cwtConfig(CWTConfig.defaultConfig())
.parallelConfig(ParallelConfig.auto())
.build()) {
double[] scales = ScaleSpace.logarithmic(1.0, 64.0, 48);
CWTResult parallelResult = parallel.analyze(signal, scales);
ParallelConfig.ExecutionStats stats = parallel.getStats();
System.out.println("Parallel runs: " + stats.parallelExecutions());
ComplexCWTResult complex = parallel.analyzeComplex(signal, scales);
double[][] magnitude = complex.getMagnitude();
double[][] phase = complex.getPhase();
}
Streaming Processing
// Real-time streaming with arbitrary block sizes
MODWTStreamingDenoiser denoiser = new MODWTStreamingDenoiser.Builder()
.wavelet(Daubechies.DB4)
.bufferSize(480) // 10ms at 48kHz - no padding needed!
.thresholdMethod(ThresholdMethod.UNIVERSAL)
.build();
// Process continuous stream
for (double[] chunk : audioStream) {
double[] denoised = denoiser.denoise(chunk);
}
Wavelet Registry
// Discover available wavelets - type-safe enum approach
Set<WaveletName> available = WaveletRegistry.getAvailableWavelets();
List<WaveletName> orthogonal = WaveletRegistry.getOrthogonalWavelets();
List<WaveletName> continuous = WaveletRegistry.getContinuousWavelets();
// Get wavelets using enum - compile-time type safety!
Wavelet db4 = WaveletRegistry.getWavelet(WaveletName.DB4);
Wavelet morlet = WaveletRegistry.getWavelet(WaveletName.MORLET);
Wavelet haar = WaveletRegistry.getWavelet(WaveletName.HAAR);
// Get wavelets by family
List<WaveletName> daubechies = WaveletRegistry.getDaubechiesWavelets();
List<WaveletName> symlets = WaveletRegistry.getSymletWavelets();
List<WaveletName> coiflets = WaveletRegistry.getCoifletWavelets();
// Type-safe wavelet selection
WaveletName selected = WaveletName.DB4; // IDE autocomplete shows all options
if (WaveletRegistry.hasWavelet(selected)) {
Wavelet wavelet = WaveletRegistry.getWavelet(selected);
}
Core Classes
MODWT Package (com.morphiqlabs.wavelet.modwt)
MODWTTransform
forward(double[] signal)- Forward transforminverse(MODWTResult result)- Inverse transformforwardBatch(double[][] signals)- Batch processinginverseBatch(MODWTResult[] results)- Batch reconstructiongetPerformanceInfo()- Platform capabilitiesestimateProcessingTime(int length)- Performance estimation
MODWTResult
create(double[] approx, double[] detail)- Factory methodapproximationCoeffs()- Get approximation coefficientsdetailCoeffs()- Get detail coefficientsgetSignalLength()- Original signal lengthisValid()- Check for finite values
MultiLevelMODWTTransform
decompose(double[] signal)- Automatic max levelsdecompose(double[] signal, int levels)- Specify levelsdecomposeMutable(double[] signal, int levels)- Returns mutable resultreconstruct(MultiLevelMODWTResult result)- Full reconstructionreconstructFromLevel(result, int level)- Partial reconstructiongetMaximumLevels(int signalLength)- Calculate max levels
MutableMultiLevelMODWTResult
getMutableDetailCoeffs(int level)- Direct coefficient accessgetMutableApproximationCoeffs()- Mutable approximationapplyThreshold(int level, double threshold, boolean soft)- ThresholdingclearCaches()- Clear cached computations after modificationtoImmutable()- Create immutable copyisValid()- Check for NaN/Inf
SWT Package (com.morphiqlabs.wavelet.swt)
VectorWaveSwtAdapter
forward(double[] signal)- Max levels decompositionforward(double[] signal, int levels)- Specified levelsinverse(MutableMultiLevelMODWTResult result)- ReconstructionapplyThreshold(result, level, threshold, soft)- Level thresholdingapplyUniversalThreshold(result, soft)- Auto thresholddenoise(signal, levels)- Universal threshold denoisingdenoise(signal, levels, threshold, soft)- Custom thresholdextractLevel(signal, levels, targetLevel)- Band extraction
CWT Package (com.morphiqlabs.wavelet.cwt)
CWTTransform
analyze(double[] signal, double[] scales)- Basic analysisanalyzeComplex(double[] signal, double[] scales)- Complex analysis
Wavelets
MorletWavelet- Time-frequency analysisPaulWavelet(int order)- Financial crash detectionGaussianDerivativeWavelet(int derivative)- Edge detection
Wavelet Families
Orthogonal Wavelets
new Haar() // Simplest wavelet
Daubechies.DB2 // 2 vanishing moments
Daubechies.DB4 // 4 vanishing moments (popular)
Daubechies.DB8 // 8 vanishing moments
Symlet.SYM4 // Nearly symmetric
Coiflet.COIF2 // Both functions have vanishing moments
Biorthogonal Wavelets
BiorthogonalSpline.BIOR1_3 // CDF 1,3 wavelet
Continuous Wavelets
new MorletWavelet() // Complex Morlet
new PaulWavelet(4) // Paul order 4
new GaussianDerivativeWavelet(2) // Mexican Hat (2nd derivative)
Performance Features
Automatic Optimization
- SIMD Detection: Automatically uses Vector API when available
- Platform Adaptive: x86 (AVX2/AVX512), ARM (NEON)
- Scalar Fallback: Graceful degradation on unsupported platforms
- Batch Optimization: 2-4x speedup for multiple signals
Performance Monitoring
// Check platform capabilities
WaveletOperations.PerformanceInfo info = WaveletOperations.getPerformanceInfo();
System.out.println(info.description());
// Output: "Vectorized operations enabled on aarch64 with S_128_BIT"
// Estimate processing time
MODWTTransform.ProcessingEstimate estimate = transform.estimateProcessingTime(signalLength);
System.out.println(estimate.description());
Configuration
Padding Strategies
PaddingStrategies.PERIODIC- Circular/periodic boundary (recommended for MODWT)PaddingStrategies.ZERO- Zero padding at boundaries (CWT always uses zero padding to stay aligned with the PyWavelets reference implementation.)
Streaming Configuration
MODWTStreamingDenoiser.Builder()
.wavelet(Daubechies.DB4)
.paddingStrategy(PaddingStrategies.PERIODIC)
.bufferSize(1024) // Any size - no power-of-2 restriction
.thresholdMethod(ThresholdMethod.UNIVERSAL)
.thresholdType(ThresholdType.SOFT)
.build();
Error Handling
Exception Types
InvalidSignalException- Invalid input signalsInvalidArgumentException- Invalid parametersInvalidConfigurationException- Invalid configurationWaveletTransformException- Transform-specific errors
Common Patterns
try {
MODWTResult result = transform.forward(signal);
} catch (InvalidSignalException e) {
// Handle invalid signal (NaN, Infinity, empty)
ErrorContext context = e.getErrorContext();
System.err.println("Signal error: " + context.getDescription());
}
Key Differences from Standard Wavelet Libraries
- No Power-of-2 Restriction: MODWT works with signals of any length
- Shift Invariance: MODWT provides translation-invariant analysis
- Automatic SIMD: Platform-specific optimizations without manual configuration
- Modern Java: Java 25+ with optional Vector API integration (Java 25 preview)
Requirements
Core Module
- Java 25+ - Required for modern language features
- No runtime dependencies - Pure Java implementation
- Maven: Add
vectorwave-coredependency
Extensions Module (Optional)
- Java 25+ with Vector API support
- Compilation:
--add-modules jdk.incubator.vector --enable-preview - Runtime: Automatic detection and fallback
- Maven: Add
vectorwave-extensionsas runtime dependency
Recommended Setup
<dependencies>
<dependency>
<groupId>com.morphiqlabs</groupId>
<artifactId>vectorwave-core</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.morphiqlabs</groupId>
<artifactId>vectorwave-extensions</artifactId>
<version>1.0.0</version>
<scope>runtime</scope>
</dependency>
</dependencies>