-
Notifications
You must be signed in to change notification settings - Fork 6
/
Legendre.cs
126 lines (115 loc) · 4.99 KB
/
Legendre.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
///
/// SharpWave - A refactored port of JWave
/// https://github.com/graetz23/JWave
///
/// MIT License
///
/// Copyright (c) 2020-2024 Christian ([email protected])
///
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in all
/// copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
/// SOFTWARE.
///
using System;
namespace SharpWave
{
///<summary>
/// Orthonormal Legendre wavelet transform of two coefficients based on the
/// Legendre polynomial. However the smallest Legendre wavelet is a mirrored
/// Haar Wavelet.
///</summary>
///<remarks>
/// Christian ([email protected]) 08.06.2010 09:32:08
///</remarks>
public class Legendre1 : Wavelet {
///<summary>
/// Constructor calculating analytically the orthogonal Legendre wavelet of
/// two coefficients, orthonormalizes them (normed, due to ||*||2 euclidean
/// norm), and builds the scaling coefficients, and the orthonormal bases
/// afterwards; .
///</summary>
///<remarks>
/// Christian ([email protected]) 08.06.2010 09:32:08
///</remarks>
public Legendre1( ) : base( "Legendre 1", 2, 2 ) {
double sqrt02 = Math.Sqrt( 2.0 ); // 1.4142135623730951
// these coefficients are already orthonormal
_scalingDeCom[ 0 ] = -1.0 / sqrt02; // h0
_scalingDeCom[ 1 ] = -1.0 / sqrt02; // h1
_buildBaseSystem( ); // build all other from low pass decomposition
} // Legendre1
} // class
///<summary>
/// Orthonormal Legendre wavelet transform of four coefficients based on the
/// Legendre polynomial; normed, due to ||*||2 euclidean norm..
///</summary>
///<remarks>
/// Christian ([email protected]) 03.06.2010 21:19:04
/// TODO NOT working for odd values; recheck coefficients ..
///</remarks>
public class Legendre2 : Wavelet {
///<summary>
/// Constructor calculating analytically the orthogonal Legendre wavelet of
/// four coefficients, orthonormalizes them (normed, due to ||*||2
/// euclidean norm), and builds the scaling coefficients, and the
/// orthonormal bases afterwards; .
///</summary>
///<remarks>
/// Christian ([email protected]) 03.06.2010 21:19:04
///</remarks>
public Legendre2( ) : base( "Legendre 2", 4, 2 ) {
double sqrt02 = Math.Sqrt( 2.0 ); // 1.4142135623730951
// these coefficients are already orthonormal
_scalingDeCom[ 0 ] = ( -5.0 / 8.0 ) / sqrt02; // s0
_scalingDeCom[ 1 ] = ( -3.0 / 8.0 ) / sqrt02; // s1
_scalingDeCom[ 2 ] = ( -3.0 / 8.0 ) / sqrt02; // s2
_scalingDeCom[ 3 ] = ( -5.0 / 8.0 ) / sqrt02; // s3
_buildBaseSystem( ); // build all other from low pass decomposition
} // Legendre2
} // class
///<summary>
/// Orthonormal Legendre wavelet transform of six coefficients based on the
/// Legendre polynomial. However the smallest Legendre wavelet is a mirrored
/// Haar Wavelet.
///</summary>
///<remarks>
/// Christian ([email protected]) 03.06.2010 22:04:35
/// TODO NOT working for odd values; recheck coefficients ..
///</remarks>
public class Legendre3 : Wavelet {
///<summary>
/// Constructor calculating analytically the orthogonal Legendre wavelet of
/// six coefficients, orthonormalizes them (normed, due to ||*||2 euclidean
/// norm), and builds the scaling coefficients, and the orthonormal bases
/// afterwards; .
///</summary>
///<remarks>
/// Christian ([email protected]) 03.06.2010 22:04:35
///</remarks>
public Legendre3( ) : base( "Legendre 3", 6, 2 ) {
double sqrt02 = Math.Sqrt( 2.0 ); // 1.4142135623730951
// these coefficients are already orthonormal
_scalingDeCom[ 0 ] = ( -63.0 / 128.0 ) / sqrt02; // h0
_scalingDeCom[ 1 ] = ( -35.0 / 128.0 ) / sqrt02; // h1
_scalingDeCom[ 2 ] = ( -30.0 / 128.0 ) / sqrt02; // h2
_scalingDeCom[ 3 ] = ( -30.0 / 128.0 ) / sqrt02; // h3
_scalingDeCom[ 4 ] = ( -35.0 / 128.0 ) / sqrt02; // h4
_scalingDeCom[ 5 ] = ( -63.0 / 128.0 ) / sqrt02; // h5
_buildBaseSystem( ); // build all other from low pass decomposition
} // Legendre3
} // class
} // namespace