~ubuntu-branches/debian/sid/genius/sid

« back to all changes in this revision

Viewing changes to src/eval.c

  • Committer: Package Import Robot
  • Author(s): Felipe Sateler
  • Date: 2014-04-07 15:43:04 UTC
  • mfrom: (1.2.6)
  • Revision ID: package-import@ubuntu.com-20140407154304-21r03zdnfc571kz0
Tags: 1.0.17-1
* Take over package from pkg-gnome
* New upstream release. Closes: #716731
* Bump standards version.
* Update Vcs fields to Git.
* Move to single-debian-patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* GENIUS Calculator
2
 
 * Copyright (C) 1997-2011 Jiri (George) Lebl
 
2
 * Copyright (C) 1997-2012 Jiri (George) Lebl
3
3
 *
4
4
 * Author: Jiri (George) Lebl
5
5
 *
124
124
                (pointer) = NULL;                                       \
125
125
        }                                                               \
126
126
}
 
127
#define GE_POP_STACKNF(thectx,pointer) { \
 
128
        if((thectx)->topstack != (gpointer *)(thectx)->stack ||         \
 
129
           ge_remove_stack_array(ctx)) {                                \
 
130
                -- (thectx)->topstack;                                  \
 
131
                *((thectx)->topstack) = NULL;                           \
 
132
                (pointer) = *(-- (thectx)->topstack);                   \
 
133
                *((thectx)->topstack) = NULL;                           \
 
134
        } else {                                                        \
 
135
                (pointer) = NULL;                                       \
 
136
        }                                                               \
 
137
}
127
138
#else /* MEM_DEBUG_FRIENDLY */
128
139
#define GE_POP_STACK(thectx,pointer,flag) { \
129
140
        if G_LIKELY ((thectx)->topstack != (gpointer *)(thectx)->stack ||       \
135
146
                (pointer) = NULL;                                       \
136
147
        }                                                               \
137
148
}
 
149
#define GE_POP_STACKNF(thectx,pointer) { \
 
150
        if G_LIKELY ((thectx)->topstack != (gpointer *)(thectx)->stack ||       \
 
151
           ge_remove_stack_array(ctx)) {                                \
 
152
                -- (thectx)->topstack;                                  \
 
153
                (pointer) = *(-- (thectx)->topstack);                   \
 
154
        } else {                                                        \
 
155
                (pointer) = NULL;                                       \
 
156
        }                                                               \
 
157
}
138
158
#endif /* MEM_DEBUG_FRIENDLY */
139
159
 
140
160
#define GE_PEEK_STACK(thectx,pointer,flag) { \
338
358
        GEL_GET_NEW_NODE (n);
339
359
        n->type = GEL_IDENTIFIER_NODE;
340
360
        n->id.id = id; 
 
361
        n->id.uninitialized = FALSE;
341
362
        n->any.next = NULL;
342
363
 
343
364
        return n;
704
725
                empty->type = GEL_IDENTIFIER_NODE;
705
726
                empty->any.next = o->any.next;
706
727
                empty->id.id = o->id.id;
 
728
                empty->id.uninitialized = o->id.uninitialized;
707
729
                break;
708
730
        case GEL_STRING_NODE:
709
731
                empty->type = GEL_STRING_NODE;
1153
1175
        return FALSE;
1154
1176
}
1155
1177
 
 
1178
/* we know we are a row matrix */
 
1179
static void
 
1180
quick_wide_expand (GelETree *n)
 
1181
{
 
1182
        GelMatrix *m;
 
1183
        int h, w, i, j;
 
1184
        GelMatrixW *nm = n->mat.matrix;
 
1185
 
 
1186
        h = 0;
 
1187
        w = 0;
 
1188
        for (i = 0; i < gel_matrixw_width (nm); i++) {
 
1189
                GelETree *et = gel_matrixw_get_index (nm, i, 0);
 
1190
                if (et == NULL) {
 
1191
                        if (h <= 0)
 
1192
                                h = 1;
 
1193
                        w++;
 
1194
                } else if (et->type == GEL_MATRIX_NODE) {
 
1195
                        if (gel_matrixw_height (et->mat.matrix) > h)
 
1196
                                h = gel_matrixw_height (et->mat.matrix);
 
1197
                        w += gel_matrixw_width (et->mat.matrix);
 
1198
                } else if (et->type != GEL_NULL_NODE) {
 
1199
                        if (h <= 0)
 
1200
                                h = 1;
 
1201
                        w++;
 
1202
                }
 
1203
        }
 
1204
 
 
1205
        gel_matrixw_make_private (nm, FALSE /* kill_type_caches */);
 
1206
 
 
1207
        m = gel_matrix_new();
 
1208
        gel_matrix_set_size(m, w, h, TRUE /* padding */);
 
1209
 
 
1210
        j = 0;
 
1211
        for (i = 0; i < gel_matrixw_width (nm); i++) {
 
1212
                GelETree *et = gel_matrixw_get_index (nm, i, 0);
 
1213
                if (et == NULL) {
 
1214
                        j++;
 
1215
                } else if (et->type == GEL_MATRIX_NODE) {
 
1216
                        int hh = gel_matrixw_height (et->mat.matrix);
 
1217
                        int ww = gel_matrixw_width (et->mat.matrix);
 
1218
                        int ii, jj;
 
1219
                        GelMatrixW *mm = et->mat.matrix;
 
1220
 
 
1221
                        gel_matrixw_make_private (mm,
 
1222
                                                  FALSE /* kill_type_caches */);
 
1223
 
 
1224
                        for (ii = 0; ii < ww; ii++) {
 
1225
                                int jjj;
 
1226
                                for (jj = 0; jj < hh; jj++) {
 
1227
                                        GelETree *e = 
 
1228
                                                gel_matrixw_get_index (mm, ii, jj);
 
1229
                                        gel_matrix_index (m, j+ii, jj) = e;
 
1230
                                        gel_matrixw_set_index (mm, ii, jj) = NULL;
 
1231
                                }
 
1232
                                jjj = 0;
 
1233
                                for (; jj < h; jj++) {
 
1234
                                        GelETree *e = 
 
1235
                                                gel_matrix_index (m, j+ii, jjj);
 
1236
                                        if (e != NULL)
 
1237
                                                gel_matrix_index (m, j+ii, jj) = gel_copynode (e);
 
1238
                                        if (++jjj >= hh)
 
1239
                                                jjj = 0;
 
1240
                                }
 
1241
                        }
 
1242
                        j += ww;
 
1243
                } else if (et->type != GEL_NULL_NODE) {
 
1244
                        int jj;
 
1245
                        gel_matrixw_set_index (nm, i, 0) = NULL;
 
1246
                        gel_matrix_index (m, j, 0) = et;
 
1247
                        for (jj = 1; jj < h; jj++) {
 
1248
                                gel_matrix_index (m, j, jj) = gel_copynode (et);
 
1249
                        }
 
1250
                        j++;
 
1251
                }
 
1252
        }
 
1253
 
 
1254
        freetree_full (n, TRUE, FALSE);
 
1255
 
 
1256
        n->type = GEL_MATRIX_NODE;
 
1257
        n->mat.matrix = gel_matrixw_new_with_matrix (m);
 
1258
        n->mat.quoted = FALSE;
 
1259
}
 
1260
 
1156
1261
/*evaluate a matrix (or try to), it will try to expand the matrix and
1157
1262
  put 0's into the empty, undefined, spots. For example, a matrix such
1158
1263
  as if b = [8,7]; a = [1,2:3,b]  should expand to, [1,2,2:3,8,7] */
1201
1306
                /* never should be reached */
1202
1307
        }
1203
1308
 
 
1309
        if (h == 1) {
 
1310
                quick_wide_expand (n);
 
1311
                return;
 
1312
        }
 
1313
 
1204
1314
        gel_matrixw_make_private (nm, FALSE /* kill_type_caches */);
1205
1315
 
1206
1316
        m = gel_matrix_new();
1209
1319
        cols = gel_matrixw_width (nm);
1210
1320
 
1211
1321
        for (i = 0, k = 0; i < h; i++) {
1212
 
                int w;
1213
 
                w = expand_row (m, nm, k, i, &need_colwise);
1214
 
                k += w;
 
1322
                int kk;
 
1323
                kk = expand_row (m, nm, k, i, &need_colwise);
 
1324
                k += kk;
1215
1325
        }
1216
1326
 
1217
1327
        if (k == 0) {
1390
1500
logicalxorop(GelCtx *ctx, GelETree *n, GelETree *l, GelETree *r)
1391
1501
{
1392
1502
        gboolean bad_node = FALSE;
1393
 
        gboolean ret = gel_isnodetrue (l, &bad_node) != gel_isnodetrue (r,& bad_node);
 
1503
        gboolean ret = gel_isnodetrue (l, &bad_node) != gel_isnodetrue (r, &bad_node);
1394
1504
 
1395
1505
        if G_UNLIKELY (bad_node || gel_error_num) {
1396
1506
                gel_error_num = GEL_NO_ERROR;
1448
1558
           b->type == GEL_MATRIX_NODE) {
1449
1559
                if G_UNLIKELY (!gel_is_matrix_value_or_bool_only(a->mat.matrix) ||
1450
1560
                               !gel_is_matrix_value_or_bool_only(b->mat.matrix)) {
1451
 
                        gel_errorout (_("Cannot compare non value or bool only matrixes"));
 
1561
                        gel_errorout (_("Cannot compare non value or bool only matrices"));
1452
1562
                        *error = TRUE;
1453
1563
                        return 0;
1454
1564
                }
1505
1615
                        GelETree *t = gel_matrixw_index(m,0,0);
1506
1616
                        if G_UNLIKELY (t->type != GEL_VALUE_NODE &&
1507
1617
                                       t->type != GEL_BOOL_NODE) {
1508
 
                                gel_errorout (_("Cannot compare non value or bool only matrixes"));
 
1618
                                gel_errorout (_("Cannot compare non value or bool only matrices"));
1509
1619
                                *error = TRUE;
1510
1620
                                return 0;
1511
1621
                        }
1520
1630
                        GelETree *t = gel_matrixw_index(m,0,0);
1521
1631
                        if G_UNLIKELY (t->type != GEL_VALUE_NODE &&
1522
1632
                                       t->type != GEL_BOOL_NODE) {
1523
 
                                gel_errorout (_("Cannot compare non value or bool only matrixes"));
 
1633
                                gel_errorout (_("Cannot compare non value or bool only matrices"));
1524
1634
                                *error = TRUE;
1525
1635
                                return 0;
1526
1636
                        }
1924
2034
                    n->op.oper == GEL_E_ELTPLUS ||
1925
2035
                    n->op.oper == GEL_E_MINUS ||
1926
2036
                    n->op.oper == GEL_E_ELTMINUS)
1927
 
                        gel_errorout (_("Can't add/subtract two matricies of different sizes"));
 
2037
                        gel_errorout (_("Can't add/subtract two matrices of different sizes"));
1928
2038
                else
1929
 
                        gel_errorout (_("Can't do element by element operations on two matricies of different sizes"));
 
2039
                        gel_errorout (_("Can't do element by element operations on two matrices of different sizes"));
1930
2040
                return TRUE;
1931
2041
        }
1932
2042
        l->mat.quoted = l->mat.quoted || r->mat.quoted;
1992
2102
        m1 = l->mat.matrix;
1993
2103
        m2 = r->mat.matrix;
1994
2104
        if G_UNLIKELY ((gel_matrixw_width(m1) != gel_matrixw_height(m2))) {
1995
 
                gel_errorout (_("Can't multiply matricies of wrong sizes"));
 
2105
                gel_errorout (_("Can't multiply matrices of wrong sizes"));
1996
2106
                return TRUE;
1997
2107
        }
1998
2108
        m = gel_matrixw_new();
2363
2473
 
2364
2474
/*return TRUE if node is true (a number node !=0), false otherwise*/
2365
2475
gboolean
2366
 
gel_isnodetrue (GelETree *n, gboolean *bad_node)
 
2476
gel_isnodetrue (GelETree *n, gboolean *bad_node) /*PURE!*/
2367
2477
{
2368
2478
        switch (n->type) {
2369
2479
        case GEL_NULL_NODE:
3352
3462
                
3353
3463
                GEL_GET_NEW_NODE(i);
3354
3464
                i->type = GEL_IDENTIFIER_NODE;
 
3465
                i->id.uninitialized = FALSE;
3355
3466
                if(f->id) {
3356
3467
                        i->id.id = f->id;
3357
3468
                } else {
3425
3536
        f = d_lookup_global(n->id.id);
3426
3537
        if G_UNLIKELY (f == NULL) {
3427
3538
                char *similar;
3428
 
                if (strcmp (n->id.id->token, "i") == 0) {
3429
 
                        gel_errorout (_("Variable 'i' used uninitialized.  "
3430
 
                                        "Perhaps you meant to write '1i' for "
3431
 
                                        "the imaginary number (square root of "
3432
 
                                        "-1)."));
3433
 
                } else if ((similar = gel_similar_possible_ids (n->id.id->token))
3434
 
                               != NULL) {
3435
 
                        gel_errorout (_("Variable '%s' used uninitialized, "
3436
 
                                        "perhaps you meant %s."),
3437
 
                                      n->id.id->token,
3438
 
                                      similar);
 
3539
                if ( ! n->id.uninitialized) {
 
3540
                        if (strcmp (n->id.id->token, "i") == 0) {
 
3541
                                gel_errorout (_("Variable 'i' used uninitialized.  "
 
3542
                                                "Perhaps you meant to write '1i' for "
 
3543
                                                "the imaginary number (square root of "
 
3544
                                                "-1)."));
 
3545
                        } else if ((similar = gel_similar_possible_ids (n->id.id->token))
 
3546
                                       != NULL) {
 
3547
                                gel_errorout (_("Variable '%s' used uninitialized, "
 
3548
                                                "perhaps you meant %s."),
 
3549
                                              n->id.id->token,
 
3550
                                              similar);
3439
3551
 
3440
 
                        g_free (similar);
3441
 
                } else {
3442
 
                        gel_errorout (_("Variable '%s' used uninitialized"),
3443
 
                                      n->id.id->token);
 
3552
                                g_free (similar);
 
3553
                        } else {
 
3554
                                gel_errorout (_("Variable '%s' used uninitialized"),
 
3555
                                              n->id.id->token);
 
3556
                        }
3444
3557
                }
 
3558
                /* save that we have determined that this was
 
3559
                 * uninitialized */
 
3560
                n->id.uninitialized = TRUE;
3445
3561
                return TRUE;
3446
3562
        } else {
3447
3563
                return iter_do_var(ctx,n,f);
3459
3575
        f = d_lookup_global(l->id.id);
3460
3576
        if G_UNLIKELY (f == NULL) {
3461
3577
                char *similar = gel_similar_possible_ids (l->id.id->token);
3462
 
                if (similar != NULL) {
3463
 
                        gel_errorout (_("Variable '%s' used uninitialized, "
3464
 
                                        "perhaps you meant %s."),
3465
 
                                      l->id.id->token,
3466
 
                                      similar);
 
3578
                if ( ! l->id.uninitialized) {
 
3579
                        if (similar != NULL) {
 
3580
                                gel_errorout (_("Variable '%s' used uninitialized, "
 
3581
                                                "perhaps you meant %s."),
 
3582
                                              l->id.id->token,
 
3583
                                              similar);
3467
3584
 
3468
 
                        g_free (similar);
3469
 
                } else {
3470
 
                        gel_errorout (_("Variable '%s' used uninitialized"),
3471
 
                                      l->id.id->token);
 
3585
                                g_free (similar);
 
3586
                        } else {
 
3587
                                gel_errorout (_("Variable '%s' used uninitialized"),
 
3588
                                              l->id.id->token);
 
3589
                        }
3472
3590
                }
 
3591
                /* save that we have determined that this was
 
3592
                 * uninitialized */
 
3593
                l->id.uninitialized = TRUE;
3473
3594
        } else if G_UNLIKELY (f->nargs != 0) {
3474
3595
                gel_errorout (_("Call of '%s' with the wrong number of arguments!\n"
3475
3596
                                "(should be %d)"), f->id ? f->id->token : "anonymous", f->nargs);
3492
3613
        return;
3493
3614
 
3494
3615
/*returns 0 if all numeric (or bool if bool_ok), 1 if numeric/matrix/null, 2 if contains string, 3 otherwise*/
 
3616
static int arglevel (GelETree *r, int cnt, gboolean bool_ok) G_GNUC_PURE;
3495
3617
static int
3496
3618
arglevel (GelETree *r, int cnt, gboolean bool_ok)
3497
3619
{
3606
3728
                                }
3607
3729
                                break;
3608
3730
                        default:
3609
 
                                gel_errorout (_("Cannot compare matrixes"));
 
3731
                                gel_errorout (_("Cannot compare matrices"));
3610
3732
                                gel_error_num = GEL_NO_ERROR;
3611
3733
                                return;
3612
3734
                        }
3977
4099
                case GE_FOR:
3978
4100
                        {
3979
4101
                                GelEvalFor *evf = data;
3980
 
                                if(evf->by)
3981
 
                                        mpw_add(evf->x,evf->x,evf->by);
 
4102
                                gboolean done = FALSE;
 
4103
                                if (evf->by)
 
4104
                                        mpw_add (evf->x, evf->x, evf->by);
3982
4105
                                else
3983
 
                                        mpw_add_ui(evf->x,evf->x,1);
3984
 
                                /*if done*/
3985
 
                                if(mpw_cmp(evf->x,evf->to) == -evf->init_cmp) {
 
4106
                                        mpw_add_ui (evf->x, evf->x, 1);
 
4107
                                /* we know we aren't dealing with complexes */
 
4108
                                if (mpw_is_real_part_float (evf->x)) {
 
4109
                                        int thecmp = mpw_cmp (evf->x, evf->to);
 
4110
                                        if (mpw_cmp (evf->x, evf->to) == -evf->init_cmp) {
 
4111
                                                /* maybe we just missed it, let's look back within 2^-20 of the by and see */
 
4112
                                                mpw_t tmp;
 
4113
                                                if (evf->by != NULL) {
 
4114
                                                        mpfr_ptr f;
 
4115
                                                        /* by is definitely mpfr */
 
4116
                                                        mpw_init_set (tmp, evf->by);
 
4117
                                                        f = mpw_peek_real_mpf (tmp);
 
4118
                                                        mpfr_mul_2si (f, f, -20, GMP_RNDN);
 
4119
                                                } else {
 
4120
                                                        mpw_init (tmp);
 
4121
                                                        mpw_set_d (tmp, 1.0/1048576.0 /* 2^-20 */);
 
4122
                                                }
 
4123
 
 
4124
                                                mpw_sub (tmp, evf->x, tmp);
 
4125
 
 
4126
                                                done = (mpw_cmp(tmp,evf->to) == -evf->init_cmp);
 
4127
 
 
4128
                                                /* don't use x, but use the to, x might be too far */
 
4129
                                                if ( ! done) {
 
4130
                                                        mpw_set (evf->x, evf->to);
 
4131
                                                }
 
4132
 
 
4133
                                                mpw_clear (tmp);
 
4134
                                        } else {
 
4135
                                                done = FALSE;
 
4136
                                        }
 
4137
                                } else {
 
4138
                                        /*if done*/
 
4139
                                        done = (mpw_cmp(evf->x,evf->to) == -evf->init_cmp);
 
4140
                                }
 
4141
 
 
4142
                                if (done) {
3986
4143
                                        GelETree *res;
3987
4144
                                        GE_POP_STACK(ctx,data,flag);
3988
4145
                                        g_assert ((flag & GE_MASK) == GE_POST);
4433
4590
                }
4434
4591
        }
4435
4592
        if (pushed) {
4436
 
                int flag;
4437
4593
                ctx->post = FALSE;
4438
4594
                /* will pop the last thing which was t in PRE mode */
4439
 
                GE_POP_STACK (ctx, ctx->current, flag);
 
4595
                GE_POP_STACKNF (ctx, ctx->current);
4440
4596
                ctx->whackarg = FALSE;
4441
4597
        } else {
4442
4598
                /*if we haven't pushed ourselves,
4453
4609
        if(l->type == GEL_IDENTIFIER_NODE) {
4454
4610
                f = d_lookup_global(l->id.id);
4455
4611
                if (f == NULL) {
4456
 
                        if G_UNLIKELY ( ! silent) {
 
4612
                        if G_UNLIKELY ( ! silent &&
 
4613
                                        ! l->id.uninitialized) {
4457
4614
                                char * similar =
4458
4615
                                        gel_similar_possible_ids (l->id.id->token);
4459
4616
                                if (similar != NULL) {
4467
4624
                                        gel_errorout (_("Function '%s' used uninitialized"),
4468
4625
                                                      l->id.id->token);
4469
4626
                                }
 
4627
                                /* save that we have determined that this was
 
4628
                                 * uninitialized */
 
4629
                                l->id.uninitialized = TRUE;
4470
4630
                        }
4471
4631
                        return NULL;
4472
4632
                }
4478
4638
                GEL_GET_L(l,ll);
4479
4639
                f = d_lookup_global(ll->id.id);
4480
4640
                if (f == NULL) {
4481
 
                        if G_UNLIKELY ( ! silent) {
 
4641
                        if G_UNLIKELY ( ! silent &&
 
4642
                                        ! ll->id.uninitialized) {
4482
4643
                                gel_errorout (_("Variable '%s' used uninitialized"),
4483
4644
                                              ll->id.id->token);
 
4645
                                /* save that we have determined that this was
 
4646
                                 * uninitialized */
 
4647
                                ll->id.uninitialized = TRUE;
4484
4648
                        }
4485
4649
                        return NULL;
4486
 
                } else if(f->type != GEL_REFERENCE_FUNC) {
 
4650
                } else if (f->type != GEL_REFERENCE_FUNC) {
4487
4651
                        if G_UNLIKELY ( ! silent) {
4488
4652
                                gel_errorout (_("Can't dereference '%s'!"),
4489
4653
                                              ll->id.id->token);
4732
4896
                GEL_GET_NEW_NODE(id);
4733
4897
                id->type = GEL_IDENTIFIER_NODE;
4734
4898
                id->id.id = f->id; /*this WILL have an id*/
 
4899
                id->id.uninitialized = FALSE;
4735
4900
                id->any.next = NULL;
4736
4901
 
4737
4902
                freetree_full(n,TRUE,FALSE);
4860
5025
        
4861
5026
        init_cmp = mpw_cmp(from->val.value,to->val.value);
4862
5027
        
4863
 
        /*if no iterations*/
4864
5028
        if(!by) {
 
5029
                /*if no iterations*/
4865
5030
                if(init_cmp>0) {
4866
5031
                        d_addfunc(d_makevfunc(ident->id.id,gel_copynode(from)));
4867
5032
                        freetree_full(n,TRUE,FALSE);
4877
5042
                } else if(init_cmp==0) {
4878
5043
                        init_cmp = -1;
4879
5044
                }
 
5045
                if (mpw_is_real_part_float (from->val.value) ||
 
5046
                    mpw_is_real_part_float (to->val.value)) {
 
5047
                        /* ensure all float */
 
5048
                        mpw_make_float (to->val.value);
 
5049
                        mpw_make_float (from->val.value);
 
5050
                }
4880
5051
                evf = evf_new(type, from->val.value,to->val.value,NULL,init_cmp,
4881
5052
                              gel_copynode(body),body,ident->id.id);
4882
5053
        } else {
4883
5054
                int sgn = mpw_sgn(by->val.value);
 
5055
                /*if no iterations*/
4884
5056
                if((sgn>0 && init_cmp>0) || (sgn<0 && init_cmp<0)) {
4885
5057
                        d_addfunc(d_makevfunc(ident->id.id,gel_copynode(from)));
4886
5058
                        freetree_full(n,TRUE,FALSE);
4896
5068
                }
4897
5069
                if(init_cmp == 0)
4898
5070
                        init_cmp = -sgn;
 
5071
                if (mpw_is_real_part_float (from->val.value) ||
 
5072
                    mpw_is_real_part_float (to->val.value) ||
 
5073
                    mpw_is_real_part_float (by->val.value)) {
 
5074
                        /* ensure all float */
 
5075
                        mpw_make_float (to->val.value);
 
5076
                        mpw_make_float (from->val.value);
 
5077
                        mpw_make_float (by->val.value);
 
5078
                }
4899
5079
                evf = evf_new(type, from->val.value,to->val.value,by->val.value,
4900
5080
                              init_cmp,gel_copynode(body),body,ident->id.id);
4901
5081
        }
5522
5702
                }
5523
5703
        } else if(l->op.oper == GEL_E_GET_ELEMENT) {
5524
5704
                GelMatrixW *mat;
5525
 
                GelETree *m, *index1, *index2;
5526
 
                GEL_GET_LRR (l, m, index1, index2);
 
5705
                GelETree *index1, *index2;
 
5706
                GEL_GET_XRR (l, index1, index2);
5527
5707
 
5528
5708
                if (index1->type == GEL_VALUE_NODE &&
5529
5709
                    index2->type == GEL_VALUE_NODE) {
5586
5766
                }
5587
5767
        } else if(l->op.oper == GEL_E_GET_VELEMENT) {
5588
5768
                GelMatrixW *mat;
5589
 
                GelETree *m, *index;
5590
 
                GEL_GET_LR (l, m, index);
 
5769
                GelETree *index;
 
5770
                GEL_GET_XR (l, index);
5591
5771
 
5592
5772
                if (index->type == GEL_VALUE_NODE) {
5593
5773
                        int i;
5630
5810
                }
5631
5811
        } else /*l->data.oper == GEL_E_GET_COL_REGION GEL_E_GET_ROW_REGION*/ {
5632
5812
                GelMatrixW *mat;
5633
 
                GelETree *m, *index;
5634
 
                GEL_GET_LR (l, m, index);
 
5813
                GelETree *index;
 
5814
                GEL_GET_XR (l, index);
5635
5815
 
5636
5816
                if (index->type == GEL_VALUE_NODE ||
5637
5817
                    index->type == GEL_MATRIX_NODE) {
5813
5993
                }
5814
5994
        } else if(l->op.oper == GEL_E_GET_ELEMENT) {
5815
5995
                GelMatrixW *mat;
5816
 
                GelETree *m, *index1, *index2;
5817
 
                GEL_GET_LRR (l, m, index1, index2);
 
5996
                GelETree *index1, *index2;
 
5997
                GEL_GET_XRR (l, index1, index2);
5818
5998
 
5819
5999
                if (index1->type == GEL_VALUE_NODE &&
5820
6000
                    index2->type == GEL_VALUE_NODE) {
5861
6041
                }
5862
6042
        } else if(l->op.oper == GEL_E_GET_VELEMENT) {
5863
6043
                GelMatrixW *mat;
5864
 
                GelETree *m, *index;
5865
 
                GEL_GET_LR (l, m, index);
 
6044
                GelETree *index;
 
6045
                GEL_GET_XR (l, index);
5866
6046
 
5867
6047
                if (index->type == GEL_VALUE_NODE) {
5868
6048
                        int i;
5898
6078
                }
5899
6079
        } else /*l->data.oper == GEL_E_GET_COL_REGION GEL_E_GET_ROW_REGION*/ {
5900
6080
                GelMatrixW *mat;
5901
 
                GelETree *m, *index;
5902
 
                GEL_GET_LR (l, m, index);
 
6081
                GelETree *index;
 
6082
                GEL_GET_XR (l, index);
5903
6083
 
5904
6084
                if (index->type == GEL_VALUE_NODE ||
5905
6085
                    index->type == GEL_MATRIX_NODE) {
5977
6157
                        rf->data.user = tmp;
5978
6158
                } else if(r->op.oper == GEL_E_GET_ELEMENT) {
5979
6159
                        GelMatrixW *mat;
5980
 
                        GelETree *m, *index1, *index2;
5981
 
                        GEL_GET_LRR (r, m, index1, index2);
 
6160
                        GelETree *index1, *index2;
 
6161
                        GEL_GET_XRR (r, index1, index2);
5982
6162
 
5983
6163
                        if (index1->type == GEL_VALUE_NODE &&
5984
6164
                            index2->type == GEL_VALUE_NODE) {
6012
6192
                        }
6013
6193
                } else if(r->op.oper == GEL_E_GET_VELEMENT) {
6014
6194
                        GelMatrixW *mat;
6015
 
                        GelETree *m, *index;
6016
 
                        GEL_GET_LR (r, m, index);
 
6195
                        GelETree *index;
 
6196
                        GEL_GET_XR (r, index);
6017
6197
 
6018
6198
                        if (index->type == GEL_VALUE_NODE) {
6019
6199
                                int i, x, y;
6062
6242
                return;
6063
6243
 
6064
6244
        if (l->op.oper == GEL_E_GET_ELEMENT) {
6065
 
                GelETree *m, *index1, *index2;
6066
 
                GEL_GET_LRR (l, m, index1, index2);
 
6245
                GelETree *index1, *index2;
 
6246
                GEL_GET_XRR (l, index1, index2);
6067
6247
 
6068
6248
                if (index1->type == GEL_VALUE_NODE &&
6069
6249
                    index2->type == GEL_VALUE_NODE) {
6078
6258
                        return;
6079
6259
                }
6080
6260
        } else if (l->op.oper == GEL_E_GET_VELEMENT) {
6081
 
                GelETree *m, *index;
6082
 
                GEL_GET_LR (l, m, index);
 
6261
                GelETree *index;
 
6262
                GEL_GET_XR (l, index);
6083
6263
 
6084
6264
                if (index->type == GEL_VALUE_NODE) {
6085
6265
                        int i;
6096
6276
        }
6097
6277
 
6098
6278
        if (r->op.oper == GEL_E_GET_ELEMENT) {
6099
 
                GelETree *m, *index1, *index2;
6100
 
                GEL_GET_LRR (r, m, index1, index2);
 
6279
                GelETree *index1, *index2;
 
6280
                GEL_GET_XRR (r, index1, index2);
6101
6281
 
6102
6282
                if (index1->type == GEL_VALUE_NODE &&
6103
6283
                    index2->type == GEL_VALUE_NODE) {
6112
6292
                        return;
6113
6293
                }
6114
6294
        } else if(r->op.oper == GEL_E_GET_VELEMENT) {
6115
 
                GelETree *m, *index;
6116
 
                GEL_GET_LR (r, m, index);
 
6295
                GelETree *index;
 
6296
                GEL_GET_XR (r, index);
6117
6297
 
6118
6298
                if (index->type == GEL_VALUE_NODE) {
6119
6299
                        int i;
6173
6353
static void
6174
6354
iter_parameterop (GelETree *n)
6175
6355
{
6176
 
        GelETree *l,*r,*rr;
 
6356
        GelETree *r,*rr;
6177
6357
 
6178
 
        GEL_GET_LRR (n, l, r, rr);
 
6358
        GEL_GET_XRR (n, r, rr);
6179
6359
 
6180
6360
        /* FIXME: l should be the set func */
6181
6361
        
6203
6383
static inline void
6204
6384
iter_push_indexes_and_arg(GelCtx *ctx, GelETree *n)
6205
6385
{
6206
 
        GelETree *l,*ident;
 
6386
        GelETree *l;
6207
6387
 
6208
6388
        GEL_GET_L(n,l);
6209
6389
        
6210
6390
        if (l->op.oper == GEL_E_GET_ELEMENT) {
6211
6391
                GelETree *ll,*rr;
6212
6392
                
6213
 
                GEL_GET_LRR(l,ident,ll,rr);
 
6393
                GEL_GET_XRR(l,ll,rr);
6214
6394
 
6215
6395
                GE_PUSH_STACK(ctx,n->op.args->any.next,GE_PRE);
6216
6396
                GE_PUSH_STACK(ctx,rr,GE_PRE);
6222
6402
                  l->op.oper == GEL_E_GET_ROW_REGION) {
6223
6403
                GelETree *ll;
6224
6404
                
6225
 
                GEL_GET_LR(l,ident,ll);
 
6405
                GEL_GET_XR(l,ll);
6226
6406
 
6227
6407
                GE_PUSH_STACK(ctx,n->op.args->any.next,GE_PRE);
6228
6408
                ctx->post = FALSE;
6238
6418
static inline void
6239
6419
iter_do_push_index (GelCtx *ctx, GelETree *l)
6240
6420
{
6241
 
        GelETree *ident;
6242
 
 
6243
6421
        if (l->op.oper == GEL_E_GET_ELEMENT) {
6244
6422
                GelETree *ll,*rr;
6245
6423
                
6246
 
                GEL_GET_LRR(l,ident,ll,rr);
 
6424
                GEL_GET_XRR(l,ll,rr);
6247
6425
 
6248
6426
                GE_PUSH_STACK(ctx,rr,GE_PRE);
6249
6427
                GE_PUSH_STACK(ctx,ll,GE_PRE);
6252
6430
                  l->op.oper == GEL_E_GET_ROW_REGION) {
6253
6431
                GelETree *ll;
6254
6432
                
6255
 
                GEL_GET_LR(l,ident,ll);
 
6433
                GEL_GET_XR(l,ll);
6256
6434
                GE_PUSH_STACK(ctx,ll,GE_PRE);
6257
6435
        }
6258
6436
}
6290
6468
        GEL_GET_LR (n, m, index);
6291
6469
 
6292
6470
        if G_UNLIKELY (m->type != GEL_MATRIX_NODE) {
6293
 
                gel_errorout (_("Index works only on matricies"));
 
6471
                gel_errorout (_("Index works only on matrices"));
6294
6472
                return;
6295
6473
        }
6296
6474
 
6335
6513
        GEL_GET_LRR (n, m, index1, index2);
6336
6514
 
6337
6515
        if G_UNLIKELY (m->type != GEL_MATRIX_NODE) {
6338
 
                gel_errorout (_("Index works only on matricies"));
 
6516
                gel_errorout (_("Index works only on matrices"));
6339
6517
                return;
6340
6518
        } else if G_UNLIKELY (index1->type != GEL_NULL_NODE &&
6341
6519
                              index1->type != GEL_MATRIX_NODE &&
6426
6604
        GEL_GET_LR (n, m, index);
6427
6605
 
6428
6606
        if G_UNLIKELY (m->type != GEL_MATRIX_NODE) {
6429
 
                gel_errorout (_("Index works only on matricies"));
 
6607
                gel_errorout (_("Index works only on matrices"));
6430
6608
                return;
6431
6609
        } else if G_LIKELY (index->type == GEL_VALUE_NODE ||
6432
6610
                            index->type == GEL_MATRIX_NODE) {
8085
8263
        if (l->type != GEL_VALUE_NODE ||
8086
8264
            (respect_type &&
8087
8265
             (mpw_is_complex (l->val.value) ||
8088
 
              mpw_is_float (l->val.value))))
 
8266
              mpw_is_real_part_float (l->val.value))))
8089
8267
                return;
8090
8268
        mpw_init(res);
8091
8269
        (*func)(res,l->val.value);
8111
8289
            (respect_type &&
8112
8290
             (mpw_is_complex (l->val.value) ||
8113
8291
              mpw_is_complex (r->val.value) ||
8114
 
              mpw_is_float (l->val.value) ||
8115
 
              mpw_is_float (r->val.value))))
 
8292
              mpw_is_real_part_float (l->val.value) ||
 
8293
              mpw_is_real_part_float (r->val.value))))
8116
8294
                return;
8117
8295
        mpw_init(res);
8118
8296
        (*func)(res,l->val.value,r->val.value);