It looks like gmp_divexact returns a resource which does not appear to be what you 
want.

You may have to access the result somehow to see if it is giving you what you expect.

Charles Killmer

---------- Original Message ----------------------------------
From: "brendan conroy" <[EMAIL PROTECTED]>
Date: Fri, 22 Mar 2002 20:18:10 +0000

Hi guys,
       Thanks for reading this. I desperatley need help with this
error. I just finished a huge project thats taken me months, my code works,
but the code it uses has an error. The project is due Monday and naturally 
enough the guy who wrote the code with the error is gone on holiday for the
weekend- typical. To be so close to having it finished is sort of
sickening..

Does anyone know what the hell Resource id's are, and why they are showing
up in my array instead of good ol fashioned numbers?

My array goes (correct)into a function looking like this :

Array ( [0] => Array ( [0] => -1 [1] => 1 [2] => 1 [3] => 1 ) [1] =>Array (
[0] => -2 [1] => 2 [2] => 2 [3] => 10 [4] => 2 ) [2] => Array ( [0] => -3[1]
=> 3 [2] => 3 [3] => 9 ) ) Array ( [0] => Array ( [0] => -4 [1] => 4 [2]=> 4
[3] => 4 ) [1] => Array ( [0] => -5 [1] => 5 [2] => 5 [3] => 5 ) [2] =>Array
( [0] => -6 [1] => 6 [2] => 6 [3] => 6 ) )

and comes out looking like this:

Array ( [0] => Array ( [0] => Resource id #5 [1] => Resource id #8 [2] =>
1[3] => 1 ) [1] => Array ( [0] => Resource id #16 [1] => Resource id #17
[2]=> 2 [3] => 10 [4] => 2 [5] => ) [2] => Array ( [0] => Resource id #24
[1]=> Resource id #25 [2] => 3 [3] => 9 ) ) Array ( [0] => Array ( [0]
=>Resource id #35 [1] => Resource id #36 [2] => 4 [3] => 4 ) [1] => Array
([0] => Resource id #44 [1] => Resource id #45 [2] => 5 [3] => 5 ) [2]
=>Array ( [0] => Resource id #53 [1] => Resource id #54 [2] => 6 [3] => 6 )
)

The Resource id #'s only go into the first two places in the end(third)
arrays.

Heres the other guys code, Im pretty sure the bug is in monic or prodmono as
they're the functions that deal with the elements that are turned into
Resource id #'s . I know this is an awful lot to ask,but like I said Im
desperate

>         <?
>         function grobmonic($g)
>         {
>
>       for($c=0;$c<count($g);$c++)
>       {
>       $g[$c]=monic($g[$c]);
>       }
>         return $g;
>         }
>         ?>
>
>
>         <?
>         function monic($p)
>         {
>       print_r($p);
>       if(gmp_cmp($p[0][0],$p[0][1])!=0)
>                       {
>                       $temp[0]=$p[0][1];
>                         $temp[1]=$p[0][0];
>                       $p=prodmono($temp,$p);
>                       }
>         return $p;
>         }
>         ?>
>
>
>
>
>         <?
>         function prodmono($p1,$p2)
>         {
>
>       for($a=0;$a<count($p2);$a++)
>                 {
>
>               $num=gmp_mul($p1[0],$p2[$a][0]);
>
>                 $den=gmp_mul($p1[1],$p2[$a][1]);
>               $g=gmp_gcd($num,$den);
>               if(gmp_cmp($g,1)!=0)
>                       {
>                       $num=gmp_divexact($num,$g);
>                       $den=gmp_divexact($den,$g);
>                       }
>               $res[$a][0]=$num;
>                 $res[$a][1]=$den;
>               $k=$i=$j=2;
>               while($i<count($p1) && $j<count($p2[$a]))
>                       {
>                       if($p1[$i]<$p2[$a][$j])
>                               {
>                               $res[$a][$k]=$p1[$i];
>                               $res[$a][$k+1]=$p1[$i+1];
>                               $i=$i+2;
>                               }
>                       elseif($p1[$i]>$p2[$a][$j])
>                               {
>                                 $res[$a][$k]=$p2[$a][$j];
>                                 $res[$a][$k+1]=$p2[$a][$j+1];
>                                 $j=$j+2;
>                                 }
>                       else
>                               {
>                                 $res[$a][$k]=$p1[$i];
>                                 $res[$a][$k+1]=$p1[$i+1]+$p2[$a][$j+1];
>                                 $i=$i+2;
>                               $j=$j+2;
>                                 }
>                       $k=$k+2;
>                       }
>               while($i<count($p1))
>                       {
>                       $res[$a][$k]=$p1[$i];
>                         $res[$a][$k+1]=$p1[$i+1];
>                         $i=$i+2;
>                       $k=$k+2;
>                         }
>                 while($j<count($p2[$a]))
>                         {
>                         $res[$a][$k]=$p2[$a][$j];
>                         $res[$a][$k+1]=$p2[$a][$j+1];
>                         $j=$j+2;
>                         $k=$k+2;
>                         }
>               }
>       return $res;
>       }
>         ?>
>


I'd really appreciate help with this


Thanks a million







_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail.
http://www.hotmail.com


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to