/[gcl]/gcl/o/num_arith.c
ViewVC logotype

Diff of /gcl/o/num_arith.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by wfs, Sun May 6 15:59:23 2001 UTC revision 1.3 by camm, Sat Jul 20 07:10:55 2002 UTC
# Line 27  Foundation, 675 Mass Ave, Cambridge, MA Line 27  Foundation, 675 Mass Ave, Cambridge, MA
27    
28  #include "num_include.h"  #include "num_include.h"
29    
30  object fixnum_add(i,j)  object fixnum_add(int i, int j)
      int i,j;  
31  {  {
32    
33    if (i>=0)    if (i>=0)
# Line 44  object fixnum_add(i,j) Line 43  object fixnum_add(i,j)
43     }     }
44  }  }
45  /* return i - j */  /* return i - j */
46  object fixnum_sub(i,j)  object fixnum_sub(int i, int j)
      int i,j;  
47  {    {  
48    
49    if (i>=0)    if (i>=0)
# Line 62  object fixnum_sub(i,j) Line 60  object fixnum_sub(i,j)
60  }  }
61    
62  object  object
63  fixnum_times(i, j)  fixnum_times(int i, int j)
 int i, j;  
64  {  {
65    
66    MPOP(return,mulss,i,j);    MPOP(return,mulss,i,j);
67  }  }
68    
69  object  object
70  number_to_complex(x)  number_to_complex(object x)
 object x;  
71  {  {
72          object z;          object z;
73    
# Line 92  object x; Line 88  object x;
88    
89          default:          default:
90                  FEwrong_type_argument(sLnumber, x);                  FEwrong_type_argument(sLnumber, x);
91                    return(Cnil);
92          }          }
93  }  }
94    
95  object  object
96  number_plus(x, y)  number_plus(object x, object y)
 object x, y;  
97  {  {
         int i, j, k;  
98          double dx, dy;          double dx, dy;
99          object z, z1;          object z;
100          switch (type_of(x)) {          switch (type_of(x)) {
101          case t_fixnum:          case t_fixnum:
102                  switch(type_of(y)) {                  switch(type_of(y)) {
# Line 238  object x, y; Line 233  object x, y;
233    
234          default:          default:
235                  FEwrong_type_argument(sLnumber, x);                  FEwrong_type_argument(sLnumber, x);
236                    return(Cnil);
237          }          }
238  }  }
239    
240  object  object
241  one_plus(x)  one_plus(object x)
 object x;  
242  {  {
         int i;  
243          double dx;          double dx;
244          object z, z1;          object z;
245    
246                    
247          switch (type_of(x)) {          switch (type_of(x)) {
# Line 278  object x; Line 272  object x;
272                  return(z);                  return(z);
273    
274          case t_complex:          case t_complex:
         COMPLEX:  
275                  z = make_complex(one_plus(x->cmp.cmp_real), x->cmp.cmp_imag);                  z = make_complex(one_plus(x->cmp.cmp_real), x->cmp.cmp_imag);
276                  return(z);                  return(z);
277    
278          default:          default:
279                  FEwrong_type_argument(sLnumber, x);                  FEwrong_type_argument(sLnumber, x);
280                    return(Cnil);
281          }          }
282  }  }
283    
284  object  object
285  number_minus(x, y)  number_minus(object x, object y)
 object x, y;  
286  {  {
         int i, j, k;  
287          double dx, dy;          double dx, dy;
288          object z, z1;          object z;
289    
290                    
291          switch (type_of(x)) {          switch (type_of(x)) {
# Line 430  object x, y; Line 422  object x, y;
422    
423          default:          default:
424                  FEwrong_type_argument(sLnumber, x);                  FEwrong_type_argument(sLnumber, x);
425                    return(Cnil);
426          }          }
427  }  }
428    
429  object  object
430  one_minus(x)  one_minus(object x)
 object x;  
431  {  {
         int i;  
432          double dx;          double dx;
433          object z, z1;          object z;
434          switch (type_of(x)) {          switch (type_of(x)) {
435    
436          case t_fixnum:          case t_fixnum:
# Line 464  object x; Line 455  object x;
455                  return(z);                  return(z);
456    
457          case t_complex:          case t_complex:
         COMPLEX:  
458                  z = make_complex(one_minus(x->cmp.cmp_real), x->cmp.cmp_imag);                  z = make_complex(one_minus(x->cmp.cmp_real), x->cmp.cmp_imag);
459                  return(z);                  return(z);
460    
461          default:          default:
462                  FEwrong_type_argument(sLnumber, x);                  FEwrong_type_argument(sLnumber, x);
463                    return(Cnil);
464          }          }
465  }  }
466    
467  object  object
468  number_negate(x)  number_negate(object x)
 object x;  
469  {  {
470          object  z, z1;          object  z, z1;
471    
# Line 512  object x; Line 502  object x;
502    
503          default:          default:
504                  FEwrong_type_argument(sLnumber, x);                  FEwrong_type_argument(sLnumber, x);
505                    return(Cnil);
506          }          }
507  }  }
508    
509  object  object
510  number_times(x, y)  number_times(object x, object y)
 object x, y;  
511  {    {  
512          object z;          object z;
513          double dx, dy;          double dx, dy;
# Line 662  object x, y; Line 652  object x, y;
652    
653          default:          default:
654                  FEwrong_type_argument(sLnumber, x);                  FEwrong_type_argument(sLnumber, x);
655                    return(Cnil);
656          }          }
657  }  }
658    
659  object  object
660  number_divide(x, y)  number_divide(object x, object y)
 object x, y;  
661  {  {
662          object z;          object z;
663          double dx, dy;          double dx, dy;
# Line 810  object x, y; Line 800  object x, y;
800    
801          default:          default:
802                  FEwrong_type_argument(sLnumber, x);                  FEwrong_type_argument(sLnumber, x);
803                    return(Cnil);
804          }          }
805  }  }
806    
807  object  object
808  integer_divide1(x, y)  integer_divide1(object x, object y)
 object x, y;  
809  {  {
810          object q, r;          object q, r;
811    
# Line 824  object x, y; Line 814  object x, y;
814  }  }
815    
816  object  object
817  get_gcd(x, y)  get_gcd(object x, object y)
 object  x, y;  
818  {  {
819          int     i, j, k;          int     i, j, k;
820          object  q, r;          object  q, r;
# Line 869  LL: Line 858  LL:
858  }  }
859    
860   /* (+          )   */   /* (+          )   */
861  Lplus()  void
862    Lplus(void)
863  {  {
864          int i, j;          int i, j;
865                    
# Line 885  Lplus() Line 875  Lplus()
875          vs_top = vs_base+1;          vs_top = vs_base+1;
876  }  }
877    
878  Lminus()  void
879    Lminus(void)
880  {  {
881          int i, j;          int i, j;
882    
# Line 903  Lminus() Line 894  Lminus()
894          vs_top = vs_base+1;          vs_top = vs_base+1;
895  }  }
896    
897  Ltimes()  void
898    Ltimes(void)
899  {  {
900          int i, j;          int i, j;
901    
# Line 919  Ltimes() Line 911  Ltimes()
911          vs_top = vs_base+1;          vs_top = vs_base+1;
912  }  }
913    
914  Ldivide()  void
915    Ldivide(void)
916  {  {
917          int i, j;          int i, j;
918    
# Line 937  Ldivide() Line 930  Ldivide()
930          vs_top = vs_base+1;          vs_top = vs_base+1;
931  }  }
932    
933  Lone_plus()  void
934    Lone_plus(void)
935  {  {
         object x;  
936                    
937          check_arg(1);          check_arg(1);
938          check_type_number(&vs_base[0]);          check_type_number(&vs_base[0]);
939          vs_base[0] = one_plus(vs_base[0]);          vs_base[0] = one_plus(vs_base[0]);
940  }  }
941    
942  Lone_minus()  void
943    Lone_minus(void)
944  {  {
         object x;  
945                    
946          check_arg(1);          check_arg(1);
947          check_type_number(&vs_base[0]);          check_type_number(&vs_base[0]);
948          vs_base[0] = one_minus(vs_base[0]);          vs_base[0] = one_minus(vs_base[0]);
949  }  }
950    
951  Lconjugate()  void
952    Lconjugate(void)
953  {  {
954          object  c, i;          object  c, i;
955    
# Line 966  Lconjugate() Line 960  Lconjugate()
960                  i = number_negate(c->cmp.cmp_imag);                  i = number_negate(c->cmp.cmp_imag);
961                  vs_push(i);                  vs_push(i);
962                  vs_base[0] = make_complex(c->cmp.cmp_real, i);                  vs_base[0] = make_complex(c->cmp.cmp_real, i);
963                  vs_pop;                  vs_popp;
964          }          }
965  }  }
966    
967  Lgcd()  void
968    Lgcd(void)
969  {  {
970          int i, narg;          int i, narg;
971    
# Line 991  Lgcd() Line 986  Lgcd()
986          vs_top = vs_base+1;          vs_top = vs_base+1;
987  }  }
988    
989  Llcm()  void
990    Llcm(void)
991  {  {
992          object t, g;          object t, g;
993          int i, narg;          int i, narg;
# Line 1012  Llcm() Line 1008  Llcm()
1008                  g = get_gcd(vs_base[0], vs_base[i]);                  g = get_gcd(vs_base[0], vs_base[i]);
1009                  vs_push(g);                  vs_push(g);
1010                  vs_base[0] = number_divide(t, g);                  vs_base[0] = number_divide(t, g);
1011                  vs_pop;                  vs_popp;
1012                  vs_pop;                  vs_popp;
1013          }          }
1014          if (number_minusp(vs_base[0]))          if (number_minusp(vs_base[0]))
1015                  vs_base[0] = number_negate(vs_base[0]);                  vs_base[0] = number_negate(vs_base[0]);
1016          vs_top = vs_base+1;          vs_top = vs_base+1;
1017  }  }
1018    
1019  zero_divisor()  void
1020    zero_divisor(void)
1021  {  {
1022          FEerror("Zero divisor.", 0);          FEerror("Zero divisor.", 0);
1023  }  }
1024    
1025  init_num_arith()  void
1026    init_num_arith(void)
1027  {  {
1028          make_function("+", Lplus);          make_function("+", Lplus);
1029          make_function("-", Lminus);          make_function("-", Lminus);

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26