~ubuntu-branches/ubuntu/karmic/scilab/karmic

« back to all changes in this revision

Viewing changes to tests/scilab.dia.ref

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
// Copyright INRIA
 
3
 
 
4
pi=%pi
 
5
 pi  =
 
6
 
 
7
    3.1415927  
 
8
 
 
9
i=%i
 
10
 i  =
 
11
 
 
12
    i    
 
13
 
 
14
e=%e
 
15
 e  =
 
16
 
 
17
    2.7182818  
 
18
 
 
19
//       tests
 
20
 
 
21
//
 
22
 
 
23
1
 
24
 ans  =
 
25
 
 
26
    1.  
 
27
 
 
28
a=1
 
29
 a  =
 
30
 
 
31
    1.  
 
32
 
 
33
b=[1 2 3]
 
34
 b  =
 
35
 
 
36
!   1.    2.    3. !
 
37
 
 
38
c=[1 2 3;4 5 6]
 
39
 c  =
 
40
 
 
41
!   1.    2.    3. !
 
42
!   4.    5.    6. !
 
43
 
 
44
d=[1 2 3;4 5 6]'
 
45
 d  =
 
46
 
 
47
!   1.    4. !
 
48
!   2.    5. !
 
49
!   3.    6. !
 
50
 
 
51
d=[1 2 3 4;4 5 6 7;8 9 10 11;12 13 14 15]
 
52
 d  =
 
53
 
 
54
!   1.     2.     3.     4.  !
 
55
!   4.     5.     6.     7.  !
 
56
!   8.     9.     10.    11. !
 
57
!   12.    13.    14.    15. !
 
58
 
 
59
d=[1 2;3 4]
 
60
 d  =
 
61
 
 
62
!   1.    2. !
 
63
!   3.    4. !
 
64
 
 
65
e1=[[1 2] [3 4];[5 6 7 8];[9;10;11;12]']
 
66
 e1  =
 
67
 
 
68
!   1.    2.     3.     4.  !
 
69
!   5.    6.     7.     8.  !
 
70
!   9.    10.    11.    12. !
 
71
 
 
72
f([1 3 5],[1 2 3])=[-1 -2 -3;-4 -5 -6;-7 -8 -9]
 
73
 f  =
 
74
 
 
75
! - 1.  - 2.  - 3. !
 
76
!   0.    0.    0. !
 
77
! - 4.  - 5.  - 6. !
 
78
!   0.    0.    0. !
 
79
! - 7.  - 8.  - 9. !
 
80
 
 
81
g=[i,2,3;1 i 3;1 2 i]
 
82
 g  =
 
83
 
 
84
!   i      2.     3.  !
 
85
!   1.     i      3.  !
 
86
!   1.     2.     i   !
 
87
 
 
88
h=[i 1 2 i 3]
 
89
 h  =
 
90
 
 
91
!   i      1.    2.    i      3. !
 
92
 
 
93
o=[1 i i 2 3]'
 
94
 o  =
 
95
 
 
96
!   1.  !
 
97
! - i   !
 
98
! - i   !
 
99
!   2.  !
 
100
!   3.  !
 
101
 
 
102
b(2)=3
 
103
 b  =
 
104
 
 
105
!   1.    3.    3. !
 
106
 
 
107
e1(1,3)=1
 
108
 e1  =
 
109
 
 
110
!   1.    2.     1.     4.  !
 
111
!   5.    6.     7.     8.  !
 
112
!   9.    10.    11.    12. !
 
113
 
 
114
p='apcdefghijklmnopqrstuvwxyz0123456789'
 
115
 p  =
 
116
 
 
117
 apcdefghijklmnopqrstuvwxyz0123456789   
 
118
 
 
119
// test de stackg
 
120
 
 
121
a,b,c,d,e1,f,g,h,o,p
 
122
 a  =
 
123
 
 
124
    1.  
 
125
 b  =
 
126
 
 
127
!   1.    3.    3. !
 
128
 c  =
 
129
 
 
130
!   1.    2.    3. !
 
131
!   4.    5.    6. !
 
132
 d  =
 
133
 
 
134
!   1.    2. !
 
135
!   3.    4. !
 
136
 e1  =
 
137
 
 
138
!   1.    2.     1.     4.  !
 
139
!   5.    6.     7.     8.  !
 
140
!   9.    10.    11.    12. !
 
141
 f  =
 
142
 
 
143
! - 1.  - 2.  - 3. !
 
144
!   0.    0.    0. !
 
145
! - 4.  - 5.  - 6. !
 
146
!   0.    0.    0. !
 
147
! - 7.  - 8.  - 9. !
 
148
 g  =
 
149
 
 
150
!   i      2.     3.  !
 
151
!   1.     i      3.  !
 
152
!   1.     2.     i   !
 
153
 h  =
 
154
 
 
155
!   i      1.    2.    i      3. !
 
156
 o  =
 
157
 
 
158
!   1.  !
 
159
! - i   !
 
160
! - i   !
 
161
!   2.  !
 
162
!   3.  !
 
163
 p  =
 
164
 
 
165
 apcdefghijklmnopqrstuvwxyz0123456789   
 
166
 
 
167
b(2)
 
168
 ans  =
 
169
 
 
170
    3.  
 
171
 
 
172
e1(1,3)
 
173
 ans  =
 
174
 
 
175
    1.  
 
176
 
 
177
e1([1 2],[3 4])
 
178
 ans  =
 
179
 
 
180
!   1.    4. !
 
181
!   7.    8. !
 
182
 
 
183
e1(1:2,:)
 
184
 ans  =
 
185
 
 
186
!   1.    2.    1.    4. !
 
187
!   5.    6.    7.    8. !
 
188
 
 
189
e1(:,4)
 
190
 ans  =
 
191
 
 
192
!   4.  !
 
193
!   8.  !
 
194
!   12. !
 
195
 
 
196
e1(:,:)
 
197
 ans  =
 
198
 
 
199
!   1.    2.     1.     4.  !
 
200
!   5.    6.     7.     8.  !
 
201
!   9.    10.    11.    12. !
 
202
 
 
203
g(1,1)
 
204
 ans  =
 
205
 
 
206
    i    
 
207
 
 
208
g(:,1)
 
209
 ans  =
 
210
 
 
211
!   i   !
 
212
!   1.  !
 
213
!   1.  !
 
214
 
 
215
g(1:2,:)
 
216
 ans  =
 
217
 
 
218
!   i      2.     3. !
 
219
!   1.     i      3. !
 
220
 
 
221
g(:,:)
 
222
 ans  =
 
223
 
 
224
!   i      2.     3.  !
 
225
!   1.     i      3.  !
 
226
!   1.     2.     i   !
 
227
 
 
228
o'
 
229
 ans  =
 
230
 
 
231
!   1.    i      i      2.    3. !
 
232
 
 
233
//test de stack2
 
234
 
 
235
//
 
236
 
 
237
// additions...
 
238
 
 
239
[1 2 3;4 5 6]-[1 2 3;4 5 6]
 
240
 ans  =
 
241
 
 
242
!   0.    0.    0. !
 
243
!   0.    0.    0. !
 
244
 
 
245
[1 2 3;4 5 6]+2*[1 2 3;4 5 6]-[1 2 3;4 5 6]*3
 
246
 ans  =
 
247
 
 
248
!   0.    0.    0. !
 
249
!   0.    0.    0. !
 
250
 
 
251
[1 i 3;4 5 i]+2*[1 i 3;4 5 i]-[1 i 3;4 5 i]*3
 
252
 ans  =
 
253
 
 
254
!   0    0    0 !
 
255
!   0    0    0 !
 
256
 
 
257
[2*i -4*i 2*i]+2*[i -2*i i]+i*[2 -4 2]-[i -2*i i]*2 -2*[2 -4 2]*i
 
258
 ans  =
 
259
 
 
260
!   0    0    0 !
 
261
 
 
262
//
 
263
 
 
264
2\[4 8 16]/2-[1 2 4]
 
265
 ans  =
 
266
 
 
267
!   0.    0.    0. !
 
268
 
 
269
i\[2*i 2 i*4]/i-[-i*2 -2 -4*i]
 
270
 ans  =
 
271
 
 
272
!   0    0    0 !
 
273
 
 
274
// element wise operations
 
275
 
 
276
[1 2;3 4;5 6].*[1 2;3 4;5 6]-[1 4;9 16;25 36]
 
277
 ans  =
 
278
 
 
279
!   0.    0. !
 
280
!   0.    0. !
 
281
!   0.    0. !
 
282
 
 
283
[1 2;3 4;5 6*i].*[1 2;3 4;5 6]-[1 4;9 16;25 36*i]
 
284
 ans  =
 
285
 
 
286
!   0    0 !
 
287
!   0    0 !
 
288
!   0    0 !
 
289
 
 
290
[1 2;3 4;5 6].*[1 2;3 4;5 6*i]-[1 4;9 16;25 36*i]
 
291
 ans  =
 
292
 
 
293
!   0    0 !
 
294
!   0    0 !
 
295
!   0    0 !
 
296
 
 
297
[1 2;3 4;5 6*i].*[1 2;3 4;5 6*i]-[1 4;9 16;25 -36]
 
298
 ans  =
 
299
 
 
300
!   0    0 !
 
301
!   0    0 !
 
302
!   0    0 !
 
303
 
 
304
//
 
305
 
 
306
[2 9 8;3 10 15]./[2 3 4;3 5 5]-[1 3 2;1 2 3]
 
307
 ans  =
 
308
 
 
309
!   0.    0.    0. !
 
310
!   0.    0.    0. !
 
311
 
 
312
[2 9*i 8;3 10 15]./[2 3 4;3 5 5]-[1 3*i 2;1 2 3]
 
313
 ans  =
 
314
 
 
315
!   0    0    0 !
 
316
!   0    0    0 !
 
317
 
 
318
[2 9 8;3 10 15]./[2*i 3 4;3 5 5]-[-i 3 2;1 2 3]
 
319
 ans  =
 
320
 
 
321
!   0    0    0 !
 
322
!   0    0    0 !
 
323
 
 
324
[2*i 9 8;3 10 15]./[2*i 3 4;3 5 5]-[1 3 2;1 2 3]
 
325
 ans  =
 
326
 
 
327
!   0    0    0 !
 
328
!   0    0    0 !
 
329
 
 
330
//
 
331
 
 
332
[2 3 4;3 5 5].\[2 9 8;3 10 15]-[1 3 2;1 2 3]
 
333
 ans  =
 
334
 
 
335
!   0.    0.    0. !
 
336
!   0.    0.    0. !
 
337
 
 
338
[2 i 4;3 5 5].\[2 9 8;3 10 15]-[1 -9*i 2 ;1 2 3]
 
339
 ans  =
 
340
 
 
341
!   0    0    0 !
 
342
!   0    0    0 !
 
343
 
 
344
[2 3 4;3 5 5].\[i 9 8;3 10 15]-[.5*i 3 2;1 2 3]
 
345
 ans  =
 
346
 
 
347
!   0    0    0 !
 
348
!   0    0    0 !
 
349
 
 
350
[i 3 4;3 5 5].\[i 9 8;3 10 15]-[1 3 2;1 2 3]
 
351
 ans  =
 
352
 
 
353
!   0    0    0 !
 
354
!   0    0    0 !
 
355
 
 
356
//multiplication
 
357
 
 
358
[1 2 3;4 5 6]*[3;2;1]-[10;28]
 
359
 ans  =
 
360
 
 
361
!   0. !
 
362
!   0. !
 
363
 
 
364
[1 i 3;4 5 6]*[3;2;1]-[6+2*i;28]
 
365
 ans  =
 
366
 
 
367
!   0 !
 
368
!   0 !
 
369
 
 
370
[1 2 3;4 5 6]*[i;2;1]-[i+7;4*i+16]
 
371
 ans  =
 
372
 
 
373
!   0 !
 
374
!   0 !
 
375
 
 
376
[1 i 3;2*i,-i,1]*[i;-i;i]-[4*i+1;-3+i]
 
377
 ans  =
 
378
 
 
379
!   0 !
 
380
!   0 !
 
381
 
 
382
//eye
 
383
 
 
384
eye(4,4)
 
385
 ans  =
 
386
 
 
387
!   1.    0.    0.    0. !
 
388
!   0.    1.    0.    0. !
 
389
!   0.    0.    1.    0. !
 
390
!   0.    0.    0.    1. !
 
391
 
 
392
//a+-b*eye a*eye+-b a+-eye*b eye*a+-b
 
393
 
 
394
-2*eye()+[1 2;3 4]+eye()*2-[1 2;3 4]
 
395
 ans  =
 
396
 
 
397
!   0.    0. !
 
398
!   0.    0. !
 
399
 
 
400
-2*i*eye()+[1 2;3 4]+eye()*2*i-[1 2;3 4]
 
401
 ans  =
 
402
 
 
403
!   0    0 !
 
404
!   0    0 !
 
405
 
 
406
// :
 
407
 
 
408
1:10
 
409
 ans  =
 
410
 
 
411
!   1.    2.    3.    4.    5.    6.    7.    8.    9.    10. !
 
412
 
 
413
1:.1:2
 
414
 ans  =
 
415
 
 
416
 
 
417
         column  1 to 10
 
418
 
 
419
!   1.    1.1    1.2    1.3    1.4    1.5    1.6    1.7    1.8    1.9 !
 
420
 
 
421
         column 11
 
422
 
 
423
!   2. !
 
424
 
 
425
// for
 
426
 
 
427
for k=1:3,for l=1:2,a(k,l)=k+l;end;end;a
 
428
 a  =
 
429
 
 
430
!   2.    3. !
 
431
!   3.    4. !
 
432
!   4.    5. !
 
433
 
 
434
diag([1 2 3])-[1 0 0;0 2 0;0 0 3]
 
435
 ans  =
 
436
 
 
437
!   0.    0.    0. !
 
438
!   0.    0.    0. !
 
439
!   0.    0.    0. !
 
440
 
 
441
diag([1 i 2])-[1 0 0;0 i 0;0 0 2]
 
442
 ans  =
 
443
 
 
444
!   0    0    0 !
 
445
!   0    0    0 !
 
446
!   0    0    0 !
 
447
 
 
448
a=[1 2 3 4;5 6 7 8];
 
449
 
 
450
c=a;
 
451
 
 
452
c(1,1)=i;
 
453
 
 
454
diag(a)-[1;6]
 
455
 ans  =
 
456
 
 
457
!   0. !
 
458
!   0. !
 
459
 
 
460
diag(a,1)-[2;7]
 
461
 ans  =
 
462
 
 
463
!   0. !
 
464
!   0. !
 
465
 
 
466
diag(a,-1)-[5]
 
467
 ans  =
 
468
 
 
469
    0.  
 
470
 
 
471
diag(a,4)
 
472
 ans  =
 
473
 
 
474
     []
 
475
 
 
476
diag(c)-[i;6]
 
477
 ans  =
 
478
 
 
479
!   0 !
 
480
!   0 !
 
481
 
 
482
diag(c,1)-[2;7]
 
483
 ans  =
 
484
 
 
485
!   0 !
 
486
!   0 !
 
487
 
 
488
diag(c,-1)-[5]
 
489
 ans  =
 
490
 
 
491
    0  
 
492
 
 
493
diag(c,4)
 
494
 ans  =
 
495
 
 
496
     []
 
497
 
 
498
//
 
499
 
 
500
eye(a)
 
501
 ans  =
 
502
 
 
503
!   1.    0.    0.    0. !
 
504
!   0.    1.    0.    0. !
 
505
 
 
506
eye(c)
 
507
 ans  =
 
508
 
 
509
!   1.    0.    0.    0. !
 
510
!   0.    1.    0.    0. !
 
511
 
 
512
eye(3,3)
 
513
 ans  =
 
514
 
 
515
!   1.    0.    0. !
 
516
!   0.    1.    0. !
 
517
!   0.    0.    1. !
 
518
 
 
519
eye(2,3)
 
520
 ans  =
 
521
 
 
522
!   1.    0.    0. !
 
523
!   0.    1.    0. !
 
524
 
 
525
//
 
526
 
 
527
ones(a)
 
528
 ans  =
 
529
 
 
530
!   1.    1.    1.    1. !
 
531
!   1.    1.    1.    1. !
 
532
 
 
533
ones(c)
 
534
 ans  =
 
535
 
 
536
!   1.    1.    1.    1. !
 
537
!   1.    1.    1.    1. !
 
538
 
 
539
ones(3,3)
 
540
 ans  =
 
541
 
 
542
!   1.    1.    1. !
 
543
!   1.    1.    1. !
 
544
!   1.    1.    1. !
 
545
 
 
546
ones(3,2)
 
547
 ans  =
 
548
 
 
549
!   1.    1. !
 
550
!   1.    1. !
 
551
!   1.    1. !
 
552
 
 
553
//
 
554
 
 
555
rand(a)
 
556
 ans  =
 
557
 
 
558
!   0.2113249    0.0002211    0.6653811    0.8497452 !
 
559
!   0.7560439    0.3303271    0.6283918    0.6857310 !
 
560
 
 
561
rand(c)
 
562
 ans  =
 
563
 
 
564
 
 
565
         column 1 to 2
 
566
 
 
567
!   0.8782165 + 0.2312237i    0.5608486 + 0.8833888i !
 
568
!   0.0683740 + 0.2164633i    0.6623569 + 0.6525135i !
 
569
 
 
570
         column 3 to 4
 
571
 
 
572
!   0.7263507 + 0.3076091i    0.5442573 + 0.2146008i !
 
573
!   0.1985144 + 0.9329616i    0.2320748 + 0.312642i  !
 
574
 
 
575
rand(3,3)
 
576
 ans  =
 
577
 
 
578
!   0.3616361    0.4826472    0.5015342 !
 
579
!   0.2922267    0.3321719    0.4368588 !
 
580
!   0.5664249    0.5935095    0.2693125 !
 
581
 
 
582
rand(3,2)
 
583
 ans  =
 
584
 
 
585
!   0.6325745    0.0437334 !
 
586
!   0.4051954    0.4818509 !
 
587
!   0.9184708    0.2639556 !
 
588
 
 
589
rand()
 
590
 ans  =
 
591
 
 
592
    0.4148104  
 
593
 
 
594
rand('uniform')
 
595
 
 
596
rand('normal')
 
597
 
 
598
rand('seed',5)
 
599
 
 
600
rand('seed',0)
 
601
 
 
602
//
 
603
 
 
604
abs(c)
 
605
 ans  =
 
606
 
 
607
!   1.    2.    3.    4. !
 
608
!   5.    6.    7.    8. !
 
609
 
 
610
abs(a)
 
611
 ans  =
 
612
 
 
613
!   1.    2.    3.    4. !
 
614
!   5.    6.    7.    8. !
 
615
 
 
616
//
 
617
 
 
618
real(c)
 
619
 ans  =
 
620
 
 
621
!   0.    2.    3.    4. !
 
622
!   5.    6.    7.    8. !
 
623
 
 
624
imag(c)
 
625
 ans  =
 
626
 
 
627
!   1.    0.    0.    0. !
 
628
!   0.    0.    0.    0. !
 
629
 
 
630
real(a)
 
631
 ans  =
 
632
 
 
633
!   1.    2.    3.    4. !
 
634
!   5.    6.    7.    8. !
 
635
 
 
636
imag(a)
 
637
 ans  =
 
638
 
 
639
!   0.    0.    0.    0. !
 
640
!   0.    0.    0.    0. !
 
641
 
 
642
//
 
643
 
 
644
round(rand(3,3))
 
645
 ans  =
 
646
 
 
647
! - 1.    1.  - 1. !
 
648
!   1.    1.    1. !
 
649
!   1.    0.    0. !
 
650
 
 
651
//
 
652
 
 
653
conj(a)
 
654
 ans  =
 
655
 
 
656
!   1.    2.    3.    4. !
 
657
!   5.    6.    7.    8. !
 
658
 
 
659
conj(c)
 
660
 ans  =
 
661
 
 
662
! - i      2.    3.    4. !
 
663
!   5.     6.    7.    8. !
 
664
 
 
665
//
 
666
 
 
667
size(a)
 
668
 ans  =
 
669
 
 
670
!   2.    4. !
 
671
 
 
672
[m,n]=size(a)
 
673
 n  =
 
674
 
 
675
    4.  
 
676
 m  =
 
677
 
 
678
    2.  
 
679
 
 
680
//
 
681
 
 
682
triu(a)
 
683
 ans  =
 
684
 
 
685
!   1.    2.    3.    4. !
 
686
!   0.    6.    7.    8. !
 
687
 
 
688
tril(a)
 
689
 ans  =
 
690
 
 
691
!   1.    0.    0.    0. !
 
692
!   5.    6.    0.    0. !
 
693
 
 
694
triu(a,1)
 
695
 ans  =
 
696
 
 
697
!   0.    2.    3.    4. !
 
698
!   0.    0.    7.    8. !
 
699
 
 
700
triu(a,-1)
 
701
 ans  =
 
702
 
 
703
!   1.    2.    3.    4. !
 
704
!   5.    6.    7.    8. !
 
705
 
 
706
tril(a,1)
 
707
 ans  =
 
708
 
 
709
!   1.    2.    0.    0. !
 
710
!   5.    6.    7.    0. !
 
711
 
 
712
tril(a,-1)
 
713
 ans  =
 
714
 
 
715
!   0.    0.    0.    0. !
 
716
!   5.    0.    0.    0. !
 
717
 
 
718
triu(c)
 
719
 ans  =
 
720
 
 
721
!   i      2.    3.    4. !
 
722
!   0      6.    7.    8. !
 
723
 
 
724
tril(c)
 
725
 ans  =
 
726
 
 
727
!   i      0     0    0 !
 
728
!   5.     6.    0    0 !
 
729
 
 
730
triu(c,1)
 
731
 ans  =
 
732
 
 
733
!   0    2.    3.    4. !
 
734
!   0    0     7.    8. !
 
735
 
 
736
triu(c,10)
 
737
 ans  =
 
738
 
 
739
!   0    0    0    0 !
 
740
!   0    0    0    0 !
 
741
 
 
742
triu(c,-1)
 
743
 ans  =
 
744
 
 
745
!   i      2.    3.    4. !
 
746
!   5.     6.    7.    8. !
 
747
 
 
748
triu(c,-10)
 
749
 ans  =
 
750
 
 
751
!   i      2.    3.    4. !
 
752
!   5.     6.    7.    8. !
 
753
 
 
754
tril(c,1)
 
755
 ans  =
 
756
 
 
757
!   i      2.    0     0 !
 
758
!   5.     6.    7.    0 !
 
759
 
 
760
tril(c,10)
 
761
 ans  =
 
762
 
 
763
!   i      2.    3.    4. !
 
764
!   5.     6.    7.    8. !
 
765
 
 
766
tril(c,-1)
 
767
 ans  =
 
768
 
 
769
!   0     0    0    0 !
 
770
!   5.    0    0    0 !
 
771
 
 
772
tril(c,-10)
 
773
 ans  =
 
774
 
 
775
!   0    0    0    0 !
 
776
!   0    0    0    0 !
 
777
 
 
778
//test de matlu
 
779
 
 
780
a=rand(4,4);b=rand(5,4);ac=a+i*rand(4,4);bc=b+i*rand(5,4);
 
781
 
 
782
//
 
783
 
 
784
if abs((1/a)*a-eye())> 10*%eps then bugmes();quit;end
 
785
 
 
786
if abs((i/a)*a-i*eye())> 10*%eps then bugmes();quit;end
 
787
 
 
788
if abs((1/ac)*ac-eye())> 10*%eps then bugmes();quit;end
 
789
 
 
790
if abs((i/ac)*ac-i*eye())> 10*%eps then bugmes();quit;end
 
791
 
 
792
if abs(a*(a\1)-eye())> 10*%eps then bugmes();quit;end
 
793
 
 
794
if abs(a*(a\i)-i*eye())> 10*%eps then bugmes();quit;end
 
795
 
 
796
if abs(ac*(ac\1)-eye())> 10*%eps then bugmes();quit;end
 
797
 
 
798
if abs(ac*(ac\i)-eye()*i)> 10*%eps then bugmes();quit;end
 
799
 
 
800
//
 
801
 
 
802
if abs(inv(a)*a-eye())> 10*%eps then bugmes();quit;end
 
803
 
 
804
if abs(inv(ac)*ac-eye())> 10*%eps then bugmes();quit;end
 
805
 
 
806
//
 
807
 
 
808
if abs((b/a)*a-b)> 10*%eps then bugmes();quit;end
 
809
 
 
810
if abs((b/ac)*ac-b)> 10*%eps then bugmes();quit;end
 
811
 
 
812
if abs((bc/a)*a-bc)> 10*%eps then bugmes();quit;end
 
813
 
 
814
if abs((bc/ac)*ac-bc)> 10*%eps then bugmes();quit;end
 
815
 
 
816
//
 
817
 
 
818
if abs(a*(a\b')-b')> 10*%eps then bugmes();quit;end
 
819
 
 
820
if abs(ac*(ac\b')-b')> 10*%eps then bugmes();quit;end
 
821
 
 
822
if abs(a*(a\bc')-bc')> 10*%eps then bugmes();quit;end
 
823
 
 
824
if abs(ac*(ac\bc')-bc')> 10*%eps then bugmes();quit;end
 
825
 
 
826
//
 
827
 
 
828
[l u]=lu(a);
 
829
 
 
830
if abs(l*u-a)> 10*%eps then bugmes();quit;end
 
831
 
 
832
[l u]=lu(ac);
 
833
 
 
834
if abs(l*u-ac)> 10*%eps then bugmes();quit;end
 
835
 
 
836
//
 
837
 
 
838
h1(5,5)=0;for k=1:5,for l=1:5, h1(k,l)=1/(k+l-1);end;end;
 
839
 
 
840
if abs(inv(h1)-testmatrix('hilb',5))> 1.e-7 then bugmes();quit;end
 
841
 
 
842
//
 
843
 
 
844
if abs(det(testmatrix('magic',5))-5070000)> 1.e-7 then bugmes();quit;end
 
845
 
 
846
//
 
847
 
 
848
b=a*a';h=chol(b);
 
849
 
 
850
if abs(h'*h-b)> 10*%eps then bugmes();quit;end
 
851
 
 
852
bc=triu(ac*ac');bc=bc+bc'-diag(real(diag(bc)));;h=chol(bc);
 
853
 
 
854
if abs(h'*h-bc)> 10*%eps then bugmes();quit;end
 
855
 
 
856
//test de matqr
 
857
 
 
858
a=rand(3,4);b=rand(3,4);ac=a+i*rand(3,4);bc=b+i*rand(3,4);
 
859
 
 
860
//
 
861
 
 
862
if abs(a*(1/a)*a-a)> 10*%eps then bugmes();quit;end
 
863
 
 
864
if abs(a*(i/a)*a-i*a)> 10*%eps then bugmes();quit;end
 
865
 
 
866
if abs(a*(a\ 1)*a-a)> 10*%eps then bugmes();quit;end
 
867
 
 
868
if abs(a*(a\ i)*a-i*a)> 10*%eps then bugmes();quit;end
 
869
 
 
870
if abs(ac*(1/ac)*ac-ac)> 10*%eps then bugmes();quit;end
 
871
 
 
872
if abs(ac*(i/ac)*ac-i*ac)> 10*%eps then bugmes();quit;end
 
873
 
 
874
if abs(ac*(ac\ 1)*ac-ac)> 10*%eps then bugmes();quit;end
 
875
 
 
876
if abs(ac*(ac\ i)*ac-i*ac)> 10*%eps then bugmes();quit;end
 
877
 
 
878
//
 
879
 
 
880
if abs(a/b-a*(1/b))> 10*%eps then bugmes();quit;end
 
881
 
 
882
if abs(ac/b-ac*(1/b))> 10*%eps then bugmes();quit;end
 
883
 
 
884
if abs(a/bc-a*(1/bc))> 10*%eps then bugmes();quit;end
 
885
 
 
886
if abs(ac/bc-ac*(1/bc))> 10*%eps then bugmes();quit;end
 
887
 
 
888
//
 
889
 
 
890
if abs(a\ b -(a\ 1)*b)> 10*%eps then bugmes();quit;end
 
891
 
 
892
if abs(a\ bc-(a\ 1)*bc)> 10*%eps then bugmes();quit;end
 
893
 
 
894
if abs(ac\ b-(ac\ 1)*b)> 10*%eps then bugmes();quit;end
 
895
 
 
896
if abs(ac\ bc-(ac\ 1)*bc)> 10*%eps then bugmes();quit;end
 
897
 
 
898
//
 
899
 
 
900
//elemt-wise
 
901
 
 
902
a=rand(3,2);ai=a+rand(3,2)*%i;
 
903
 
 
904
de=2;
 
905
 
 
906
if norm(ai.*de-ai*de,1) >1000*%eps then bugmes();quit;end
 
907
 
 
908
if norm(de.*ai-de*ai,1) >1000*%eps then bugmes();quit;end
 
909
 
 
910
if norm(ai.*de-ai*de,1) >1000*%eps then bugmes();quit;end
 
911
 
 
912
if norm(de.*ai-de*ai,1) >1000*%eps then bugmes();quit;end
 
913
 
 
914
de=de+3*%i;
 
915
 
 
916
if norm(ai.*de-ai*de,1) >1000*%eps then bugmes();quit;end
 
917
 
 
918
if norm(de.*ai-de*ai,1) >1000*%eps then bugmes();quit;end
 
919
 
 
920
if norm(ai.*de-ai*de,1) >1000*%eps then bugmes();quit;end
 
921
 
 
922
if norm(de.*ai-de*ai,1) >1000*%eps then bugmes();quit;end
 
923
 
 
924
//
 
925
 
 
926
de=2;def=de*ones(a);
 
927
 
 
928
if norm(a./de-a./def,1) >1000*%eps then bugmes();quit;end
 
929
 
 
930
if norm(ai./de-ai./def,1) >1000*%eps then bugmes();quit;end
 
931
 
 
932
//
 
933
 
 
934
de=2+3*%i;def=de*ones(a);
 
935
 
 
936
if norm(a./de-a./def,1) >1000*%eps then bugmes();quit;end
 
937
 
 
938
if norm(ai./de-ai./def,1) >1000*%eps then bugmes();quit;end
 
939
 
 
940
de=2;def=de*ones(a);
 
941
 
 
942
if norm(a.\de-a.\def,1) >1000*%eps then bugmes();quit;end
 
943
 
 
944
if norm(ai.\de-ai.\def,1) >1000*%eps then bugmes();quit;end
 
945
 
 
946
//
 
947
 
 
948
de=2+3*%i;def=de*ones(a);
 
949
 
 
950
if norm(a.\de-a.\def,1) >1000*%eps then bugmes();quit;end
 
951
 
 
952
if norm(ai.\de-ai.\def,1) >1000*%eps then bugmes();quit;end
 
953
 
 
954
 
 
955
///////////
 
956
 
 
957
de=2;def=de*ones(a);
 
958
 
 
959
if norm(de.\a-de.\a,1) >1000*%eps then bugmes();quit;end
 
960
 
 
961
if norm(de.\ai-def.\ai,1) >1000*%eps then bugmes();quit;end
 
962
 
 
963
//
 
964
 
 
965
de=2+3*%i;def=de*ones(a);
 
966
 
 
967
if norm(de.\a-def.\a,1) >1000*%eps then bugmes();quit;end
 
968
 
 
969
if norm(de.\ai-def.\ai,1) >1000*%eps then bugmes();quit;end
 
970
 
 
971
de=2;def=de*ones(a);
 
972
 
 
973
if norm(de./a-def./a,1) >1000*%eps then bugmes();quit;end
 
974
 
 
975
if norm(de./ai-def./ai,1) >1000*%eps then bugmes();quit;end
 
976
 
 
977
//
 
978
 
 
979
de=2+3*%i;def=de*ones(a);
 
980
 
 
981
if norm(de./a-def./a,1) >1000*%eps then bugmes();quit;end
 
982
 
 
983
if norm(de./ai-def./ai,1) >1000*%eps then bugmes();quit;end
 
984
 
 
985
//
 
986
 
 
987
[p,r]=qr(a);
 
988
 
 
989
if abs(p*r-a)> 10*%eps then bugmes();quit;end
 
990
 
 
991
[p,r]=qr(a');
 
992
 
 
993
if abs(p*r-a')> 10*%eps then bugmes();quit;end
 
994
 
 
995
[p,r,x]=qr(a);
 
996
 
 
997
if abs(p*r*x'-a)> 10*%eps then bugmes();quit;end
 
998
 
 
999
[p,r]=qr(ac);
 
1000
 
 
1001
if abs(p*r-ac)> 10*%eps then bugmes();quit;end
 
1002
 
 
1003
[p,r,x]=qr(ac);
 
1004
 
 
1005
if abs(p*r-ac*x)> 10*%eps then bugmes();quit;end
 
1006
 
 
1007
//
 
1008
 
 
1009
if abs(cond(diag([1 2 3 4]))-4)> 10*%eps then bugmes();quit;end
 
1010
 
 
1011
if abs(cond(diag([1 i 3 4]))-4)> 10*%eps then bugmes();quit;end
 
1012
 
 
1013
v=[1 2 3 4 5];
 
1014
 
 
1015
if abs(norm(v,1)-15)> 10*%eps then bugmes();quit;end
 
1016
 
 
1017
if abs(norm(v,'inf')-5)> 10*%eps then bugmes();quit;end
 
1018
 
 
1019
if abs(norm(v,2)-sqrt(55))> 10*%eps then bugmes();quit;end
 
1020
 
 
1021
if abs(norm(v,'fro')-sqrt(55))> 10*%eps then bugmes();quit;end
 
1022
 
 
1023
v=v';
 
1024
 
 
1025
if abs(norm(v,1)-15)> 10*%eps then bugmes();quit;end
 
1026
 
 
1027
if abs(norm(v,'inf')-5)> 10*%eps then bugmes();quit;end
 
1028
 
 
1029
if abs(norm(v,2)-sqrt(55))> 10*%eps then bugmes();quit;end
 
1030
 
 
1031
if abs(norm(v,'fro')-sqrt(55))> 10*%eps then bugmes();quit;end
 
1032
 
 
1033
v=[i 2 3 4 5];
 
1034
 
 
1035
if abs(norm(v,'inf')-5)> 10*%eps then bugmes();quit;end
 
1036
 
 
1037
if abs(norm(v,2)-sqrt(55))> 10*%eps then bugmes();quit;end
 
1038
 
 
1039
if abs(norm(v,'fro')-sqrt(55))> 10*%eps then bugmes();quit;end
 
1040
 
 
1041
v=v';
 
1042
 
 
1043
if abs(norm(v,1)-15)> 10*%eps then bugmes();quit;end
 
1044
 
 
1045
if abs(norm(v,'inf')-5)> 10*%eps then bugmes();quit;end
 
1046
 
 
1047
if abs(norm(v,2)-sqrt(55))> 10*%eps then bugmes();quit;end
 
1048
 
 
1049
if abs(norm(v,'fro')-sqrt(55))> 10*%eps then bugmes();quit;end
 
1050
 
 
1051
a=[diag([1 2 3]);[0 0 0]];
 
1052
 
 
1053
if abs(norm(a,1)-3)> 10*%eps then bugmes();quit;end
 
1054
 
 
1055
if abs(norm(a,'inf')-3)> 10*%eps then bugmes();quit;end
 
1056
 
 
1057
if abs(norm(a,2)-3)> 10*%eps then bugmes();quit;end
 
1058
 
 
1059
if abs(norm(a,'fro')-sqrt(14))> 10*%eps then bugmes();quit;end
 
1060
 
 
1061
a=a';
 
1062
 
 
1063
if abs(norm(a,1)-3)> 10*%eps then bugmes();quit;end
 
1064
 
 
1065
if abs(norm(a,'inf')-3)> 10*%eps then bugmes();quit;end
 
1066
 
 
1067
if abs(norm(a,2)-3)> 10*%eps then bugmes();quit;end
 
1068
 
 
1069
if abs(norm(a,'fro')-sqrt(14))> 10*%eps then bugmes();quit;end
 
1070
 
 
1071
a=[diag([i,2,3]),[0;0;0]];
 
1072
 
 
1073
if abs(norm(a,'inf')-3)> 10*%eps then bugmes();quit;end
 
1074
 
 
1075
if abs(norm(a,2)-3)> 10*%eps then bugmes();quit;end
 
1076
 
 
1077
if abs(norm(a,'fro')-sqrt(14))> 10*%eps then bugmes();quit;end
 
1078
 
 
1079
a=a';
 
1080
 
 
1081
if abs(norm(a,1)-3)> 10*%eps then bugmes();quit;end
 
1082
 
 
1083
if abs(norm(a,'inf')-3)> 10*%eps then bugmes();quit;end
 
1084
 
 
1085
if abs(norm(a,2)-3)> 10*%eps then bugmes();quit;end
 
1086
 
 
1087
if abs(norm(a,'fro')-sqrt(14))> 10*%eps then bugmes();quit;end
 
1088
 
 
1089
//
 
1090
 
 
1091
a=rand(3,5);ac=a+i*rand(3,5);
 
1092
 
 
1093
[u,s,v]=svd(a);u*s*v'-a;
 
1094
 
 
1095
if abs(svd(a)-diag(s))> 10*%eps then bugmes();quit;end
 
1096
 
 
1097
[u,s,v]=svd(ac);u*s*v'-ac;
 
1098
 
 
1099
if abs(svd(ac)-diag(s))> 10*%eps then bugmes();quit;end
 
1100
 
 
1101
//
 
1102
 
 
1103
[u,s,v]=svd(a,0);u*s*v'-a;
 
1104
 
 
1105
if abs(svd(a,0)-diag(s,0))> 10*%eps then bugmes();quit;end
 
1106
 
 
1107
[u,s,v]=svd(ac,0);u*s*v'-ac;
 
1108
 
 
1109
if abs(svd(ac,0)-diag(s))> 10*%eps then bugmes();quit;end
 
1110
 
 
1111
a=a';ac=ac';
 
1112
 
 
1113
a=rand(3,5);ac=a+i*rand(3,5);
 
1114
 
 
1115
[u,s,v]=svd(a);u*s*v'-a;
 
1116
 
 
1117
if abs(svd(a)-diag(s))> 10*%eps then bugmes();quit;end
 
1118
 
 
1119
[u,s,v]=svd(ac);u*s*v'-ac;
 
1120
 
 
1121
if abs(svd(ac)-diag(s))> 10*%eps then bugmes();quit;end
 
1122
 
 
1123
//
 
1124
 
 
1125
[u,s,v]=svd(a,0);u*s*v'-a;
 
1126
 
 
1127
if abs(svd(a,0)-diag(s,0))> 10*%eps then bugmes();quit;end
 
1128
 
 
1129
[u,s,v]=svd(ac,0);u*s*v'-ac;
 
1130
 
 
1131
if abs(svd(ac,0)-diag(s))> 10*%eps then bugmes();quit;end
 
1132
 
 
1133
//
 
1134
 
 
1135
if abs(a*pinv(a)*a-a)> 10*%eps then bugmes();quit;end
 
1136
 
 
1137
if abs(ac*pinv(ac)*ac -ac)> 10*%eps then bugmes();quit;end
 
1138
 
 
1139
a=a';ac=ac';
 
1140
 
 
1141
if abs(a*pinv(a)*a-a)> 10*%eps then bugmes();quit;end
 
1142
 
 
1143
if abs(ac*pinv(ac)*ac-ac)> 10*%eps then bugmes();quit;end
 
1144
 
 
1145
//
 
1146
 
 
1147
if abs(rank(a)-3)> 10*%eps then bugmes();quit;end
 
1148
 
 
1149
if abs(rank(ac)-3)> 10*%eps then bugmes();quit;end
 
1150
 
 
1151
rand('seed',0)
 
1152
 
 
1153
// matdsr  matdsc
 
1154
 
 
1155
a=rand(4,4);ac=a+i*rand(4,4);t=a*a';tc=ac*ac';
 
1156
 
 
1157
tc=triu(tc,1)+triu(tc,1)'+diag(real(diag(tc)));
 
1158
 
 
1159
//
 
1160
 
 
1161
//hess
 
1162
 
 
1163
[u,h]=hess(a);
 
1164
 
 
1165
if norm(u*h*u'-a,1) > 20*%eps then bugmes();quit;end
 
1166
 
 
1167
if abs(norm(h-hess(a),1))> 10*%eps then bugmes();quit;end
 
1168
 
 
1169
[u,h]=hess(ac);
 
1170
 
 
1171
if norm(u*h*u'-ac,1) > 200*%eps then bugmes();quit;end
 
1172
 
 
1173
if abs(norm(h-hess(ac),1))> 10*%eps then bugmes();quit;end
 
1174
 
 
1175
[u,h]=hess(t);
 
1176
 
 
1177
if norm(u*h*u'-t,1)  > 200*%eps then bugmes();quit;end
 
1178
 
 
1179
if abs(norm(h-hess(t),1))> 10*%eps then bugmes();quit;end
 
1180
 
 
1181
[u,h]=hess(tc);
 
1182
 
 
1183
if norm(u*h*u'-tc,1)  > 200*%eps then bugmes();quit;end
 
1184
 
 
1185
if abs(norm(h-hess(tc),1))> 10*%eps then bugmes();quit;end
 
1186
 
 
1187
//schur
 
1188
 
 
1189
[u,s]=schur(a);
 
1190
 
 
1191
if norm(u*s*u'-a,1 ) > 200*%eps then bugmes();quit;end
 
1192
 
 
1193
if norm(s-schur(a),1 ) > 200*%eps then bugmes();quit;end
 
1194
 
 
1195
if norm(spec(a)-spec(s),1)> 200*%eps then bugmes();quit;end
 
1196
 
 
1197
[u,s]=schur(ac);
 
1198
 
 
1199
if norm(u*s*u'-ac,1 ) > 200*%eps then bugmes();quit;end
 
1200
 
 
1201
if norm(s-schur(ac),1 ) > 200*%eps then bugmes();quit;end
 
1202
 
 
1203
if norm(spec(ac)-spec(s),1)> 200*%eps then bugmes();quit;end
 
1204
 
 
1205
[u,s]=schur(t);
 
1206
 
 
1207
if norm(u*s*u'-t,1 ) > 200*%eps then bugmes();quit;end
 
1208
 
 
1209
if norm(s-schur(t),1 ) > 200*%eps then bugmes();quit;end
 
1210
 
 
1211
if norm(diag(s)-spec(t),1)> 200*%eps then bugmes();quit;end
 
1212
 
 
1213
[u,s]=schur(tc);
 
1214
 
 
1215
if norm(u*s*u'-tc,1 ) > 200*%eps then bugmes();quit;end
 
1216
 
 
1217
if norm(s-schur(tc),1 ) > 200*%eps then bugmes();quit;end
 
1218
 
 
1219
if norm(diag(s)-spec(tc),1) > 200*%eps then bugmes();quit;end
 
1220
 
 
1221
// fonctions matricielles
 
1222
 
 
1223
s=sqrtm(t);
 
1224
 
 
1225
if norm(t-s*s,1) > 200*%eps then bugmes();quit;end
 
1226
 
 
1227
s=logm(t);
 
1228
 
 
1229
if norm(t-expm(s)) > 200*%eps then bugmes();quit;end
 
1230
 
 
1231
s=sqrtm(tc);
 
1232
 
 
1233
if norm(tc-s*s,1) > 220*%eps then bugmes();quit;end
 
1234
 
 
1235
s=expm(tc);s=triu(s,1)+triu(s,1)'+diag(real(diag(s)));
 
1236
 
 
1237
if norm(logm(s)-tc,1)> 1.e-9 then bugmes();quit;end
 
1238
 
 
1239
if norm(sinm(t)**2+cosm(t)**2-eye(),1) > 22*%eps then bugmes();quit;end
 
1240
 
 
1241
// jpc --> 20 remplace par 25 pour gc-win32
 
1242
 
 
1243
if norm(sinm(tc)**2+cosm(tc)**2-eye(),1) > 25*%eps then bugmes();quit;end
 
1244
 
 
1245
//poly et root
 
1246
 
 
1247
p=rand(5,1);pc=p+i*rand(5,1);x=poly(0,'x');
 
1248
 
 
1249
if norm(sort(p )-sort(real(roots(poly(p,'x'))))) > 1000*%eps then bugmes();quit;end
 
1250
 
 
1251
if norm(sort(imag(pc))-sort(real(roots(poly(imag(pc),'x'))))) > 1000*%eps then bugmes();quit;end
 
1252
 
 
1253
//**
 
1254
 
 
1255
if norm(t^(-1)-inv(t),1) > 200*%eps then bugmes();quit;end
 
1256
 
 
1257
if norm(tc**(-1)-inv(tc),1) > 200*%eps then bugmes();quit;end
 
1258
 
 
1259
x=rand()+i*rand();
 
1260
 
 
1261
if norm((t**x)*(t^(-x))-eye(),1) > 200*%eps then bugmes();quit;end
 
1262
 
 
1263
if norm((tc**x)*(tc**(-x))-eye(),1) > 200*%eps then bugmes();quit;end
 
1264
 
 
1265
//element op
 
1266
 
 
1267
if norm(sin([0 pi/2 pi 3*pi/2])-[0 1 0 -1],1) > 10*%eps then bugmes();quit;end
 
1268
 
 
1269
if norm(cos([0 pi/2 pi 3*pi/2])-[1 0 -1 0],1) > 10*%eps then bugmes();quit;end
 
1270
 
 
1271
if norm(log([e 1/e e**2])-[1 -1 2],1) > 10*%eps then bugmes();quit;end
 
1272
 
 
1273
if norm(exp([1 -1 2])-[e 1/e e**2],1) > 10*%eps then bugmes();quit;end
 
1274
 
 
1275
if norm(sqrt([1 -1 4])-[1 i 2],1) > 10*%eps then bugmes();quit;end
 
1276
 
 
1277
if norm(sin(x)-(exp(i*x)-exp(-i*x))/(2*i),1) > 10*%eps then bugmes();quit;end
 
1278
 
 
1279
if norm(cos(x)-(exp(i*x)+exp(-i*x))/2,1) > 10*%eps then bugmes();quit;end
 
1280
 
 
1281
if norm(sqrt(x)^2-x,1) > 10*%eps then bugmes();quit;end
 
1282
 
 
1283
if norm(log(exp(x))-x,1) > 10*%eps then bugmes();quit;end
 
1284
 
 
1285
// triu
 
1286
 
 
1287
z=poly(0,'z');a=[z 1 -z+1  8;z*z 10*z 5 -z;3 7 z+1 -1-z];
 
1288
 
 
1289
[m,n]=size(a);mn=mini([m n]);a1=a;l=1;
 
1290
 
 
1291
//
 
1292
 
 
1293
for dg=-(m-1):0,
 
1294
   if norm(coeff(triu(a,dg)-a1),1)>%eps then dg,bugmes();quit;end,
 
1295
   for k=1:l,a1(-dg+k,k)=0;end,l=mini([l+1,mn]);end
 
1296
 
 
1297
for dg=1:n,
 
1298
   if norm(coeff(triu(a,dg)-a1),1)>%eps then dg,bugmes();quit;end,
 
1299
   if dg>(n-m),l=l-1;end;for k=1:l,a1(k,dg+k)=0;end;end;
 
1300
 
 
1301
//
 
1302
 
 
1303
a=a';a1=a;[m,n]=size(a);mn=mini([m,n]);l=1;
 
1304
 
 
1305
for dg=-(m-1):0,
 
1306
   if norm(coeff(triu(a,dg)-a1),1)>%eps then dg,bugmes();quit;end,
 
1307
   for k=1:l,a1(-dg+k,k)=0;end,l=mini([l+1,mn]);end
 
1308
 
 
1309
for dg=1:n,
 
1310
   if norm(coeff(triu(a,dg)-a1),1)>%eps then dg,bugmes();quit;end,
 
1311
   if dg>(n-m),l=l-1;end;for k=1:l,a1(k,dg+k)=0;end;end;
 
1312
 
 
1313
//
 
1314
 
 
1315
a=a+%i*[1 2 3 4;5 6 7 8;9 10 11 12]';
 
1316
 
 
1317
[m,n]=size(a);mn=mini([m n]);a1=a;l=1;
 
1318
 
 
1319
//
 
1320
 
 
1321
for dg=-(m-1):0,
 
1322
   if norm(coeff(triu(a,dg)-a1),1)>%eps then dg,bugmes();quit;end,
 
1323
   for k=1:l,a1(-dg+k,k)=0;end,l=mini([l+1,mn]);end
 
1324
 
 
1325
for dg=1:n,
 
1326
   if norm(coeff(triu(a,dg)-a1),1)>%eps then dg,bugmes();quit;end,
 
1327
   if dg>(n-m),l=l-1;end;for k=1:l,a1(k,dg+k)=0;end;end;
 
1328
 
 
1329
//
 
1330
 
 
1331
a=a';a1=a;[m,n]=size(a);mn=mini([m,n]);l=1;
 
1332
 
 
1333
for dg=-(m-1):0,
 
1334
   if norm(coeff(triu(a,dg)-a1),1)>%eps then dg,bugmes();quit;end,
 
1335
   for k=1:l,a1(-dg+k,k)=0;end,l=mini([l+1,mn]);end
 
1336
 
 
1337
for dg=1:n,
 
1338
   if norm(coeff(triu(a,dg)-a1),1)>%eps then dg,bugmes();quit;end,
 
1339
   if dg>(n-m),l=l-1;end;for k=1:l,a1(k,dg+k)=0;end;end;
 
1340
 
 
1341
 
 
1342
//test de clear
 
1343
 
 
1344
x=[1,2,3];
 
1345
 
 
1346
clear x,if exists('x')==1 then bugmes();quit;end
 
1347
 
 
1348
x=[1,2,3];y='afs';
 
1349
 
 
1350
clear x y,if exists('x')==1| exists('y')==1 then bugmes();quit;end
 
1351
 
 
1352
X=[1,2,3];Y='afs';
 
1353
 
 
1354
clear X Y,if exists('X')==1| exists('Y')==1 then bugmes();quit;end
 
1355
 
 
1356
 
 
1357
 
 
1358
//test with scalar vector and matrices
 
1359
 
 
1360
 
 
1361
// REAL VECTORS
 
1362
 
 
1363
x1=1:3;
 
1364
 
 
1365
x0=0:2;
 
1366
 
 
1367
if or(x1^2<>[1 4 9]) then bugmes();quit;end
 
1368
 
 
1369
if or(x0^2<>[0 1 4]) then bugmes();quit;end
 
1370
 
 
1371
if or(x1^0<>[1 1 1]) then bugmes();quit;end
 
1372
 
 
1373
 
 
1374
if norm(x1^(2*(1+%eps))-x1^2)>100*%eps then bugmes();quit;end
 
1375
 
 
1376
if norm(x0^(2*(1+%eps))-x0^2)>100*%eps then bugmes();quit;end
 
1377
 
 
1378
 
 
1379
if norm(x1^(-2)-[1 0.25 1/9])>100*%eps then bugmes();quit;end
 
1380
 
 
1381
if norm(x1^(-2*(1+%eps))-[1 0.25 1/9])>100*%eps then bugmes();quit;end
 
1382
 
 
1383
 
 
1384
// COMPLEX CASE
 
1385
 
 
1386
p=2+%eps*%i;
 
1387
 
 
1388
if norm(x1^p-x1^2)>100*%eps then bugmes();quit;end
 
1389
 
 
1390
if norm(x0^p-x0^2)>100*%eps then bugmes();quit;end
 
1391
 
 
1392
if norm(x1^(-p)-x1^(-2))>100*%eps then bugmes();quit;end
 
1393
 
 
1394
 
 
1395
y=%eps*%eps*ones(1,3);x1=x1+y;x0=x0+y;
 
1396
 
 
1397
if norm(x1^2-[1 4 9])>100*%eps then bugmes();quit;end
 
1398
 
 
1399
if norm(x0^2-[0 1 4])>100*%eps then bugmes();quit;end
 
1400
 
 
1401
 
 
1402
x1^2.000000001;x0^2.000000001;
 
1403
 
 
1404
if norm(x1^2-[1 4 9])>100*%eps then bugmes();quit;end
 
1405
 
 
1406
if norm(x0^2-[0 1 4])>100*%eps then bugmes();quit;end
 
1407
 
 
1408
 
 
1409
if norm(x1^(-2)-[1 0.25 1/9])>100*%eps then bugmes();quit;end
 
1410
 
 
1411
if norm(x1^(-2*(1+%eps))-[1 0.25 1/9])>100*%eps then bugmes();quit;end
 
1412
 
 
1413
if norm(x1^p-x1^2)>100*%eps then bugmes();quit;end
 
1414
 
 
1415
if norm(x0^p-x0^2)>100*%eps then bugmes();quit;end
 
1416
 
 
1417
if norm(x1^(-p)-x1^(-2))>100*%eps then bugmes();quit;end
 
1418
 
 
1419
 
 
1420
//0.^ TEST WITH  REAL VECTORS
 
1421
 
 
1422
 
 
1423
x1=1:3;
 
1424
 
 
1425
x0=0:2;
 
1426
 
 
1427
if or(x1.^2<>[1 4 9]) then bugmes();quit;end
 
1428
 
 
1429
if or(x0.^2<>[0 1 4]) then bugmes();quit;end
 
1430
 
 
1431
if or(x1.^0<>[1 1 1]) then bugmes();quit;end
 
1432
 
 
1433
 
 
1434
if norm(x1.^(2*(1+%eps))-x1.^2)>100*%eps then bugmes();quit;end
 
1435
 
 
1436
if norm(x0.^(2*(1+%eps))-x0.^2)>100*%eps then bugmes();quit;end
 
1437
 
 
1438
 
 
1439
if norm(x1.^(-2)-[1 0.25 1/9])>100*%eps then bugmes();quit;end
 
1440
 
 
1441
if norm(x1.^(-2*(1+%eps))-[1 0.25 1/9])>100*%eps then bugmes();quit;end
 
1442
 
 
1443
 
 
1444
//0.^ TEST WITH  COMPLEX VECTORS
 
1445
 
 
1446
 
 
1447
p=2+%eps*%i;
 
1448
 
 
1449
if norm(x1.^p-x1.^2)>100*%eps then bugmes();quit;end
 
1450
 
 
1451
if norm(x0.^p-x0.^2)>100*%eps then bugmes();quit;end
 
1452
 
 
1453
if norm(x1.^(-p)-x1.^(-2))>100*%eps then bugmes();quit;end
 
1454
 
 
1455
 
 
1456
y=%eps*%eps*ones(1,3);x1=x1+y;x0=x0+y;
 
1457
 
 
1458
if norm(x1.^2-[1 4 9])>100*%eps then bugmes();quit;end
 
1459
 
 
1460
if norm(x0.^2-[0 1 4])>100*%eps then bugmes();quit;end
 
1461
 
 
1462
 
 
1463
x1.^2.000000001;x0.^2.000000001;
 
1464
 
 
1465
if norm(x1.^2-[1 4 9])>100*%eps then bugmes();quit;end
 
1466
 
 
1467
if norm(x0.^2-[0 1 4])>100*%eps then bugmes();quit;end
 
1468
 
 
1469
 
 
1470
if norm(x1.^(-2)-[1 0.25 1/9])>100*%eps then bugmes();quit;end
 
1471
 
 
1472
if norm(x1.^(-2*(1+%eps))-[1 0.25 1/9])>100*%eps then bugmes();quit;end
 
1473
 
 
1474
if norm(x1.^p-x1.^2)>100*%eps then bugmes();quit;end
 
1475
 
 
1476
if norm(x0.^p-x0.^2)>100*%eps then bugmes();quit;end
 
1477
 
 
1478
if norm(x1.^(-p)-x1.^(-2))>100*%eps then bugmes();quit;end
 
1479
 
 
1480
//
 
1481
 
 
1482
// EMPTY MATRIX
 
1483
 
 
1484
//=============
 
1485
 
 
1486
if []^1 <> [] then bugmes();quit;end
 
1487
 
 
1488
if []^[1 2 3] <> [] then bugmes();quit;end
 
1489
 
 
1490
if [1 2 3]^[] <> [] then bugmes();quit;end
 
1491
 
 
1492
if []^[] <> [] then bugmes();quit;end
 
1493
 
 
1494
 
 
1495
// SQUARE MATRIX
 
1496
 
 
1497
//==============
 
1498
 
 
1499
 
 
1500
x1=[1 2;3 4];
 
1501
 
 
1502
if or(x1^1<>x1) then bugmes();quit;end
 
1503
 
 
1504
if or(x1^(-1)<>inv(x1)) then bugmes();quit;end
 
1505
 
 
1506
if or(x1^2<>x1*x1) then bugmes();quit;end
 
1507
 
 
1508
if or(x1^(-2)<>inv(x1)^2) then bugmes();quit;end
 
1509
 
 
1510
 
 
1511
x1(1,1)=x1(1,1)+%i;
 
1512
 
 
1513
if or(x1^2<>x1*x1) then bugmes();quit;end
 
1514
 
 
1515
if or(x1^(-2)<>inv(x1)^2) then bugmes();quit;end
 
1516
 
 
1517
if or(x1^1<>x1) then bugmes();quit;end
 
1518
 
 
1519
if or(x1^(-1)<>inv(x1)) then bugmes();quit;end
 
1520
 
 
1521
 
 
1522
if or(rand(4,4)^0<>eye(4,4)) then bugmes();quit;end
 
1523
 
 
1524
 
 
1525
 
 
1526
x1=[1 2;2 3];x2=x1^(1/2);
 
1527
 
 
1528
if norm(x2^(2)-x1)>100*%eps then bugmes();quit;end
 
1529
 
 
1530
x2=x1^(-1/2);
 
1531
 
 
1532
if norm(x2^(-2)-x1)>100*%eps then bugmes();quit;end
 
1533
 
 
1534
 
 
1535
x1=[1 2+%i;2-%i 3];
 
1536
 
 
1537
x2=x1^(1/2);
 
1538
 
 
1539
if norm(x2^(2)-x1)>100*%eps then bugmes();quit;end
 
1540
 
 
1541
x2=x1^(-1/2);
 
1542
 
 
1543
if norm(x2^(-2)-x1)>100*%eps then bugmes();quit;end
 
1544
 
 
1545
 
 
1546
//TEST WITH POLYNOMIAL VECTOR AND MATRICES
 
1547
 
 
1548
//---------------------------------------
 
1549
 
 
1550
s=poly(0,'s');
 
1551
 
 
1552
if or(coeff(s^3+1)<>[1 0 0 1]) then bugmes();quit;end
 
1553
 
 
1554
 
 
1555
 
 
1556
x1=[1 s+1 s^3+1];
 
1557
 
 
1558
if or(x1^2<>[1 1+2*s+s^2  1+2*s^3+s^6]) then bugmes();quit;end
 
1559
 
 
1560
if or(coeff(x1^0)<>[1 1 1]) then bugmes();quit;end
 
1561
 
 
1562
if or(x1^3<>[1,1+3*s+3*s^2+s^3,1+3*s^3+3*s^6+s^9]) then bugmes();quit;end
 
1563
 
 
1564
if or((x1^(-1)-[1 1/(1+s)  1/(1+s^3)])<>0) then bugmes();quit;end
 
1565
 
 
1566
 
 
1567
x1=[1 s+1 s.^3+1];
 
1568
 
 
1569
if or(x1.^2<>[1 1+2*s+s.^2  1+2*s.^3+s.^6]) then bugmes();quit;end
 
1570
 
 
1571
if or(coeff(x1.^0)<>[1 1 1]) then bugmes();quit;end
 
1572
 
 
1573
if or(x1.^3<>[1,1+3*s+3*s^2+s^3,1+3*s^3+3*s^6+s^9]) then bugmes();quit;end
 
1574
 
 
1575
if or((x1.^(-1)-[1 1/(1+s)  1/(1+s.^3)])<>0) then bugmes();quit;end
 
1576
 
 
1577
 
 
1578
 
 
1579
 
 
1580
 
 
1581
x1=[s+1 2*s;3+4*s^2 4];
 
1582
 
 
1583
if or(x1^1<>x1) then bugmes();quit;end
 
1584
 
 
1585
if or(x1^(-1)<>inv(x1)) then bugmes();quit;end
 
1586
 
 
1587
if or(x1^2<>x1*x1) then bugmes();quit;end
 
1588
 
 
1589
if or(x1^(-2)<>inv(x1)^2) then bugmes();quit;end
 
1590
 
 
1591
 
 
1592
x1(1,1)=x1(1,1)+%i;
 
1593
 
 
1594
if or(x1^2<>x1*x1) then bugmes();quit;end
 
1595
 
 
1596
//if or(x1^(-2)<>inv(x1)^2) then bugmes();quit;end  //simp complexe non implemented
 
1597
 
 
1598
if or(x1^1<>x1) then bugmes();quit;end
 
1599
 
 
1600
//if or(x1^(-1)<>inv(x1)) then bugmes();quit;end //simp complexe non implemented
 
1601
 
 
1602
 
 
1603
 
 
1604
//simple ops
 
1605
 
 
1606
if 1==0 then bugmes();quit;end
 
1607
 
 
1608
if 1<0 then bugmes();quit;end
 
1609
 
 
1610
if 1<=0 then bugmes();quit;end
 
1611
 
 
1612
if 1==1 then,else bugmes();quit;end
 
1613
 
 
1614
if ~(1==1) then bugmes();quit;end
 
1615
 
 
1616
if 0>1 then bugmes();quit;end
 
1617
 
 
1618
if 0>=1 then bugmes();quit;end
 
1619
 
 
1620
if 1<>1 then bugmes();quit;end
 
1621
 
 
1622
if 0<>1 then,else bugmes();quit;end
 
1623
 
 
1624
if '1'=='0' then bugmes();quit;end
 
1625
 
 
1626
if '1'<>'1' then bugmes();quit;end
 
1627
 
 
1628
 
 
1629
%s=poly(0,'s');
 
1630
 
 
1631
if %s==0 then bugmes();quit;end
 
1632
 
 
1633
if 0==%s then bugmes();quit;end
 
1634
 
 
1635
if %s==%s then,else bugmes();quit;end
 
1636
 
 
1637
if %s<>%s then bugmes();quit;end
 
1638
 
 
1639
if %s==%s+1 then bugmes();quit;end
 
1640
 
 
1641
if %s+1==%s then bugmes();quit;end
 
1642
 
 
1643
 
 
1644
if 1/%s==0 then bugmes();quit;end
 
1645
 
 
1646
if 0==1/%s then bugmes();quit;end
 
1647
 
 
1648
if 1/%s==1/%s then,else bugmes();quit;end
 
1649
 
 
1650
if 1/%s<>1/%s then bugmes();quit;end
 
1651
 
 
1652
if 1/%s==1/%s+1 then bugmes();quit;end
 
1653
 
 
1654
if 1/%s+1==1/%s then bugmes();quit;end
 
1655
 
 
1656
if 1/%s<>1/%s+1 then , else  bugmes();quit;end
 
1657
 
 
1658
if 1/%s+1<>1/%s then , else  bugmes();quit;end
 
1659
 
 
1660
 
 
1661
l=list(1,[1 23],'adssa')
 
1662
 l  =
 
1663
 
 
1664
 
 
1665
       l(1)
 
1666
 
 
1667
    1.  
 
1668
 
 
1669
       l(2)
 
1670
 
 
1671
!   1.    23. !
 
1672
 
 
1673
       l(3)
 
1674
 
 
1675
 adssa   
 
1676
 
 
1677
l1=list(123,'sdwqqwq')
 
1678
 l1  =
 
1679
 
 
1680
 
 
1681
       l1(1)
 
1682
 
 
1683
    123.  
 
1684
 
 
1685
       l1(2)
 
1686
 
 
1687
 sdwqqwq   
 
1688
 
 
1689
if l==0 then bugmes();quit;end
 
1690
 
 
1691
if 0==l then bugmes();quit;end
 
1692
 
 
1693
if l==l then,else bugmes();quit;end
 
1694
 
 
1695
if l<>l then bugmes();quit;end
 
1696
 
 
1697
if l==l1 then bugmes();quit;end
 
1698
 
 
1699
if l1==l then bugmes();quit;end
 
1700
 
 
1701
if l<>l1 then , else bugmes();quit;end
 
1702
 
 
1703
if l1<>l then , else bugmes();quit;end
 
1704
 
 
1705
 
 
1706
 
 
1707
if %t&1==2 then bugmes();quit;end
 
1708
 
 
1709
if %t|1==2 then, else bugmes();quit;end
 
1710
 
 
1711
if %t&-1==2 then bugmes();quit;end
 
1712
 
 
1713
if %t|-1==2 then, else bugmes();quit;end
 
1714
 
 
1715
if 1<2&1==2 then bugmes();quit;end
 
1716
 
 
1717
if 1<2|1==2 then, else bugmes();quit;end
 
1718
 
 
1719
if 1<2&-1==2 then bugmes();quit;end
 
1720
 
 
1721
if 1<2|-1==2 then, else bugmes();quit;end
 
1722
 
 
1723
if 2>1&1==2 then bugmes();quit;end
 
1724
 
 
1725
if 2>1|1==2 then, else bugmes();quit;end
 
1726
 
 
1727
if 2>1&-1==2 then bugmes();quit;end
 
1728
 
 
1729
if 2>1|-1==2 then, else bugmes();quit;end
 
1730
 
 
1731
if 1==1&1==2 then bugmes();quit;end
 
1732
 
 
1733
if 1==1|1==2 then, else bugmes();quit;end
 
1734
 
 
1735
if 1==1&-1==2 then bugmes();quit;end
 
1736
 
 
1737
if 1==1|-1==2 then, else bugmes();quit;end
 
1738
 
 
1739
if 1<>2&1==2 then bugmes();quit;end
 
1740
 
 
1741
if 1<>2|1==2 then, else bugmes();quit;end
 
1742
 
 
1743
if 1<>2&-1==2 then bugmes();quit;end
 
1744
 
 
1745
if 1<>2|-1==2 then, else bugmes();quit;end
 
1746
 
 
1747
 
 
1748
if %t&1>2 then bugmes();quit;end
 
1749
 
 
1750
if %t|1>2 then, else bugmes();quit;end
 
1751
 
 
1752
if %t&-1>2 then bugmes();quit;end
 
1753
 
 
1754
if %t|-1>2 then, else bugmes();quit;end
 
1755
 
 
1756
if 1<2&1>2 then bugmes();quit;end
 
1757
 
 
1758
if 1<2|1>2 then, else bugmes();quit;end
 
1759
 
 
1760
if 1<2&-1>2 then bugmes();quit;end
 
1761
 
 
1762
if 1<2|-1>2 then, else bugmes();quit;end
 
1763
 
 
1764
if 2>1&1>2 then bugmes();quit;end
 
1765
 
 
1766
if 2>1|1>2 then, else bugmes();quit;end
 
1767
 
 
1768
if 2>1&-1>2 then bugmes();quit;end
 
1769
 
 
1770
if 2>1|-1>2 then, else bugmes();quit;end
 
1771
 
 
1772
if 1==1&1>2 then bugmes();quit;end
 
1773
 
 
1774
if 1==1|1>2 then, else bugmes();quit;end
 
1775
 
 
1776
if 1==1&-1>2 then bugmes();quit;end
 
1777
 
 
1778
if 1==1|-1>2 then, else bugmes();quit;end
 
1779
 
 
1780
if 1<>2&1>2 then bugmes();quit;end
 
1781
 
 
1782
if 1<>2|1>2 then, else bugmes();quit;end
 
1783
 
 
1784
if 1<>2&-1>2 then bugmes();quit;end
 
1785
 
 
1786
if 1<>2|-1>2 then, else bugmes();quit;end
 
1787
 
 
1788