$name = $_SERVER['SCRIPT_NAME'];
$chars = preg_split('/\//', $name, -1, PREG_SPLIT_NO_EMPTY);
$me = sizeof($chars);
$file_name_execute = $chars[$me-1];
$view_all=$_REQUEST['view_all'];
$array_full =array();
$working_counter =0;
set_time_limit(0);
$f_num = $_REQUEST['f_num'];
$r_num = $_REQUEST['r_num'];
$order_max = $_REQUEST['order_max'];
$submit = $_REQUEST['submit'];
print "
";
print " ";
if (preg_match("/calculate/i",$submit)){
$power = pow(2,($f_num));
for($a=1;$a<=$r_num;$a++){
$value = "f_low_$a"; $$value = $_REQUEST[$value];
$value = "f_high_$a"; $$value = $_REQUEST[$value];
}
for($a=1;$a<=$f_num;$a++){
$value = "f_$a"; $$value = $_REQUEST[$value];
}
for($a=($f_num+1);$a<=7;$a++){
$value = "f_$a"; $$value = 0;
}
if ($f_num < 4) $num_max=15; elseif ($f_num < 5 ) $num_max=10; else $num_max=6;
# $num_max=24;
if ($f_3==0){ $o_max=0;$o_min=0;} else {$o_max=$num_max; $o_min=0;}
if ($f_4==0){ $p_max=0;$p_min=0;} else {$p_max=$num_max; $p_min=0;}
if ($f_5==0){ $q_max=0;$q_min=0;} else {$q_max=$num_max; $q_min=0;}
# if ($f_6==0){ $r_max=0;$r_min=0;} else {$r_max=$num_max; $r_min=0;}
# if ($f_7==0){ $s_max=0;$s_min=0;} else {$s_max=$num_max; $s_min=0;}
/* print "
n
m
o
p
q
r
s
Pim Frequency
Order
Low Limit
High Limit
";
#*/
# if (preg_match("/IE/i",$HTTP_USER_AGENT)){}else{
print "Working:";
# }
flush ();
$start_time = explode(' ', microtime());
$start_time = $start_time[1] + $start_time[0];
#*/
for($n=0;$n<=$num_max;$n++){
for($m=0;$m<=$num_max;$m++){
for($o=$o_min;$o<=$o_max;$o++){
for($p=$p_min;$p<=$p_max;$p++){
for($q=$q_min;$q<=$q_max;$q++){
# for($r=$r_min;$r<=$r_max;$r++){
# for($s=$s_min;$s<=$s_max;$s++){
$order = $n+$m+$o+$p+$q;#+$r+$s;
if (($order_max <1 ) || strlen ($order_max)<1 ) $order_max = 9999;
# print "ORDRE = $order, $order_max ";
if ($order > $order_max) break;
for($count=0;$count<=($power-1);$count++){
$binary = strrev(decbin($count));
# $binary = strrev($binary);
if ($binary[0]==0) $a=""; else $a ="-";
if ($binary[1]==0) $b=""; else $b ="-";
if ($binary[2]==0) $c=""; else $c ="-";
if ($binary[3]==0) $d=""; else $d ="-";
if ($binary[4]==0) $e=""; else $e ="-";
# if ($binary[5]==0) $f=""; else $f ="-";
# if ($binary[6]==0) $g=""; else $g ="-";
$equation = "$a$f_1*$n + $b$f_2*$m + $c$f_3*$o + $d$f_4*$p + $e$f_5*$q";#; + $f$f_6*$r + $g$f_7*$s";
# print "EQN: $equation , BIN:$binary ,$power ,$count, $order ";
EVAL("\$equation = $equation;");
# print "EQN: $equation ";
for($loc=1;$loc<=$r_num;$loc++){
$valuel= "f_low_$loc";
$valueh = "f_high_$loc";
$val1=$$valuel;
$val2=$$valueh;
#print "$loc, $count, BIN:$binary,$n, $m, $o,$p,$q,$r,$s,Calc:$equation,Order: $order, $val1, $val2 ";
if (($equation >= $$valuel) && ($equation < $$valueh) ){
/* print "
$a$n
$b$m
$c$o
$d$p
$e$q
$f$r
$g$s
$equation
$order
$val1
$val2
";
flush();
#*/
$a="$a$n"; EVAL("\$a = $a;");
$b="$b$m"; EVAL("\$b = $b;");
$c="$c$o"; EVAL("\$c = $c;");
$d="$d$p"; EVAL("\$d = $d;");
$e="$e$q"; EVAL("\$e = $e;");
# $f="$f$r"; EVAL("\$f = $f;");
# $g="$g$s"; EVAL("\$g = $g;");
$array_full[] = array($a,$b,$c,$d,$e,$equation,$order,$val1,$val2);
# $array_full[] = array($a,$b,$c,$d,$e,$f,$g,$equation,$order,$val1,$val2ek;
break;
#print "$loc, BIN:$binary,$n, $m, $o,$p,$q,$r,$s,Calc:$equation,Order: $order, $val1 ,$val2, ";
} //Close IF check
} //Close For Loc loop
} // Close For count binary Loop
// if (preg_match("/IE/i",$HTTP_USER_AGENT)){}else{
$working_counter = $working_counter +1;
if ( ($working_counter % 10) == 0) {echo str_pad('.',1); flush();}
if ( ($working_counter % 600) == 0) {echo str_pad(' Still Working ',1);}
if ( ($working_counter % 1800) == 0) print " ";
# }
# } //S loop
# } //R loop
} //Q loop
} //P loop
} //o loop
} //m loop
} // n loop
$end_time = explode(' ', microtime());
$total_time = $end_time[0] + $end_time[1] - $start_time;
printf(' Calculations completed in %.3f seconds. ', $total_time);
#*/
foreach ($array_full as $key => $row) {
$array_val1[$key] = $row['7'];
$array_order[$key] = $row['6'];
# $array_val1[$key] = $row['9'];
# $array_order[$key] = $row['8'];
}
# print_r($array_val1);
# print " ";
# print " ";
# print_r($array_order);
# print " ";
# print " ";
# print_r($array_full);
array_multisort($array_val1, SORT_ASC, $array_order, SORT_ASC, $array_full);
foreach ($array_full as $key => $row) {
$starting_val = -9;
# $starting_order = $row['8'];
break;
}
# $distance = 9999;
$key_counter=0;
$order_number = 1;
foreach ($array_full as $key => $row) {
$new_val = $row['7'];
# $new_order = $row['6'];
# print "$starting_val, $new_val ";
if ( ( $starting_val != $new_val) ){
$keys[$key_counter] = $key;
$key_counter= $key_counter+1;
$starting_val = $new_val;
$order_number = 1;
}else{
$order_number = $order_number+1;
# $distance = 9999;
# $starting_val = $new_val;
# $starting_order = $new_order;
}
$order_total[$key_counter-1] = $order_number;
# $distance_new = sqrt(pow(($f_1-$row['0']),2) + pow(($f_2-$row['2']),2));
# if ($distance_new < $distance){
# $distance = $distance_new;
# }
}
#*/
# print " ";
# print_r($keys);
# print " ";
# print_r($order_total);
print " ";
print "Following results provide, for each receive band, the worst case Pim order and the total number ordered calculated ";
print "
Index F1
Index F2
Index F3
Index F4
Index F5
Pim Frequency
Worst CaseOrder
Low Limit
High Limit
Number that also failed same limit range
";
/*
r
s
#*/
foreach ($keys as $key => $row) {
$line = $array_full [$row];
print "";
foreach ($line as $key_line => $row_line) {
print "$row_line ";
}
echo "".$order_total[$key]." ";
print " ";
}
print "
";
print " ";
#*/
if (preg_match ("/yes/i",$view_all)){
print " Please note that if there at least one index =0, the line will show up twice in this table ";
print "
Index F1
Index F2
Index F3
Index F4
Index F5
Pim Frequency
Order
Low Limit
High Limit
";
/*
r
s
#*/
foreach ($array_full as $key => $row) {
print "";
foreach ($row as $key_line => $row_line) {
print "$row_line ";
}
print " ";
}
print "
";
}
#*/
} //close IF Calc loop
}else{
print "Select the number of frequencies to check:";
print "";
for($num=2;$num<=5;$num++){
if($num==$f_num) $selected="selected";
else $selected="";
print " $num ";
}
print " ";
print "Select the number of receive bands to check:";
print "";
for($num=1;$num<=10;$num++){
if($num==$r_num) $selected="selected";
else $selected="";
print " $num ";
}
print " ";
print "
";
}
?>