Skip to content

Commit c5ddd35

Browse files
authored
Add files via upload
1 parent d09d6f4 commit c5ddd35

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

nQuantCpp/PnnLABGAQuantizer.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -223,23 +223,19 @@ namespace PnnLABQuant
223223
return (float) _fitness;
224224
}
225225

226-
double rotateLeft(double u, double v) {
227-
auto theta = randrange(0.0, 2.0 * M_PI);
226+
static double rotateLeft(double u, double v) {
227+
auto theta = M_PI * randrange(minRatio, maxRatio);
228228
auto result = u * sin(theta) + v * cos(theta);
229-
if (result <= minRatio || result >= maxRatio) {
230-
auto range = maxRatio - minRatio;
231-
result = minRatio + fmod(abs(result) - minRatio, range);
232-
}
229+
if (result <= minRatio || result >= maxRatio)
230+
result = minRatio + fmod(minRatio, maxRatio - minRatio);
233231
return result;
234232
}
235-
236-
double rotateRight(double u, double v) {
237-
auto theta = randrange(0.0, 2.0 * M_PI);
233+
234+
static double rotateRight(double u, double v) {
235+
auto theta = M_PI * randrange(minRatio, maxRatio);
238236
auto result = u * cos(theta) - v * sin(theta);
239-
if (result <= minRatio || result >= maxRatio) {
240-
auto range = maxRatio - minRatio;
241-
result = maxRatio - fmod(abs(result) + maxRatio, range);
242-
}
237+
if (result <= minRatio || result >= maxRatio)
238+
result = maxRatio - fmod(minRatio, maxRatio - minRatio);
243239
return result;
244240
}
245241

0 commit comments

Comments
 (0)