2828
2929
3030using System ;
31+ using System . Collections . Generic ;
32+ using System . Collections . ObjectModel ;
3133
3234
3335namespace Litipk . ColorSharp
@@ -61,7 +63,7 @@ public class RegularMatchingFunction : AMatchingFunction
6163 /**
6264 * <value>Data points</value>
6365 */
64- public readonly double [ ] Amplitudes ;
66+ public readonly ReadOnlyCollection < double > Amplitudes ;
6567 #endregion
6668
6769
@@ -73,12 +75,12 @@ public class RegularMatchingFunction : AMatchingFunction
7375 * <param name="maxWaveLength">Upper boundary of the matching function's support.</param>
7476 * <param name="amplitudes">Data points.</param>
7577 */
76- public RegularMatchingFunction ( double minWaveLength , double maxWaveLength , double [ ] amplitudes )
78+ public RegularMatchingFunction ( double minWaveLength , double maxWaveLength , IList < double > amplitudes )
7779 {
7880 MinWaveLength = minWaveLength ;
7981 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 ) ;
8284 }
8385
8486 /**
@@ -87,12 +89,12 @@ public RegularMatchingFunction (double minWaveLength, double maxWaveLength, doub
8789 * <param name="amplitudes">Data points.</param>
8890 * <param name="nmPerStep">Number of nanometers between data points.</param>
8991 */
90- public RegularMatchingFunction ( double minWaveLength , double [ ] amplitudes , double nmPerStep )
92+ public RegularMatchingFunction ( double minWaveLength , IList < double > amplitudes , double nmPerStep )
9193 {
9294 NmPerStep = nmPerStep ;
9395 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 ) ;
9698 }
9799
98100 #endregion
@@ -108,7 +110,7 @@ public override double EvaluateAt (double waveLength)
108110 if ( waveLength >= MinWaveLength && waveLength <= MaxWaveLength ) {
109111 double dblIndex = ( waveLength - MinWaveLength ) / NmPerStep ;
110112 double floorIndex = Math . Floor ( dblIndex ) ;
111- uint uIndex = ( uint ) floorIndex ;
113+ int uIndex = ( int ) floorIndex ;
112114
113115 if ( dblIndex - floorIndex <= 2 * double . Epsilon ) {
114116 return Amplitudes [ uIndex ] ;
@@ -144,7 +146,7 @@ public override double GetSupportMaxValue ()
144146 */
145147 public override int GetNumberOfDataPoints ( )
146148 {
147- return Amplitudes . Length ;
149+ return Amplitudes . Count ;
148150 }
149151
150152 #endregion
0 commit comments