Fix it)
static final private float Pi = (float)Math.PI;
static final private float Pi_D = Pi * 2;
static final private int Size_SC_Ac = 5000;
static final private int Size_SC_Ar = Size_SC_Ac + 1;
static final private float Sin[] = new float[Size_SC_Ar];
static final private float Cos[] = new float[Size_SC_Ar];
static final private float Pi_SC_D = Pi_D / Size_SC_Ac;
static final private int Pi_SC_D_Rem = (int)(Pi_D / Pi_SC_D);
static{
for(int i = 0; i < Size_SC_Ar; i++){
double d = i * Pi_SC_D;
Sin[i] = (float) Math.sin(d);
Cos[i] = (float) Math.cos(d);
}
}
static final public float sin(float r){
if(r < 0){
return Sin[((int)(r / Pi_SC_D) % Pi_SC_D_Rem) + Pi_SC_D_Rem];
}
else{
return Sin[(int)(r / Pi_SC_D) % Pi_SC_D_Rem];
}
}
static final public float cos(float r){
if(r < 0){
return Cos[((int)(r / Pi_SC_D) % Pi_SC_D_Rem) + Pi_SC_D_Rem];
}
else{
return Cos[(int)(r / Pi_SC_D) % Pi_SC_D_Rem];
}
}
linear progression -0.5PI..+0.5PI:
java.math 64.369 ns/op
devmaster 29.441 ns/op
icecore 13.827 ns/op
riven 11.395 ns/op
kappa 8.976 ns/op
linear progression -8PI..+8PI:
java.math 93.948 ns/op
devmaster 30.792 ns/op
icecore 14.076 ns/op
riven 11.319 ns/op
kappa 9.439 ns/op
input float[]/L1 -0.5PI..+0.5PI:
java.math 75.743 ns/op
devmaster 34.110 ns/op
icecore 23.574 ns/op
riven 3.197 ns/op
kappa 16.083 ns/op