|
660 | 660 | (error? (fxvector-copy '(a b c)))
|
661 | 661 | )
|
662 | 662 |
|
| 663 | +(mat fxvector-copy! |
| 664 | + (begin |
| 665 | + (define $v1 (fxvector 1 2 3 4)) |
| 666 | + (define $v2 (fxvector 255 254 253 252 251 250 249 248 247)) |
| 667 | + (and (fxvector? $v1) |
| 668 | + (fxvector? $v2) |
| 669 | + (eqv? (fxvector-length $v1) 4) |
| 670 | + (eqv? (fxvector-length $v2) 9))) |
| 671 | +
|
| 672 | + ; wrong number of arguments |
| 673 | + (error? (fxvector-copy!)) |
| 674 | + (error? (fxvector-copy! $v2)) |
| 675 | + (error? (fxvector-copy! $v2 3)) |
| 676 | + (error? (fxvector-copy! $v2 3 $v1)) |
| 677 | + (error? (fxvector-copy! $v2 3 $v1 1)) |
| 678 | + (error? (if (fxvector-copy! $v2 3 $v1 1 2 3) #f #t)) |
| 679 | +
|
| 680 | + ; not fxvector |
| 681 | + (error? (fxvector-copy! 0 0 $v2 0 0)) |
| 682 | + (error? (if (fxvector-copy! $v1 0 (vector 1 2 3) 0 0) #f #t)) |
| 683 | +
|
| 684 | + ; bad index |
| 685 | + (error? (fxvector-copy! $v1 -1 $v2 0 0)) |
| 686 | + (error? (fxvector-copy! $v1 0 $v2 -1 0)) |
| 687 | + (error? (fxvector-copy! $v1 'a $v2 0 0)) |
| 688 | + (error? (fxvector-copy! $v1 0 $v2 0.0 0)) |
| 689 | + (error? (fxvector-copy! $v1 (+ (most-positive-fixnum) 1) $v2 0 0)) |
| 690 | + (error? (if (fxvector-copy! $v1 0 $v2 (+ (most-positive-fixnum) 1) 0) #f #t)) |
| 691 | + |
| 692 | + ; bad count |
| 693 | + (error? (fxvector-copy! $v1 0 $v2 0 -1)) |
| 694 | + (error? (fxvector-copy! $v1 0 $v2 0 (+ (most-positive-fixnum) 1))) |
| 695 | + (error? (if (fxvector-copy! $v1 0 $v2 0 'a) #f #t)) |
| 696 | +
|
| 697 | + ; beyond end |
| 698 | + (error? (fxvector-copy! $v1 0 $v2 0 5)) |
| 699 | + (error? (fxvector-copy! $v2 0 $v1 0 5)) |
| 700 | + (error? (fxvector-copy! $v1 1 $v2 0 4)) |
| 701 | + (error? (fxvector-copy! $v2 0 $v1 1 4)) |
| 702 | + (error? (fxvector-copy! $v1 2 $v2 0 3)) |
| 703 | + (error? (fxvector-copy! $v2 0 $v1 2 3)) |
| 704 | + (error? (fxvector-copy! $v1 3 $v2 0 2)) |
| 705 | + (error? (fxvector-copy! $v2 0 $v1 3 2)) |
| 706 | + (error? (fxvector-copy! $v1 4 $v2 0 1)) |
| 707 | + (error? (fxvector-copy! $v2 0 $v1 4 1)) |
| 708 | + (error? (fxvector-copy! $v2 0 $v1 0 500)) |
| 709 | + (error? (if (fxvector-copy! $v2 500 $v1 0 0) #f #t)) |
| 710 | +
|
| 711 | + ; make sure no damage done |
| 712 | + (and (fxvector? $v1) |
| 713 | + (fxvector? $v2) |
| 714 | + (equal? $v1 #vfx(1 2 3 4)) |
| 715 | + (equal? $v2 #vfx(255 254 253 252 251 250 249 248 247))) |
| 716 | +
|
| 717 | + (begin |
| 718 | + (fxvector-copy! $v2 3 $v1 1 2) |
| 719 | + (and (equal? $v1 #vfx(1 252 251 4)) |
| 720 | + (equal? $v2 #vfx(255 254 253 252 251 250 249 248 247)))) |
| 721 | + (begin |
| 722 | + (fxvector-copy! $v2 6 $v1 2 2) |
| 723 | + (and (equal? $v1 #vfx(1 252 249 248)) |
| 724 | + (equal? $v2 #vfx(255 254 253 252 251 250 249 248 247)))) |
| 725 | + (begin |
| 726 | + (fxvector-copy! $v2 0 $v1 4 0) |
| 727 | + (and (equal? $v1 #vfx(1 252 249 248)) |
| 728 | + (equal? $v2 #vfx(255 254 253 252 251 250 249 248 247)))) |
| 729 | + (begin |
| 730 | + (fxvector-copy! $v2 3 $v1 4 0) |
| 731 | + (and (equal? $v1 #vfx(1 252 249 248)) |
| 732 | + (equal? $v2 #vfx(255 254 253 252 251 250 249 248 247)))) |
| 733 | + (begin |
| 734 | + (fxvector-copy! $v2 3 $v2 4 0) |
| 735 | + (and (equal? $v1 #vfx(1 252 249 248)) |
| 736 | + (equal? $v2 #vfx(255 254 253 252 251 250 249 248 247)))) |
| 737 | + (begin |
| 738 | + (fxvector-copy! $v2 2 $v1 1 3) |
| 739 | + (and (equal? $v1 #vfx(1 253 252 251)) |
| 740 | + (equal? $v2 #vfx(255 254 253 252 251 250 249 248 247)))) |
| 741 | + (begin |
| 742 | + (fxvector-copy! $v1 0 $v2 3 4) |
| 743 | + (and (equal? $v1 #vfx(1 253 252 251)) |
| 744 | + (equal? $v2 #vfx(255 254 253 1 253 252 251 248 247)))) |
| 745 | + (begin |
| 746 | + (fxvector-copy! $v2 0 $v2 3 5) |
| 747 | + (and (equal? $v1 #vfx(1 253 252 251)) |
| 748 | + (equal? $v2 #vfx(255 254 253 255 254 253 1 253 247)))) |
| 749 | + (begin |
| 750 | + (fxvector-copy! $v2 4 $v2 2 5) |
| 751 | + (and (equal? $v1 #vfx(1 253 252 251)) |
| 752 | + (equal? $v2 #vfx(255 254 254 253 1 253 247 253 247)))) |
| 753 | + (begin |
| 754 | + (fxvector-copy! $v2 1 $v2 1 7) |
| 755 | + (and (equal? $v1 #vfx(1 253 252 251)) |
| 756 | + (equal? $v2 #vfx(255 254 254 253 1 253 247 253 247)))) |
| 757 | +) |
| 758 | +
|
663 | 759 | (mat fxvector-fill!
|
664 | 760 | (let ([v (fxvector-copy '#5vfx(1 2 3 4 5))])
|
665 | 761 | (and (equal? v '#5vfx(1 2 3 4 5))
|
|
815 | 911 | (error? (flvector-copy '(a b c)))
|
816 | 912 | )
|
817 | 913 |
|
| 914 | +(mat flvector-copy! |
| 915 | + (begin |
| 916 | + (define $v1 (flvector 1.0 2.0 3.0 4.0)) |
| 917 | + (define $v2 (flvector 255.0 254.0 253.0 252.0 251.0 250.0 249.0 248.0 247.0)) |
| 918 | + (and (flvector? $v1) |
| 919 | + (flvector? $v2) |
| 920 | + (eqv? (flvector-length $v1) 4) |
| 921 | + (eqv? (flvector-length $v2) 9))) |
| 922 | +
|
| 923 | + ; wrong number of arguments |
| 924 | + (error? (flvector-copy!)) |
| 925 | + (error? (flvector-copy! $v2)) |
| 926 | + (error? (flvector-copy! $v2 3)) |
| 927 | + (error? (flvector-copy! $v2 3 $v1)) |
| 928 | + (error? (flvector-copy! $v2 3 $v1 1)) |
| 929 | + (error? (if (flvector-copy! $v2 3 $v1 1 2 3) #f #t)) |
| 930 | +
|
| 931 | + ; not flvector |
| 932 | + (error? (flvector-copy! 0 0 $v2 0 0)) |
| 933 | + (error? (if (flvector-copy! $v1 0 (vector 1 2 3) 0 0) #f #t)) |
| 934 | +
|
| 935 | + ; bad index |
| 936 | + (error? (flvector-copy! $v1 -1 $v2 0 0)) |
| 937 | + (error? (flvector-copy! $v1 0 $v2 -1 0)) |
| 938 | + (error? (flvector-copy! $v1 'a $v2 0 0)) |
| 939 | + (error? (flvector-copy! $v1 0 $v2 0.0 0)) |
| 940 | + (error? (flvector-copy! $v1 (+ (most-positive-fixnum) 1) $v2 0 0)) |
| 941 | + (error? (if (flvector-copy! $v1 0 $v2 (+ (most-positive-fixnum) 1) 0) #f #t)) |
| 942 | + |
| 943 | + ; bad count |
| 944 | + (error? (flvector-copy! $v1 0 $v2 0 -1)) |
| 945 | + (error? (flvector-copy! $v1 0 $v2 0 (+ (most-positive-fixnum) 1))) |
| 946 | + (error? (if (flvector-copy! $v1 0 $v2 0 'a) #f #t)) |
| 947 | +
|
| 948 | + ; beyond end |
| 949 | + (error? (flvector-copy! $v1 0 $v2 0 5)) |
| 950 | + (error? (flvector-copy! $v2 0 $v1 0 5)) |
| 951 | + (error? (flvector-copy! $v1 1 $v2 0 4)) |
| 952 | + (error? (flvector-copy! $v2 0 $v1 1 4)) |
| 953 | + (error? (flvector-copy! $v1 2 $v2 0 3)) |
| 954 | + (error? (flvector-copy! $v2 0 $v1 2 3)) |
| 955 | + (error? (flvector-copy! $v1 3 $v2 0 2)) |
| 956 | + (error? (flvector-copy! $v2 0 $v1 3 2)) |
| 957 | + (error? (flvector-copy! $v1 4 $v2 0 1)) |
| 958 | + (error? (flvector-copy! $v2 0 $v1 4 1)) |
| 959 | + (error? (flvector-copy! $v2 0 $v1 0 500)) |
| 960 | + (error? (if (flvector-copy! $v2 500 $v1 0 0) #f #t)) |
| 961 | +
|
| 962 | + ; make sure no damage done |
| 963 | + (and (flvector? $v1) |
| 964 | + (flvector? $v2) |
| 965 | + (equal? $v1 #vfl(1.0 2.0 3.0 4.0)) |
| 966 | + (equal? $v2 #vfl(255.0 254.0 253.0 252.0 251.0 250.0 249.0 248.0 247.0))) |
| 967 | +
|
| 968 | + (begin |
| 969 | + (flvector-copy! $v2 3 $v1 1 2) |
| 970 | + (and (equal? $v1 #vfl(1.0 252.0 251.0 4.0)) |
| 971 | + (equal? $v2 #vfl(255.0 254.0 253.0 252.0 251.0 250.0 249.0 248.0 247.0)))) |
| 972 | + (begin |
| 973 | + (flvector-copy! $v2 6 $v1 2 2) |
| 974 | + (and (equal? $v1 #vfl(1.0 252.0 249.0 248.0)) |
| 975 | + (equal? $v2 #vfl(255.0 254.0 253.0 252.0 251.0 250.0 249.0 248.0 247.0)))) |
| 976 | + (begin |
| 977 | + (flvector-copy! $v2 0 $v1 4 0) |
| 978 | + (and (equal? $v1 #vfl(1.0 252.0 249.0 248.0)) |
| 979 | + (equal? $v2 #vfl(255.0 254.0 253.0 252.0 251.0 250.0 249.0 248.0 247.0)))) |
| 980 | + (begin |
| 981 | + (flvector-copy! $v2 3 $v1 4 0) |
| 982 | + (and (equal? $v1 #vfl(1.0 252.0 249.0 248.0)) |
| 983 | + (equal? $v2 #vfl(255.0 254.0 253.0 252.0 251.0 250.0 249.0 248.0 247.0)))) |
| 984 | + (begin |
| 985 | + (flvector-copy! $v2 3 $v2 4 0) |
| 986 | + (and (equal? $v1 #vfl(1.0 252.0 249.0 248.0)) |
| 987 | + (equal? $v2 #vfl(255.0 254.0 253.0 252.0 251.0 250.0 249.0 248.0 247.0)))) |
| 988 | + (begin |
| 989 | + (flvector-copy! $v2 2 $v1 1 3) |
| 990 | + (and (equal? $v1 #vfl(1.0 253.0 252.0 251.0)) |
| 991 | + (equal? $v2 #vfl(255.0 254.0 253.0 252.0 251.0 250.0 249.0 248.0 247.0)))) |
| 992 | + (begin |
| 993 | + (flvector-copy! $v1 0 $v2 3 4) |
| 994 | + (and (equal? $v1 #vfl(1.0 253.0 252.0 251.0)) |
| 995 | + (equal? $v2 #vfl(255.0 254.0 253.0 1.0 253.0 252.0 251.0 248.0 247.0)))) |
| 996 | + (begin |
| 997 | + (flvector-copy! $v2 0 $v2 3 5) |
| 998 | + (and (equal? $v1 #vfl(1.0 253.0 252.0 251.0)) |
| 999 | + (equal? $v2 #vfl(255.0 254.0 253.0 255.0 254.0 253.0 1.0 253.0 247.0)))) |
| 1000 | + (begin |
| 1001 | + (flvector-copy! $v2 4 $v2 2 5) |
| 1002 | + (and (equal? $v1 #vfl(1.0 253.0 252.0 251.0)) |
| 1003 | + (equal? $v2 #vfl(255.0 254.0 254.0 253.0 1.0 253.0 247.0 253.0 247.0)))) |
| 1004 | + (begin |
| 1005 | + (flvector-copy! $v2 1 $v2 1 7) |
| 1006 | + (and (equal? $v1 #vfl(1.0 253.0 252.0 251.0)) |
| 1007 | + (equal? $v2 #vfl(255.0 254.0 254.0 253.0 1.0 253.0 247.0 253.0 247.0)))) |
| 1008 | +) |
| 1009 | +
|
818 | 1010 | (mat flvector-fill!
|
819 | 1011 | (let ([v (flvector-copy '#5vfl(1.0 2.0 3.0 4.0 5.0))])
|
820 | 1012 | (and (equal? v '#5vfl(1.0 2.0 3.0 4.0 5.0))
|
|
0 commit comments