unary.cc
21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
// -*- mode:C++ ; compile-command: "g++ -I.. -g -c unary.cc -DIN_GIAC -DHAVE_CONFIG_H" -*-
#include "giacPCH.h"
/*
* Copyright (C) 2000,14 B. Parisse, Institut Fourier, 38402 St Martin d'Heres
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using namespace std;
#include "unary.h"
#include "gen.h"
#include "usual.h"
#include "rpn.h"
#include "tex.h"
#include "input_lexer.h"
#include "symbolic.h"
#include "input_lexer.h"
#include "rpn.h"
#include "sparse.h"
#include "giacintl.h"
#ifndef NO_NAMESPACE_GIAC
namespace giac {
#endif // ndef NO_NAMESPACE_GIAC
// unary_function_ptr
gen unary_function_ptr::operator () (const gen & arg,const context * context_ptr) const{
return (*ptr())(arg,context_ptr);
// return (*ptr)(arg,context_ptr);
this->dbgprint();
}
const char * unary_function_ptr::dbgprint() const {
#ifndef NSPIRE
CERR << ptr()->s << endl;
#endif
return ptr()->s;
}
#if 0 // def x86_64
bool unary_function_ptr::quoted() const { return (ptr()->index_quoted_function & 0x1) || ( ((longlong) _ptr) & 0x1); }
#else
bool unary_function_ptr::quoted() const { return (ptr()->index_quoted_function & 0x1) || ( ((size_t) _ptr) & 0x1); }
#endif
/*
unary_function_ptr::unary_function_ptr(const unary_function_ptr & myptr):ptr(myptr.ptr),ref_count(myptr.ref_count),quoted(myptr.quoted){
if (ref_count)
++(*ref_count);
}
// dynamic unary_function_abstract
unary_function_ptr::unary_function_ptr(const unary_function_abstract & myptr): quoted(0) {
ref_count = new int(1);
ptr = myptr.recopie();
}
unary_function_ptr::unary_function_ptr(const unary_function_abstract & myptr,int myquoted,int parser_token): quoted(myquoted) {
ptr = myptr.recopie();
if (parser_token)
if (!lexer_functions_register(*this,ptr->s,parser_token))
setsizeerr(gettext("Unable to register ")+ptr->s);
}
*/
// global unary_function_abstract pointer, no reference count here
#ifdef NO_UNARY_FUNCTION_COMPOSE
unary_function_ptr::unary_function_ptr(const unary_function_eval * myptr,int myquoted,int parser_token): _ptr((size_t)myptr){
if (myquoted)
*((size_t *) &_ptr) |= 0x1;
if (parser_token)
if (!lexer_functions_register(*this,myptr->s,parser_token))
setsizeerr(gettext("Unable to register ")+string(myptr->s));
}
unary_function_ptr::unary_function_ptr(const alias_unary_function_eval * myptr,int myquoted,int parser_token):_ptr((size_t)myptr) {
if (myquoted)
*((size_t *) &_ptr) |= 0x1;
if (parser_token)
if (!lexer_functions_register(*this,myptr->s,parser_token))
setsizeerr(gettext("Unable to register ")+string(myptr->s));
}
/*
unary_function_ptr::unary_function_ptr(const unary_function_eval * myptr,int parser_token): _ptr(myptr){
if (parser_token)
if (!lexer_functions_register(*this,myptr->s,parser_token))
setsizeerr(gettext("Unable to register ")+string(myptr->s));
}
unary_function_ptr::unary_function_ptr(const alias_unary_function_eval * myptr,int parser_token):_ptr((const unary_function_eval *)myptr) {
if (parser_token)
if (!lexer_functions_register(*this,myptr->s,parser_token))
setsizeerr(gettext("Unable to register ")+string(myptr->s));
}
*/
const char * unary_function_eval::print(GIAC_CONTEXT) const {
if (abs_calc_mode(contextptr)==38){
if (calc_mode(contextptr)==38){
const char * maj = hp38_display_in_maj(s);
return maj?maj:s;
}
else
return s;
}
int lang=language(contextptr);
multimap<string,localized_string>::iterator it=back_lexer_localization_map().find(s),backend=back_lexer_localization_map().end(),itend=back_lexer_localization_map().upper_bound(s);
if (it!=backend){
for (;it!=itend;++it){
if (it->second.language==lang)
return it->second.chaine.c_str();
}
}
return s;
}
#else // NO_UNARY_FUNCTION_COMPOSE
unary_function_ptr::unary_function_ptr(const unary_function_abstract * myptr,int myquoted,int parser_token): _ptr(myptr){
if (myquoted)
*((size_t *) &_ptr) |= 0x1;
if (parser_token)
if (!lexer_functions_register(*this,myptr->s,parser_token))
setsizeerr(gettext("Unable to register ")+string(myptr->s));
}
unary_function_ptr::unary_function_ptr(const alias_unary_function_eval * myptr,int myquoted,int parser_token):_ptr((const unary_function_abstract *)myptr) {
if (myquoted)
*((size_t *) &_ptr) |= 0x1;
if (parser_token)
if (!lexer_functions_register(*this,myptr->s,parser_token))
setsizeerr(gettext("Unable to register ")+string(myptr->s));
}
/*
unary_function_ptr::unary_function_ptr(const unary_function_abstract * myptr,int parser_token): _ptr(myptr){
if (parser_token)
if (!lexer_functions_register(*this,myptr->s,parser_token))
setsizeerr(gettext("Unable to register ")+string(myptr->s));
}
unary_function_ptr::unary_function_ptr(const alias_unary_function_eval * myptr,int parser_token):_ptr((const unary_function_abstract *)myptr) {
if (parser_token)
if (!lexer_functions_register(*this,myptr->s,parser_token))
setsizeerr(gettext("Unable to register ")+string(myptr->s));
}
*/
const char * unary_function_abstract::print(GIAC_CONTEXT) const {
if (abs_calc_mode(contextptr)==38){
if (calc_mode(contextptr)==38){
const char * maj = hp38_display_in_maj(s);
return maj?maj:s;
}
return s;
}
int lang=language(contextptr);
multimap<string,localized_string>::iterator it=back_lexer_localization_map().find(s),backend=back_lexer_localization_map().end(),itend=back_lexer_localization_map().upper_bound(s);
if (it!=backend){
for (;it!=itend;++it){
if (it->second.language==lang)
return it->second.chaine.c_str();
}
}
return s;
}
#endif // NO_UNARY_FUNCTION_COMPOSE
/*
// copy constructor
unary_function_ptr & unary_function_ptr::operator = (const unary_function_ptr & acopier){
if (ref_count){
if (!((*ref_count)--)){
delete ptr;
delete ref_count;
}
}
ptr = acopier.ptr;
ref_count=acopier.ref_count;
quoted = acopier.quoted;
if (ref_count)
++(*ref_count);
return *this;
}
unary_function_ptr::~unary_function_ptr(){
if (ref_count){
if (!((*ref_count)--)){
delete ptr;
delete ref_count;
}
}
}
*/
gen apply(const gen & e,const unary_function_ptr & f,GIAC_CONTEXT){
if (e.type==_MAP){
gen_map res;
gen g(res);
map_apply(*e._MAPptr,f,*g._MAPptr,contextptr);
return g;
}
if (e.type!=_VECT)
return f(e,contextptr);
const_iterateur it=e._VECTptr->begin(),itend=e._VECTptr->end();
// if (itend==it && abs_calc_mode(contextptr)==38) return gensizeerr();
vecteur v;
v.reserve(itend-it);
for (;it!=itend;++it){
gen tmp=f(*it,contextptr);
if (is_undef(tmp))
return gen2vecteur(tmp);
v.push_back(tmp);
}
return gen(v,e.subtype);
}
gen apply(const gen & e,const unary_function_ptr * f,GIAC_CONTEXT){
if (e.type!=_VECT)
return (*f)(e,contextptr);
const_iterateur it=e._VECTptr->begin(),itend=e._VECTptr->end();
// if (itend==it && abs_calc_mode(contextptr)==38) return gensizeerr();
vecteur v;
v.reserve(itend-it);
for (;it!=itend;++it){
gen tmp=(*f)(*it,contextptr);
if (is_undef(tmp))
return gen2vecteur(tmp);
v.push_back(tmp);
}
return gen(v,e.subtype);
}
gen apply(const gen & e, gen (* f) (const gen &) ){
if (e.type!=_VECT)
return f(e);
const_iterateur it=e._VECTptr->begin(),itend=e._VECTptr->end();
vecteur v;
v.reserve(itend-it);
for (;it!=itend;++it){
gen tmp=f(*it);
if (is_undef(tmp))
return gen2vecteur(tmp);
v.push_back(tmp);
}
return gen(v,e.subtype);
}
gen apply(const gen & e, gen (* f) (const gen &,const context *),GIAC_CONTEXT ){
if (e.type==_MAP){
gen_map res;
gen g(res);
map_apply(*e._MAPptr,*g._MAPptr,contextptr,f);
return g;
}
if (e.type!=_VECT)
return f(e,contextptr);
const_iterateur it=e._VECTptr->begin(),itend=e._VECTptr->end();
// if (itend==it && abs_calc_mode(contextptr)==38) return gensizeerr();
vecteur v;
v.reserve(itend-it);
for (;it!=itend;++it){
gen tmp=f(*it,contextptr);
if (is_undef(tmp))
return gen2vecteur(tmp);
v.push_back(tmp);
}
return gen(v,e.subtype);
}
gen apply(const gen & e1, const gen & e2,gen (* f) (const gen &, const gen &) ){
if ((e1.type!=_VECT) && (e2.type!=_VECT))
return f(e1,e2);
if (e1.type!=_VECT){
const_iterateur it=e2._VECTptr->begin(),itend=e2._VECTptr->end();
vecteur v;
v.reserve(itend-it);
for (;it!=itend;++it){
gen tmp=f(e1,*it);
if (is_undef(tmp))
return gen2vecteur(tmp);
v.push_back(tmp);
}
return gen(v,e2.subtype);
}
if (e2.type!=_VECT){
const_iterateur it=e1._VECTptr->begin(),itend=e1._VECTptr->end();
vecteur v;
v.reserve(itend-it);
for (;it!=itend;++it){
gen tmp=f(*it,e2);
if (is_undef(tmp))
return gen2vecteur(tmp);
v.push_back(tmp);
}
return gen(v,e1.subtype);
}
const_iterateur it1=e1._VECTptr->begin(),it1end=e1._VECTptr->end();
const_iterateur it2=e2._VECTptr->begin(),it2end=e2._VECTptr->end();
// if (it2end-it2!=it1end-it1) return gendimerr();
vecteur v;
v.reserve(it1end-it1);
for (;it1!=it1end && it2!=it2end;++it1,++it2){
gen tmp=f(*it1,*it2);
if (is_undef(tmp))
return gen2vecteur(tmp);
v.push_back(tmp);
}
return gen(v,e1.subtype);
}
gen apply(const gen & e, const context * contextptr,const gen_op_context & f ){
if (e.type==_MAP){
gen_map res;
gen g(res);
map_apply(*e._MAPptr,*g._MAPptr,contextptr,f);
return g;
}
if (e.type!=_VECT)
return f(e,contextptr);
const_iterateur it=e._VECTptr->begin(),itend=e._VECTptr->end();
// if (itend==it && abs_calc_mode(contextptr)==38) return gensizeerr();
vecteur v;
v.reserve(itend-it);
for (;it!=itend;++it){
gen tmp=f(*it,contextptr);
if (is_undef(tmp))
return gen2vecteur(tmp);
v.push_back(tmp);
}
return gen(v,e.subtype);
}
gen apply(const gen & e1, const gen & e2,const context * contextptr,gen (* f) (const gen &, const gen &,const context *) ){
if ((e1.type!=_VECT) && (e2.type!=_VECT))
return f(e1,e2,contextptr);
if (e1.type!=_VECT){
const_iterateur it=e2._VECTptr->begin(),itend=e2._VECTptr->end();
vecteur v;
v.reserve(itend-it);
for (;it!=itend;++it){
gen tmp=f(e1,*it,contextptr);
if (is_undef(tmp))
return gen2vecteur(tmp);
v.push_back(tmp);
}
return gen(v,e2.subtype);
}
if (e2.type!=_VECT){
const_iterateur it=e1._VECTptr->begin(),itend=e1._VECTptr->end();
vecteur v;
v.reserve(itend-it);
for (;it!=itend;++it){
gen tmp=f(*it,e2,contextptr);
if (is_undef(tmp))
return gen2vecteur(tmp);
v.push_back(tmp);
}
return gen(v,e1.subtype);
}
const_iterateur it1=e1._VECTptr->begin(),it1end=e1._VECTptr->end();
const_iterateur it2=e2._VECTptr->begin(),it2end=e2._VECTptr->end();
// if (it2end-it2!=it1end-it1) return gendimerr();
vecteur v;
v.reserve(it1end-it1);
for (;it1!=it1end && it2!=it2end;++it1,++it2){
gen tmp=f(*it1,*it2,contextptr);
if (is_undef(tmp))
return gen2vecteur(tmp);
v.push_back(tmp);
}
return gen(v,e1.subtype);
}
gen apply1st(const gen & e1, const gen & e2,gen (* f) (const gen &, const gen &) ){
if (e1.type!=_VECT)
return f(e1,e2);
const_iterateur it=e1._VECTptr->begin(),itend=e1._VECTptr->end();
gen res=new ref_vecteur;
res.subtype=e1.subtype;
vecteur &v=*res._VECTptr;
v.reserve(itend-it);
for (;it!=itend;++it){
gen tmp=f(*it,e2);
if (is_undef(tmp))
return gen2vecteur(tmp);
v.push_back(tmp);
}
return res;//gen(v,e1.subtype);
}
gen apply1st(const gen & e1, const gen & e2,const context * contextptr, gen (* f) (const gen &, const gen &,const context *) ){
if (e1.type!=_VECT)
return f(e1,e2,contextptr);
const_iterateur it=e1._VECTptr->begin(),itend=e1._VECTptr->end();
gen res=new ref_vecteur;
res.subtype=e1.subtype;
vecteur &v=*res._VECTptr;
v.reserve(itend-it);
for (;it!=itend;++it){
gen tmp=f(*it,e2,contextptr);
if (is_undef(tmp))
return gen2vecteur(tmp);
v.push_back(tmp);
}
return res;//gen(v,e1.subtype);
}
gen apply2nd(const gen & e1, const gen & e2,gen (* f) (const gen &, const gen &) ){
if (e2.type!=_VECT)
return f(e1,e2);
const_iterateur it=e2._VECTptr->begin(),itend=e2._VECTptr->end();
gen res=new ref_vecteur;
res.subtype=e2.subtype;
vecteur &v=*res._VECTptr;
v.reserve(itend-it);
for (;it!=itend;++it){
gen tmp=f(e1,*it);
if (is_undef(tmp))
return gen2vecteur(tmp);
v.push_back(tmp);
}
return res; // gen(v,e2.subtype);
}
gen apply2nd(const gen & e1, const gen & e2,const context * contextptr, gen (* f) (const gen &, const gen &,const context *) ){
if (e2.type!=_VECT)
return f(e1,e2,contextptr);
const_iterateur it=e2._VECTptr->begin(),itend=e2._VECTptr->end();
gen res=new ref_vecteur;
res.subtype=e2.subtype;
vecteur &v=*res._VECTptr; // vecteur v;
v.reserve(itend-it);
for (;it!=itend;++it){
gen tmp=f(e1,*it,contextptr);
if (is_undef(tmp))
return gen2vecteur(tmp);
v.push_back(tmp);
}
return res;//gen(v,e2.subtype);
}
#ifdef NO_UNARY_FUNCTION_COMPOSE
#ifdef NSPIRE
template<class T> nio::ios_base<T> & operator << (nio::ios_base<T> & os,const unary_function_eval & o) { return os << o.s ; }
#else
ostream & operator << (ostream & os,const unary_function_eval & o) { return os << o.s ; }
#endif
#else
// unary_function_abstract
unary_function_abstract * unary_function_abstract::recopie() const{
unary_function_abstract * ptr=new unary_function_abstract(index_quoted_function,s);
ptr->D = D;
return ptr;
}
unary_function_unary * unary_function_unary::recopie() const{
unary_function_unary * ptr=new unary_function_unary(index_quoted_function,op,s);
ptr->D = D;
return ptr;
}
unary_function_eval * unary_function_eval::recopie() const{
unary_function_eval * ptr=new unary_function_eval(index_quoted_function,op,s);
ptr->D = D;
return ptr;
}
// I/O
ostream & operator << (ostream & os,const unary_function_abstract & o){ return os << o.s; }
ostream & operator << (ostream & os,const unary_function_unary & o) { return os << o.s ; }
ostream & operator << (ostream & os,const unary_function_eval & o) { return os << o.s ; }
unary_function_compose * unary_function_compose::recopie() const{
unary_function_compose * ptr=new unary_function_compose(index_quoted_function,op_v);
ptr->D = D;
return ptr;
}
unary_function_list * unary_function_list::recopie() const{
unary_function_list * ptr=new unary_function_list(index_quoted_function,op_l);
ptr->D = D;
return ptr;
}
unary_function_constant * unary_function_constant::recopie() const{
unary_function_constant * ptr=new unary_function_constant(index_quoted_function,constant);
ptr->D = D;
return ptr;
}
unary_function_innerprod * unary_function_innerprod::recopie() const{
unary_function_innerprod * ptr=new unary_function_innerprod(index_quoted_function,i);
ptr->D = D;
return ptr;
}
unary_function_user * unary_function_user::recopie() const{
unary_function_user * ptr=new unary_function_user(index_quoted_function,f,s,printsommet,texprint,cprint);
ptr->D = D;
return ptr;
}
// unary_function_compose related
gen unary_function_compose::operator () (const gen & arg,const context * context_ptr) const{
vector<unary_function_ptr>::const_iterator it=op_v.begin(),itend=op_v.end();
gen res(arg);
for (;it!=itend;++it)
res=(*it)(res,context_ptr);
return res;
}
unary_function_compose::unary_function_compose(unsigned u,const vector<unary_function_ptr> & myop_v) : unary_function_abstract(u,0) {
string * sptr=new string(":: ");
vector<unary_function_ptr>::const_iterator it=myop_v.begin(),itend=myop_v.end();
for (;it!=itend;++it){
op_v.push_back( (*it) );
*sptr += it->ptr()->s;
*sptr +=" ";
}
*sptr += string(";");
s=sptr->c_str();
}
gen unary_function_list::operator () (const gen & arg,const context * context_ptr) const{
vector<unary_function_ptr>::const_iterator it=op_l.begin(),itend=op_l.end();
vecteur res;
for (;it!=itend;++it)
res.push_back( (*it)(arg,context_ptr));
return res;
}
unary_function_list::unary_function_list(unsigned u,const vector<unary_function_ptr> & myop_v) : unary_function_abstract(u,0) {
string * sptr=new string("{ ");
vector<unary_function_ptr>::const_iterator it=myop_v.begin(),itend=myop_v.end();
for (;it!=itend;++it){
op_l.push_back( (*it) );
*sptr += it->ptr()->s;
*sptr +=" ";
}
*sptr += string("}");
s=sptr->c_str();
}
gen unary_function_innerprod::operator () (const gen & arg,const context * contextptr) const{
if (arg.type!=_VECT)
setsizeerr(arg.print(contextptr)+ gettext(" should be of type _VECT (unary.cc)"));
vecteur res;
// remove i indices from arg
vecteur::const_iterator jt=arg._VECTptr->begin(),jtend=arg._VECTptr->end();
vector<int>::const_iterator it=i.begin(), itend=i.end();
for (int j=0;jt!=jtend;++jt,++j){
if (it==itend)
break;
else {
if (j!=*it)
res.push_back(*jt);
else
++it;
}
}
for (;jt!=jtend;++jt)
res.push_back(*jt);
return res;
}
ostream & operator << (ostream & os,const unary_function_compose & p){ return os << p.s;}
ostream & operator << (ostream & os,const unary_function_list & p){ return os<< p.s; }
ostream & operator << (ostream & os,const unary_function_constant & c){ return os<< c.s; }
ostream & operator << (ostream & os,const unary_function_innerprod & i){ return os<< i.s; }
#endif // NO_UNARY_FUNCTION_COMPOSE
string printsommetasoperator(const gen & feuille,const char * sommetstr_orig,GIAC_CONTEXT){
if (feuille.type!=_VECT)
return feuille.print(contextptr);
string sommetstr(sommetstr_orig);
if ( (sommetstr[0]>32 && isalpha(sommetstr[0])) || sommetstr[0]=='%' || sommetstr[0]=='.')
sommetstr=' '+sommetstr+' ';
vecteur::const_iterator itb=feuille._VECTptr->begin(),itend=feuille._VECTptr->end();
if (itb==itend)
return "";
string s;
if (itb->type==_FRAC && sommetstr!="=")
s='('+itb->print(contextptr)+')';
else {
if ( sommetstr=="=" || itb->type==_IDNT || (itb->type<=_CPLX && is_positive(*itb,contextptr)) )
s=itb->print(contextptr);
else
s='('+itb->print(contextptr)+')';
}
++itb;
for (;;){
if (itb==itend)
return s;
if ( itb->type==_SYMB || itb->type==_FRAC || itb->type==_CPLX || (itb->type==_VECT && itb->subtype==_SEQ__VECT) )
s += sommetstr + '('+itb->print(contextptr)+")";
else
s += sommetstr + itb->print(contextptr);
++itb;
}
}
string texprintsommetasoperator(const gen & feuille,const char * sommetstr_orig,GIAC_CONTEXT){
if (feuille.type!=_VECT)
return feuille.print(contextptr);
string sommetstr(sommetstr_orig);
vecteur::const_iterator itb=feuille._VECTptr->begin(),itend=feuille._VECTptr->end();
if (itb==itend)
return "";
string s;
if (itb->type==_FRAC)
s="("+gen2tex(*itb,contextptr)+")";
else {
if ( sommetstr=="=" || itb->type==_IDNT || (itb->type<=_CPLX && is_positive(*itb,contextptr)) )
s=gen2tex(*itb,contextptr);
else
s="("+gen2tex(*itb,contextptr)+")";
}
++itb;
for (;;){
if (itb==itend)
return s;
if ( itb->type==_SYMB || itb->type==_FRAC || itb->type==_CPLX || (itb->type==_VECT && itb->subtype==_SEQ__VECT) )
s += sommetstr + '('+gen2tex(*itb,contextptr)+")";
else
s += sommetstr + gen2tex(*itb,contextptr);
++itb;
}
}
#ifdef NO_UNARY_FUNCTION_COMPOSE
partial_derivative::partial_derivative(gen (* mydf) (const gen & argss,const context * contextptr) ) : df(unary_function_ptr(new unary_function_eval(0,mydf,""))) {}
#else
partial_derivative_onearg::partial_derivative_onearg(gen (* mydf) (const gen & args) ) : df(unary_function_ptr(new unary_function_unary(0,mydf,""))) {}
partial_derivative_onearg::partial_derivative_onearg(gen (* mydf) (const gen & args,const context * contextptr) ) : df(unary_function_ptr(new unary_function_eval(0,mydf,""))) {}
#endif
#ifndef NO_NAMESPACE_GIAC
} // namespace giac
#endif // ndef NO_NAMESPACE_GIAC