]> git.imager.perl.org - imager.git/blobdiff - regmach.c
most numeric parameters to the XS implementation now throw an exception if supplied...
[imager.git] / regmach.c
index 02ea5e3c7f68757452d44e1902dd6f238acada6c..64783432d3192cc37b31a702603e9b784070963d 100644 (file)
--- a/regmach.c
+++ b/regmach.c
@@ -1,5 +1,6 @@
 #include "regmach.h"
 #include <float.h>
 #include "regmach.h"
 #include <float.h>
+#include "imageri.h"
 
 /*#define DEBUG*/
 #ifdef DEBUG
 
 /*#define DEBUG*/
 #ifdef DEBUG
@@ -65,7 +66,7 @@ static double hsv_sat(i_color color) {
     return 0;
   }
   else {
     return 0;
   }
   else {
-    int temp = i_min(i_max(color.rgb.r, color.rgb.g), color.rgb.b);
+    int temp = i_min(i_min(color.rgb.r, color.rgb.g), color.rgb.b);
     return (value - temp) / (double)value;
   }
 }
     return (value - temp) / (double)value;
   }
 }
@@ -167,7 +168,7 @@ static i_color make_rgb(int r, int g, int b, int a) {
    It isn't currently used for inequalities 
 */
 
    It isn't currently used for inequalities 
 */
 
-#define n_epsilon(x, y) (abs(x)+abs(y))*0.001
+#define n_epsilon(x, y) (fabs(x)+fabs(y))*0.001
 static i_color bcol = {{ 0 }};
 
 i_color i_rm_run(struct rm_op codes[], size_t code_count, 
 static i_color bcol = {{ 0 }};
 
 i_color i_rm_run(struct rm_op codes[], size_t code_count, 
@@ -195,14 +196,14 @@ i_color i_rm_run(struct rm_op codes[], size_t code_count,
       break;
       
     case rbc_div:
       break;
       
     case rbc_div:
-      if (abs(nb) < 1e-10)
+      if (fabs(nb) < 1e-10)
        nout = 1e10;
       else
        nout = na / nb;
       break;
       
     case rbc_mod:
        nout = 1e10;
       else
        nout = na / nb;
       break;
       
     case rbc_mod:
-      if (abs(nb) > 1e-10) {
+      if (fabs(nb) > 1e-10) {
        nout = fmod(na, nb);
       }
       else {
        nout = fmod(na, nb);
       }
       else {
@@ -342,11 +343,11 @@ i_color i_rm_run(struct rm_op codes[], size_t code_count,
       break;
 
     case rbc_eq:
       break;
 
     case rbc_eq:
-      nout = abs(na-nb) <= n_epsilon(na,nb);
+      nout = fabs(na-nb) <= n_epsilon(na,nb);
       break;
 
     case rbc_ne:
       break;
 
     case rbc_ne:
-      nout = abs(na-nb) > n_epsilon(na,nb);
+      nout = fabs(na-nb) > n_epsilon(na,nb);
       break;
 
     case rbc_and:
       break;
 
     case rbc_and:
@@ -362,7 +363,7 @@ i_color i_rm_run(struct rm_op codes[], size_t code_count,
       break;
 
     case rbc_abs:
       break;
 
     case rbc_abs:
-      nout = abs(na);
+      nout = fabs(na);
       break;
 
     case rbc_ret:
       break;
 
     case rbc_ret:
@@ -421,9 +422,14 @@ i_color i_rm_run(struct rm_op codes[], size_t code_count,
       break;
 
     case rbc_print:
       break;
 
     case rbc_print:
+      nout = na;
       printf("r%d is %g\n", codes->ra, na);
       break;
 
       printf("r%d is %g\n", codes->ra, na);
       break;
 
+    case rbc_det:
+      nout = na*nd-nb*nc;
+      break;
+
     default:
       /*croak("bad opcode"); */
       printf("bad op %d\n", codes->code);
     default:
       /*croak("bad opcode"); */
       printf("bad op %d\n", codes->code);