File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -202,14 +202,12 @@ void FloatArray::clip(float max){
202202 data[n]=-max;
203203 }
204204}
205- void FloatArray::clip (float max, float newMax){
206- float scale=newMax/max;
205+ void FloatArray::clip (float min, float max){
207206 for (int n=0 ; n<size; n++){
208207 if (data[n]>max)
209208 data[n]=max;
210- else if (data[n]<-max)
211- data[n]=-max;
212- data[n]*=scale;
209+ else if (data[n]<min)
210+ data[n]=min;
213211 }
214212}
215213FloatArray FloatArray::subArray (int offset, int length){
Original file line number Diff line number Diff line change @@ -148,7 +148,7 @@ class FloatArrayTestPatch : public Patch {
148148 float clip=0.5 ;
149149 tempFa1.clip (clip);
150150 for (int n=0 ; n<size; n++){
151- assert (abs (tempFa1[n])<=clip, " clip" );
151+ assert (abs (tempFa1[n])<=clip, " clip to value " );
152152 }
153153 tempFa1.copyFrom (fa);
154154 tempFa1.scale (3 );
@@ -157,9 +157,11 @@ class FloatArrayTestPatch : public Patch {
157157 assert (abs (tempFa1[n])<=1 , " clip to 1" );
158158 }
159159 fa.scale (3 , tempFa1);
160- tempFa1.clip (0.1 , 0.5 );
160+ float min=0.1 ;
161+ float max=0.5 ;
162+ tempFa1.clip (min, max);
161163 for (int n=0 ; n<size; n++){
162- assert (abs (tempFa1[n])<=0.5 , " clip and scale " );
164+ assert (abs (tempFa1[n])<=max && abs (tempFa1[n])>=min , " clip, asymmetric " );
163165 }
164166 }
165167 // test negate
You can’t perform that action at this time.
0 commit comments