28
28
29
29
30
30
using System ;
31
+ using System . Collections . Generic ;
32
+ using System . Collections . ObjectModel ;
31
33
32
34
33
35
namespace Litipk . ColorSharp
@@ -61,7 +63,7 @@ public class RegularMatchingFunction : AMatchingFunction
61
63
/**
62
64
* <value>Data points</value>
63
65
*/
64
- public readonly double [ ] Amplitudes ;
66
+ public readonly ReadOnlyCollection < double > Amplitudes ;
65
67
#endregion
66
68
67
69
@@ -73,12 +75,12 @@ public class RegularMatchingFunction : AMatchingFunction
73
75
* <param name="maxWaveLength">Upper boundary of the matching function's support.</param>
74
76
* <param name="amplitudes">Data points.</param>
75
77
*/
76
- public RegularMatchingFunction ( double minWaveLength , double maxWaveLength , double [ ] amplitudes )
78
+ public RegularMatchingFunction ( double minWaveLength , double maxWaveLength , IList < double > amplitudes )
77
79
{
78
80
MinWaveLength = minWaveLength ;
79
81
MaxWaveLength = maxWaveLength ;
80
- NmPerStep = ( maxWaveLength - minWaveLength ) / ( amplitudes . Length - 1 ) ;
81
- Amplitudes = amplitudes ;
82
+ NmPerStep = ( maxWaveLength - minWaveLength ) / ( amplitudes . Count - 1 ) ;
83
+ Amplitudes = new ReadOnlyCollection < double > ( amplitudes ) ;
82
84
}
83
85
84
86
/**
@@ -87,12 +89,12 @@ public RegularMatchingFunction (double minWaveLength, double maxWaveLength, doub
87
89
* <param name="amplitudes">Data points.</param>
88
90
* <param name="nmPerStep">Number of nanometers between data points.</param>
89
91
*/
90
- public RegularMatchingFunction ( double minWaveLength , double [ ] amplitudes , double nmPerStep )
92
+ public RegularMatchingFunction ( double minWaveLength , IList < double > amplitudes , double nmPerStep )
91
93
{
92
94
NmPerStep = nmPerStep ;
93
95
MinWaveLength = minWaveLength ;
94
- MaxWaveLength = minWaveLength + nmPerStep * ( amplitudes . Length - 1 ) ;
95
- Amplitudes = amplitudes ;
96
+ MaxWaveLength = minWaveLength + nmPerStep * ( amplitudes . Count - 1 ) ;
97
+ Amplitudes = new ReadOnlyCollection < double > ( amplitudes ) ;
96
98
}
97
99
98
100
#endregion
@@ -108,7 +110,7 @@ public override double EvaluateAt (double waveLength)
108
110
if ( waveLength >= MinWaveLength && waveLength <= MaxWaveLength ) {
109
111
double dblIndex = ( waveLength - MinWaveLength ) / NmPerStep ;
110
112
double floorIndex = Math . Floor ( dblIndex ) ;
111
- uint uIndex = ( uint ) floorIndex ;
113
+ int uIndex = ( int ) floorIndex ;
112
114
113
115
if ( dblIndex - floorIndex <= 2 * double . Epsilon ) {
114
116
return Amplitudes [ uIndex ] ;
@@ -144,7 +146,7 @@ public override double GetSupportMaxValue ()
144
146
*/
145
147
public override int GetNumberOfDataPoints ( )
146
148
{
147
- return Amplitudes . Length ;
149
+ return Amplitudes . Count ;
148
150
}
149
151
150
152
#endregion
0 commit comments