-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
p4p/src/java/p4p/sim/P4PSim.java
Lines 237 to 238 in 2446c44
| ////// 1. Generate Data_long_Array && UserVector2 & ////// | |
| data_long_1arr = Util.randVector(dimension, FieldSize_larger_than_bitLength_Sim, l2_norm_double_5dot49_Sim); |
p4p/src/java/p4p/util/Util.java
Lines 835 to 880 in 2446c44
| long[] data_Util_randVector = new long[dimension]; | |
| BigInteger bigF_randV = null; | |
| if(l2_norm_5dot49_Util_randVector <=0){ | |
| bigF_randV = new BigInteger(Long.toString(ZF_orderGroup_utilRandV)); | |
| } | |
| double myL2_SQUARE_util = 0.; | |
| int L_10000_util = 10000; | |
| int[] l2_positive_counter_for_10_dimension = new int[2]; | |
| for(int dimension_id = 0; dimension_id < dimension; dimension_id++) { | |
| if(l2_norm_5dot49_Util_randVector > 0) { | |
| data_Util_randVector[dimension_id] = rand.nextInt(2*L_10000_util+1)-L_10000_util; | |
| myL2_SQUARE_util += (double)((double)data_Util_randVector[dimension_id]*(double)data_Util_randVector[dimension_id]); | |
| l2_positive_counter_for_10_dimension[0]++; | |
| } | |
| else { | |
| data_Util_randVector[dimension_id] = randomBigInteger(bigF_randV).longValue(); | |
| // A random long in [0, F-1] | |
| data_Util_randVector[dimension_id] -= Math.floor((double) ZF_orderGroup_utilRandV / 2.); | |
| // Shift to Z_F | |
| l2_positive_counter_for_10_dimension[1]++; | |
| } | |
| } | |
| System.out.println("l2_positive_counter_for_10_dimension: " + Arrays.toString(l2_positive_counter_for_10_dimension)); | |
| System.out.println("data_Util_randVector: "+ Arrays.toString(data_Util_randVector)); | |
| if(l2_norm_5dot49_Util_randVector > 0) { | |
| double myL2_SQRT = Math.sqrt(myL2_SQUARE_util); | |
| double scale_Util_randV = l2_norm_5dot49_Util_randVector/myL2_SQRT; | |
| for(int i = 0; i < dimension; i++) { | |
| long data_half_M_scale = 0; | |
| long data_ADD_half = (long)(((double)data_Util_randVector[i]+0.5)*scale_Util_randV); | |
| long data_MINUS_half = (long)(((double)data_Util_randVector[i]-0.5)*scale_Util_randV); | |
| if(data_Util_randVector[i] > 0) { | |
| data_half_M_scale = data_ADD_half; | |
| data_Util_randVector[i] = data_half_M_scale; | |
| } | |
| else{ | |
| data_half_M_scale = data_MINUS_half; | |
| data_Util_randVector[i] = data_half_M_scale; | |
| } | |
| // Round to the closest long | |
| } | |
| } | |
| return data_Util_randVector; | |
| } |
Metadata
Metadata
Assignees
Labels
No labels


