]> www.ginac.de Git - cln.git/blob - src/real/elem/cl_R_mul.cc
Initial revision
[cln.git] / src / real / elem / cl_R_mul.cc
1 // binary operator *
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cl_real.h"
8
9
10 // Implementation.
11
12 #include "cl_R.h"
13 #include "cl_rational.h"
14 #include "cl_RA.h"
15 #include "cl_integer.h"
16 #include "cl_I.h"
17 #include "cl_F.h"
18 #include "cl_sfloat.h"
19 #include "cl_SF.h"
20 #include "cl_ffloat.h"
21 #include "cl_FF.h"
22 #include "cl_dfloat.h"
23 #include "cl_DF.h"
24 #include "cl_lfloat.h"
25 #include "cl_LF.h"
26 #include "cl_N.h"
27
28 ALL_cl_LF_OPERATIONS_SAME_PRECISION()
29
30 const cl_R operator* (const cl_R& x, const cl_R& y)
31 {
32         if (eq(x,0)) { return 0; } // 0 * y = exakte 0
33         elif (eq(y,0)) { return 0; } // x * 0 = exakte 0
34         else
35 #define mul(a,b) a*b
36         realcase6(x
37         , /* I */       
38                         realcase6(y
39                         , /* I */       return mul(x,y);
40                         , /* RT */      return mul(x,y);
41                         , /* SF */      return mul(cl_I_to_SF(x),y);
42                         , /* FF */      return mul(cl_I_to_FF(x),y);
43                         , /* DF */      return mul(cl_I_to_DF(x),y);
44                         , /* LF */      return cl_LF_I_mul(y,x);
45                         );
46         , /* RT */      
47                         realcase6(y
48                         , /* I */       return mul(x,y);
49                         , /* RT */      return mul(x,y);
50                         , /* SF */      return mul(cl_RA_to_SF(x),y);
51                         , /* FF */      return mul(cl_RA_to_FF(x),y);
52                         , /* DF */      return mul(cl_RA_to_DF(x),y);
53                         , /* LF */      return cl_LF_RA_mul(y,x);
54                         );
55         , /* SF */      
56                         realcase6(y
57                         , /* I */       return mul(x,cl_I_to_SF(y));
58                         , /* RT */      return mul(x,cl_RA_to_SF(y));
59                         , /* SF */      return mul(x,y);
60                         , /* FF */      return cl_FF_to_SF(mul(cl_SF_to_FF(x),y));
61                         , /* DF */      return cl_DF_to_SF(mul(cl_SF_to_DF(x),y));
62                         , /* LF */      return cl_LF_to_SF(mul(cl_SF_to_LF(x,LFlen0(y)),y));
63                         );
64         , /* FF */      
65                         realcase6(y
66                         , /* I */       return mul(x,cl_I_to_FF(y));
67                         , /* RT */      return mul(x,cl_RA_to_FF(y));
68                         , /* SF */      return cl_FF_to_SF(mul(x,cl_SF_to_FF(y)));
69                         , /* FF */      return mul(x,y);
70                         , /* DF */      return cl_DF_to_FF(mul(cl_FF_to_DF(x),y));
71                         , /* LF */      return cl_LF_to_FF(mul(cl_FF_to_LF(x,LFlen0(y)),y));
72                         );
73         , /* DF */      
74                         realcase6(y
75                         , /* I */       return mul(x,cl_I_to_DF(y));
76                         , /* RT */      return mul(x,cl_RA_to_DF(y));
77                         , /* SF */      return cl_DF_to_SF(mul(x,cl_SF_to_DF(y)));
78                         , /* FF */      return cl_DF_to_FF(mul(x,cl_FF_to_DF(y)));
79                         , /* DF */      return mul(x,y);
80                         , /* LF */      return cl_LF_to_DF(mul(cl_DF_to_LF(x,LFlen0(y)),y));
81                         );
82         , /* LF */      
83                         realcase6(y
84                         , /* I */       return cl_LF_I_mul(x,y);
85                         , /* RT */      return cl_LF_RA_mul(x,y);
86                         , /* SF */      return cl_LF_to_SF(mul(x,cl_SF_to_LF(y,LFlen0(x))));
87                         , /* FF */      return cl_LF_to_FF(mul(x,cl_FF_to_LF(y,LFlen0(x))));
88                         , /* DF */      return cl_LF_to_DF(mul(x,cl_DF_to_LF(y,LFlen0(x))));
89                         , /* LF */      return mul(x,y);
90                         );
91         );
92 }